在 Rocky Linux 8 上安装 Nikto Web Scanner

[ad_1]

在本教程中,您将学习如何在 Rocky Linux 8 上安装 Nikto 网络扫描仪。

Nikto 是一个 Perl 基于开源 Web 漏洞扫描程序,可以发现 Web 服务器上的所有其他潜在威胁,包括但不限于;

  • 不安全的文件和程序
  • 过时的服务器和程序
  • 服务器和软件配置错误
  • 默认文件和程序

Nikto 几乎可以在任何安装了 Perl 解释器的操作系统上运行。 它支持 SSL、代理、主机认证、攻击编码、IDS 验证等。

在 Rocky Linux 8 上安装 Nikto Web Scanner

您可以通过两种方式在 Rocky Linux 8 上安装 Nikto 网络扫描仪。

  1. 克隆 Nikto GitHub 存储库并运行 Nikto perl
  2. 从第三方存储库在 Rocky Linux 8 上安装 Nikto

克隆 Nikto GitHub Repo 并运行 Nikto perl 程序

在 Rocky Linux 上运行 Nikto 的最简单也是最推荐的方法是将其 GitHub 存储库克隆到您的系统并从存储库目录运行 Nikto perl 程序。

由于这是一个 perl 程序,您需要在系统上安装 perl,然后才能运行 Nikto。

dnf install perl

安装 Perl 后,克隆 Nikto 存储库;

git clone https://github.com/sullo/nikto

克隆存储库后,您现在可以切换到程序目录;

cd nikto/program

并运行 nikto.pl 程序。

语法是;

./nikto.pl [options...]

在没有任何命令行选项的情况下运行时,它会显示各种命令选项的基本描述;

./nikto.pl

样本输出;

- Nikto v2.1.6
---------------------------------------------------------------------------
+ ERROR: No host (-host) specified

   Options:
       -ask+               Whether to ask about submitting updates
                               yes   Ask about each (default)
                               no    Don't ask, don't send
                               auto  Don't ask, just send
       -Cgidirs+           Scan these CGI dirs: "none", "all", or values like "/cgi/ /cgi-a/"
       -config+            Use this config file
       -Display+           Turn on/off display outputs:
                               1     Show redirects
                               2     Show cookies received
                               3     Show all 200/OK responses
                               4     Show URLs which require authentication
                               D     Debug output
                               E     Display all HTTP errors
                               P     Print progress to STDOUT
                               S     Scrub output of IPs and hostnames
                               V     Verbose output
       -dbcheck           Check database and other key files for syntax errors
       -evasion+          Encoding technique:
                               1     Random URI encoding (non-UTF8)
                               2     Directory self-reference (/./)
                               3     Premature URL ending
                               4     Prepend long random string
                               5     Fake parameter
                               6     TAB as request spacer
                               7     Change the case of the URL
                               8     Use Windows directory separator ()
                               A     Use a carriage return (0x0d) as a request spacer
                               B     Use binary value 0x0b as a request spacer
       -Format+           Save file (-o) format:
                               csv   Comma-separated-value
                               json  JSON Format
                               htm   HTML Format
                               nbe   Nessus NBE format
                               sql   Generic SQL (see docs for schema)
                               txt   Plain text
                               xml   XML Format
                               (if not specified the format will be taken from the file extension passed to -output)
       -Help              This help information

如果您想查看有关上述选项的更多详细信息,请运行以下命令;

./nikto -H

使用 Nikto 执行 Web 扫描

在本节中,我们将了解 Nikto 如何与上面显示的各种命令行选项一起使用来执行 Web 扫描。

在其基本功能中,Nikto 只需要一个主机即可进行扫描。 目标主机可以用 -H 或者 -主持人 选项。 例如,要扫描 IP 地址为 192.168.60.20, 运行 Nikto 如下;

./nikto.pl -host 192.168.60.20
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          192.168.60.20
+ Target Hostname:    192.168.60.20
+ Target Port:        80
+ Start Time:         2021-07-13 22:17:01 (GMT3)
---------------------------------------------------------------------------
+ Server: Apache/2.4.37 (rocky)
+ Cookie PHPSESSID created without the httponly flag
+ Retrieved x-powered-by header: PHP/7.4.6
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type.
+ Root page / redirects to: login.php
+ Apache/2.4.37 appears to be outdated (current is at least Apache/2.4.46). Apache 2.2.34 is the EOL for the 2.x branch.
+ OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
+ OSVDB-3268: /config/: Directory indexing found.
+ /config/: Configuration information may be available remotely.
+ OSVDB-3268: /tests/: Directory indexing found.
+ OSVDB-3092: /tests/: This might be interesting.
+ OSVDB-3268: /icons/: Directory indexing found.
+ OSVDB-3268: /docs/: Directory indexing found.
+ OSVDB-3233: /icons/README: Apache default file found.
+ OSVDB-3092: /.git/index: Git Index file may contain directory listing information.
+ /.git/HEAD: Git HEAD file found. Full repo details may be present.
+ /.git/config: Git config file found. Infos about repo details may be present.
+ /.gitignore: .gitignore file found. It is possible to grasp the directory structure.
+ 8916 requests: 0 error(s) and 17 item(s) reported on remote host
+ End Time:           2021-07-13 22:17:16 (GMT3) (15 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

从输出中可以看出,当指定的目标主机没有端口时,Nikto 会扫描端口 80 默认情况下。

但是,如果您的 Web 服务器运行在不同的端口上,则必须使用 -p 或者 -港口 选项。

见下面的例子;

./nikto.pl -h 192.168.60.15 -p 8080

如果你在同一个主机服务器上有多个虚拟主机监听不同的端口,你可以指定多个端口,用逗号分隔它们。

./nikto.pl -h 192.168.60.20 -p 8080,8888

您还可以在格式中指定一系列端口 端口1-端口N 例如,

./nikto.pl -h 192.168.60.20 -p 8080-8888

例如,也可以使用 URL 代替使用 IP 地址指定目标主机;

./nikto.pl -h mydvwa.example.com
./nikto.pl -h https://mydvwa.example.com

也可以在使用 URL 时指定端口;

./nikto.pl -h mydvwa.example.com -p 8080
./nikto.pl -h https://mydvwa.example.com -p 8443

或者

./nikto.pl -h mydvwa.example.com:8080
./nikto.pl -h https://mydvwa.example.com:8443/

可以使用 -p 选项,也可以指定一个包含目标主机列表的文件,每行一个。 例如,您的文件应该包含格式的目标;

cat scan-targets
https://mydvwa.example.com:443/
192.168.60.20:8888
192.168.43.101

要同时扫描这些主机,请运行以下命令;

./nikto.pl -h scan-targets

还可以使用 Nmap 扫描侦听 Web 服务器端口的网络中的主机,并将输出传递到 ./nikto.pl。 例如要扫描网络中的开放端口 80,192.168.43.0/24,

nmap -p80 192.168.60.0/24 -oG - | ./nikto.pl -h -

如果您通过代理服务器,您可以要求 ./nikto.pl 使用代理 -使用代理服务器 选项。 您可以在 ./nikto.pl 配置文件中设置代理详细信息, /etc/./nikto.pl/config.txt 或者您可以在命令行上进行操作,如下所示;

要在 /etc/./nikto.pl/config.txt 文件中定义代理服务器详细信息,请使用以下格式;

PROXYHOST=192.168.20.45
PROXYPORT=3128
PROXYUSER=username
PROXYPASS=password

当您如上所示定义了代理详细信息后,请按如下方式运行 ./nikto.pl;

./nikto.pl -h 192.168.20.128 -useproxy

在命令行上指定代理连接的详细信息;

./nikto.pl -h 192.168.20.128 -useproxy https://id:[email protected]:3128/
./nikto.pl -h 192.168.20.128 -useproxy https://@192.168.20.23:3128/

Nikto 可以导出不同格式的扫描结果; CSV、HTML、XML、NBE、文本。 要将结果保存为特定的输出格式,您需要指定 -o/-输出 选项以及 -格式 选项来定义输出格式。 请参阅以下示例以 html 格式保存扫描结果。

./nikto.pl -h 192.168.60.20 -o /var/www/html/test.html -F html

因此,您可以通过网络浏览器访问该报告。 见下面的截图;

Nikto 还可以进行微调以执行特定的扫描。 以下是可用于实现此功能的调整选项的说明。

1 - Interesting File / Seen in logs
2 - Misconfiguration / Default File
3 - Information Disclosure
4 - Injection (XSS/Script/HTML)
5 - Remote File Retrieval - Inside Web Root
6 - Denial of Service
7 - Remote File Retrieval - Server Wide
8 - Command Execution / Remote Shell
9 - SQL Injection
0 - File Upload
a - Authentication Bypass
b - Software Identification
c - Remote Source Inclusion
x - Reverse Tuning Options (i.e., include all except specified)

例如,要测试 SQL 注入和远程文件检索 – 服务器范围,您可以使用 ./nikto.pl 之类的;

./nikto.pl -h 192.168.60.20 -Tuning 79 -o /var/www/html/test.html -F html

示例命令输出;

- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          192.168.60.20
+ Target Hostname:    192.168.60.20
+ Target Port:        80
+ Start Time:         2021-07-13 22:27:33 (GMT3)
---------------------------------------------------------------------------
+ Server: Apache/2.4.37 (rocky)
+ Cookie PHPSESSID created without the httponly flag
+ Retrieved x-powered-by header: PHP/7.4.6
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type.
+ Root page / redirects to: login.php
+ Apache/2.4.37 appears to be outdated (current is at least Apache/2.4.46). Apache 2.2.34 is the EOL for the 2.x branch.
+ OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST
+ 717 requests: 0 error(s) and 6 item(s) reported on remote host
+ End Time:           2021-07-13 22:27:35 (GMT3) (2 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

从第三方存储库在 Rocky Linux 8 上安装 Nikto

Nikto 可以从 EPEL 存储库安装,但还有一些其他必需的依赖项可以由第三方 GetPageSpeed 存储库提供。

dnf install https://extras.getpagespeed.com/release-el8-latest.rpm epel-release

存储库到位后,在 Rocky Linux 8 上安装 Nikto。

dnf install nikto
============================================================================================================================================================================
 Package                                  Architecture                   Version                                   Repository                                          Size
============================================================================================================================================================================
Installing:
 nikto                                    noarch                         1:2.1.6-8.el8                             epel                                               352 k
Installing dependencies:
 perl-JSON-PP                             noarch                         1:2.97.001-3.el8                          appstream                                           67 k
 perl-Math-BigRat                         noarch                         0.2614-1.el8                              appstream                                           39 k
 perl-Time-HiRes                          x86_64                         4:1.9758-2.el8                            appstream                                           60 k
 perl-bignum                              noarch                         0.49-2.el8                                appstream                                           42 k
 perl-libwhisker2                         noarch                         2.5-29.el8                                getpagespeed-extras-noarch                          95 k

Transaction Summary
============================================================================================================================================================================
Install  6 Packages

Total download size: 655 k
Installed size: 2.8 M
Is this ok [y/N]: y

然后,您可以像上面一样从命令行使用 Nikto,但您只需运行 nikto 代替 ./nikto.pl.

nikto
- ***** RFIURL is not defined in nikto.conf--no RFI tests will run *****
- Nikto v2.1.6
---------------------------------------------------------------------------
+ ERROR: No host specified

       -config+            Use this config file
       -Display+           Turn on/off display outputs
       -dbcheck            check database and other key files for syntax errors
       -Format+            save file (-o) format
       -Help               Extended help information
       -host+              target host
       -id+                Host authentication to use, format is id:pass or id:pass:realm
       -list-plugins       List all available plugins
       -output+            Write output to this file
       -nossl              Disables using SSL
       -no404              Disables 404 checks
       -Plugins+           List of plugins to run (default: ALL)
       -port+              Port to use (default 80)
       -root+              Prepend root value to all requests, format is /directory 
       -ssl                Force ssl mode on port
       -Tuning+            Scan tuning
       -timeout+           Timeout for requests (default 10 seconds)
       -update             Update databases and plugins from CIRT.net
       -Version            Print plugin and database versions
       -vhost+             Virtual host (for Host header)
   		+ requires a value

	Note: This is the short help output. Use -H for full help text.

这就是如何在 Rocky Linux 8 上安装 Nikto Web Scanner 的全部内容。

随意从 Nikto 文档页面探索其他命令行选项的基本用法。

使用 Wazuh 和 VirusTotal 检测恶意文件

使用 ModSecurity 和 ClamAV 拦截恶意文件上传

在 Ubuntu 20.04 上安装和使用 ClamAV

[ad_2]

Related Posts