Nikto基础使用教学

使用 Nikto 扫描任何网站上的漏洞

在攻击任何网站之前,黑客或渗透测试人员将首先编制目标表面列表。在他们使用了一些良好的侦察并找到正确的位置来定位他们的范围之后,他们将使用 Nikto 等 Web 服务器扫描工具来寻找可能是潜在攻击媒介的漏洞。

图片[1]-Nikto基础使用教学-可能资源网

Nikto 是一种简单的开源 Web 服务器扫描程序,可检查网站并报告发现可用于利用或破解该网站的漏洞。此外,它是业内使用最广泛的网站漏洞工具之一,在许多圈子里,被认为是行业标准。

虽然这个工具非常有效,但它一点也不隐蔽。任何具有入侵检测系统或其他安全措施的站点都会检测到它正在被扫描。最初是为安全测试而设计的,隐身从来都不是问题。

不要错过:使用Metasploit的WMAP扫描Web应用程序的漏洞

如果幸运的话,将发现具有武器化漏洞的漏洞,这意味着已经有一个工具可以利用该漏洞。使用自动利用此漏洞的适当工具,黑客可以访问目标以执行任意数量的幕后攻击,例如添加代码以执行恶意活动。

安装 Nikto

如果您运行的是Kali Linux,则预装了Nikto,因此您无需下载或安装任何东西。它将位于“漏洞分析”类别中。如果由于某种原因没有它,您可以从其GitHub获取Nikto,或者仅使用apt install命令。

apt install nikto

如果您在 Mac 上执行此操作,则可以使用 Homebrew 安装 Nikto。

brew install nikto

了解日都

在深入了解使用 Nikto 扫描 Web 服务器之前, 允许您使用 -Help 选项查看在 Nikto 中可以执行的所有操作。

nikto -Help
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
                               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              Extended help information
       -host+             Target host
       -404code           Ignore these HTTP codes as negative responses (always). Format is "302,301".
       -404string         Ignore this string in response body content as negative response (always). Can be a regular expression.
       -id+               Host authentication to use, format is id:pass or id:pass:realm
       -key+              Client certificate key file
       -list-plugins      List all available plugins, perform no testing
       -maxtime+          Maximum testing time per host (e.g., 1h, 60m, 3600s)
       -mutate+           Guess additional file names:
                               1     Test all files with all root directories
                               2     Guess for password file names
                               3     Enumerate user names via Apache (/~user type requests)
                               4     Enumerate user names via cgiwrap (/cgi-bin/cgiwrap/~user type requests)
                               5     Attempt to brute force sub-domain names, assume that the host name is the parent domain
                               6     Attempt to guess directory names from the supplied dictionary file
       -mutate-options    Provide information for mutates
       -nointeractive     Disables interactive features
       -nolookup          Disables DNS lookups
       -nossl             Disables the use of SSL
       -no404             Disables nikto attempting to guess a 404 page
       -Option            Over-ride an option in nikto.conf, can be issued multiple times
       -output+           Write output to this file ('.' for auto-name)
       -Pause+            Pause between tests (seconds, integer or float)
       -Plugins+          List of plugins to run (default: ALL)
       -port+             Port to use (default 80)
       -RSAcert+          Client certificate file
       -root+             Prepend root value to all requests, format is /directory
       -Save              Save positive responses to this directory ('.' for auto-name)
       -ssl               Force ssl mode on port
       -Tuning+           Scan tuning:
                               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
                               d     WebService
                               e     Administrative Console
                               x     Reverse Tuning Options (i.e., include all except specified)
       -timeout+          Timeout for requests (default 10 seconds)
       -Userdbs           Load only user databases, not the standard databases
                               all   Disable standard dbs and load only user dbs
                               tests Disable only db_tests and load udb_tests
       -useragent         Over-rides the default useragent
       -until             Run until the specified time or duration
       -update            Update databases and plugins from CIRT.net
       -useproxy          Use the proxy defined in nikto.conf, or argument http://server:port
       -Version           Print plugin and database versions
       -vhost+            Virtual host (for Host header)
   		+ requires a value

使用基本语法

从上一步可以看出,Nikto 有很多选项,但出于我们的目的,我们将坚持使用基本语法,如下所示。我们将替换为实际的 IP 地址或主机名,不带尖括号。

nikto -h <IP or hostname>

但是,Nikto能够进行扫描,该扫描可以针对SSL和端口443(HTTPS网站使用的端口)(HTTP默认使用端口80)。因此,我们不仅限于扫描旧站点,还可以对使用SSL的站点进行漏洞评估,这几乎是当今在搜索结果中索引的要求。

如果我们知道它是我们要定位的 SSL 站点,我们可以在 Nikto 中指定它,通过在命令末尾添加 -ssl 来节省一些扫描时间。

nikto -h <IP or hostname> -ssl

扫描启用了 SSL 的网站

例如,让我们从扫描 pbs.org 开始,以查看 Nikto 扫描将显示的一些类型的信息。在它连接到端口 443 后,我们看到有一些关于密码的有用信息以及其他详细信息的列表,例如服务器是 Nginx,但这里没有很多有趣的数据对我们来说。

nikto -h pbs.org -ssl
- Nikto v2.1.6
------------------------------------------------------------------------------
- STATUS: Starting up!
+ Target IP:			54.225.198.196
+ Target Hostname:		pbs.org
+ Traget Port:			443
------------------------------------------------------------------------------
+ SSl Info:			Subject:	/CN=www.pbs.org
					Altnames:	account.pbs.org, admin.pgs.org, dipsy-tc.pbs.org, docs.pbs.org, ga.video.cdn.pbs.org, git.pbs.org, heart.ops.pbs.org, hub-dev.pbs.org, image.pbs.org,
                    			jaws..pbs.org, kids.pbs.org, koth-qa.svp.pbs.org, login.pbs.org, ops.pbs.org, pbs.org, player.pbs.org, projects.pbs.org, sentry.pbs.org, teacherline.pbs.org,
                                urs.pbs.org, video.pbs.org, weta-qa.svp.pbs.org, whut-qa.svp.pbs.org, wnet.video-qa.pbs.org, wnet.video-staging.pbs.org, www-cache.pbs.org, www.pbs.org
                    Ciphers:	ECDHE-RSA-AES128-GCM-SHA256
                    Issuer:		/C-US/0=Let's Encrypt/CN=Let's Encrypt Authority X3
+ Start Time:			2018-12-05 23:34:06 (GMT-8)
------------------------------------------------------------------------------
+ Server: nginx
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
+ Uncommon header 'x-pbs-fwsrvname' found, with contents: fwcacheproxy1
+ The site uses SSL and the Strict-Transport-Security HTTP header is not defined.
+ 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: https://www.pbs.org/
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ RC-1918 IP address found in the 'x-pbs-appsvrip' header: The IP is "10.137.181.52".
+ Uncommon header 'x-cache-fs-status' found, with contents: EXPIRED
+ Uncommon header 'x-pbs-appsvrname' found, with contents: fwcacheproxy1
+ Uncommon header 'x-pbs-appsvrip' found, with contents: 10.137.181.52
+ Server leaks inodes via ETags, header found with file /pbs.org.zip, fields: 0x5b96537e 0x1678
+ 7446 requests: 0 error(s) and 10 item(s) reported on remote host
+ End Time:				2018-12-06 00:30:29 (GMT-8) (3383 seconds)
------------------------------------------------------------------------------
+ 1 host(s) tested

扫描 IP 地址

现在我们执行了网站的快速扫描,让我们尝试在本地网络上使用 Nikto 来查找嵌入式服务器,例如路由器的登录页面或另一台计算机上的 HTTP 服务,而这些服务器只是一个没有网站的服务器。首先,让我们使用 ifconfig 查找我们的 IP 地址.

ifconfig
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST>  mtu 1500
        inet 192.168.0.48  netmask 0xffffff00  broadcast 192.168.0.255
        inet6 XXXX::XXX:XXXX:XXXX:XXXX%en0  prefixlen 64  secured scopeid 0x8
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        inet6 XXXX::XXX:XXXX:XXXX:XXXX%en0  prefixlen 64 autoconf secured
        inet6 XXXX::XXX:XXXX:XXXX:XXXX%en0  prefixlen 64 autoconf temporary
        nd6 options=201<PERFORMNUD,DAD>
        media: autoselect
        status: active

en2: flags=8863<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST>  mtu 1500
        options=60<TS04,TS06>
        ether XX:XX:XX:XX:XX:XX
        media: autoselect <full-duplex>
        status: inactive

我们想要的IP地址是“inet”地址。然后我们可以在其上运行ipcalc以获取我们的网络范围。如果您没有ipcalc,可以使用apt install ipcalc安装它,然后重试。范围将在“网络”旁边,在我的例子中是 192.168.0.0/24。

ipcalc 192.168.0.48
Address:   192.168.0.48         11000000.10101000.00000000. 00110000
Netmask:   255.255.255.0 = 24   11111111.11111111.11111111. 00000000
Wildcard:  0.0.0.255            00000000.00000000.00000000. 11111111
=>
Network:   192.168.0.0/24       11000000.10101000.00000000. 00000000
HostMin:   192.168.0.1          11000000.10101000.00000000. 00000001
HostMax:   192.168.0.254        11000000.10101000.00000000. 11111110
Broadcast: 192.168.0.255        11000000.10101000.00000000. 11111111
Hosts/Net: 254                   Class C, Private Internet

现在,我们要运行 Nmap 来查找在网络范围内运行的服务。让我们用我们的范围扫描端口 80,并附加 -oG(grepable 输出)以仅提取已启动并正在运行的主机,即响应指示端口 80 已打开的主机。然后我们将所有内容保存到一个文件中,我将其命名为 kngzs.txt,但可以命名为任何内容。

nmap -p 80 192.168.0.0/24 -oG nullbyte.txt
Starting Nmap 7.60 ( https://nmap.org ) at 2018-12-06 00:43 PST
Nmap scan report for 192.168.0.1
Host is up (0.021s latency).

PORT   STATE SERVICE
80/tcp open  http

Nmap scan report for 192.168.0.2
Host is up (0.088s latency).

PORT   STATE SERVICE
80/tcp open  http

Nmap scan report for 192.168.0.4
Host is up (0.032s latency).

PORT   STATE SERVICE
80/tcp open  http

Nmap scan report for 192.168.0.5
Host is up (0.020s latency).

PORT   STATE SERVICE
80/tcp open  http

Nmap scan report for 192.168.0.11
Host is up (0.068s latency).

PORT   STATE  SERVICE
80/tcp closed http

Nmap scan report for 192.168.0.24
Host is up (0.023s latency).

PORT   STATE  SERVICE
80/tcp closed http

Nmap scan report for 192.168.0.31
Host is up (0.059s latency).

PORT   STATE  SERVICE
80/tcp closed http

Nmap scan report for 192.168.0.48
Host is up (0.030s latency).

PORT   STATE  SERVICE
80/tcp closed http

Nmap scan report for 192.168.0.60
Host is up (0.092s latency).

PORT   STATE  SERVICE
80/tcp closed http

Nmap done: 256 IP addresses (9 hosts up) scanned in 8.92 seconds

有一个不错的小技巧可以将所有启动的主机直接发送到 Nikto 进行扫描。我们使用 cat 来读取存储在 kngzs.txt 文档中的输出(或任何您命名的文档)。然后,有一个awk,一个Linux工具,可以帮助搜索以下模式,其中Up表示主机已启动,打印$ 2表示为每个单词打印出该行中的第二个单词,即仅IP地址。然后,我们将该数据发送到一个名为 kngzsip.txt(或任何您想命名的文件)的新文件。

cat kngzs.txt | awk '/Up$/{print $2}' | cat >> kngzsip.txt

我们现在可以使用 cat 查看新文件的内容,以查看所有打开端口 80 的 IP 地址。

cat kngzsip.txt
192.168.0.1
192.168.0.2
192.168.0.4
192.168.0.5
192.168.0.11
192.168.0.24
192.168.0.31
192.168.0.48
192.168.0.60

这对 Nikto 来说是完美的,因为它可以轻松解释这样的文件。因此,我们可以使用以下命令将此输出发送到 Nikto。

nikto -h kngzsip.txt

结果看起来类似于我们在执行SSL扫描时得到的结果。

将扫描与 Metasploit 配对

关于Nikto的最好的事情之一是,您实际上可以将信息导出为Metasploit在执行扫描时可以读取的格式。为此,只需使用上面的命令执行扫描,但将 -Format msf+ 附加到扫描的末尾。该格式可以帮助我们快速将检索到的数据与武器化漏洞配对。

THE END