[ 首页 ] [ 渗透测试 ] [ 黑客接单 ] [ 黑客技术 ] [ 黑客论坛 ] [ 黑客松 ]



标题 : 怎么黑入网站后台入侵渗透教程
日期 : 2023-03-14

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

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

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

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

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

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

步骤 1安装 Nikto

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

apt install nikto

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

brew install nikto

步骤 2了解日都

在深入了解使用 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

步骤 3使用基本语法

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

nikto -h <IP or hostname>

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

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

nikto -h <IP or hostname> -ssl

步骤 4扫描启用了 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

步骤 5扫描 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 已打开的主机。然后我们将所有内容保存到一个文件中,我将其命名为 nullbyte.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 来读取存储在 nullbyte.txt 文档中的输出(或任何您命名的文档)。然后,有一个awk,一个Linux工具,可以帮助搜索以下模式,其中Up表示主机已启动,打印$ 2表示为每个单词打印出该行中的第二个单词,即仅IP地址。然后,我们将该数据发送到一个名为 targetIP.txt(或任何您想命名的文件)的新文件。

cat nullbyte.txt | awk '/Up$/{print $2}' | cat >> targetIP.txt

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

cat targetIP.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 targetIP.txt

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

步骤 6扫描 HTTP 网站

我们已经扫描了一个安全的网站和本地网络上的 IP 地址,现在是时候使用端口 80 来追踪不安全的 Web 域了。在本例中,我使用的是“afl.com.au”,在我执行此扫描时未使用 SSL。

nikto -h www.afl.com.au
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP:          159.180.84.10
+ Target Hostname:    www.afl.com.au
+ Target Port:        80
+ Start Time:         2018-12-05 21:48:32 (GMT-8)
---------------------------------------------------------------------------
+ Server: instart/nginx
+ Retried via header: 1.1 varnish (Varnish/6.1), 1.1 e9ba0a9a729ff2960a04323bf1833df8.cloudfront.net (CloudFront)
+ 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-cache' found, with contents: Miss from cloudfront
+ Uncommon header 'x-instart-cache-id' found, with contents: 17:12768802731504004780::1544075250
+ Uncommon header 'v-cache-hit' found, with contents: Hit
+ Uncommon header 'x-amz-cf-id' found, with contents: Dr-r6OwO5kk9ABt4ejzpc7R7AIF6SuH6kfJHQgP0v6xZoHwMLE55rQ==
+ Uncommon header 'x-instart-request-id' found, with contents: 12814413144077601501:BEQ01-CPVNPPRY18:1552504721:0
+ Uncommon header 'x-oneagent-js-injection' found, with contents: true
+ Uncommon header 'grace' found, with contents: cache
+ 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
+ Uncommon header 'x-ruxit-js-agent' found, with contents: true
+ Cookie dtCookie created without the httponly flag
+ Server banner has changed from 'instart/nginx' to 'nginx' which may suggest a WAF, load balancer or proxy is in place
+ No CGI Directories found (use '-C all' to force check all possible dirs)
+ Entry '/sites/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/search/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '*.mobileapp' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '*.liveradio' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '*.smartmobile' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '*.responsive' in robots.txt returned a non-forbidden or redirect HTTP code (400)
+ Entry '/stats?*/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ "robots.txt" contains 8 entries which should be manually viewed.
+ OSVDB-3092: /sitemap.xml: This gives a nice listing of the site content.
+ OSVDB-3092: /psql_history: This might be interesting...
+ OSVDB-3092: /global/: This might be interesting...
+ OSVDB-3092: /home/: This might be interesting...
+ OSVDB-3092: /news: This might be interesting...
+ OSVDB-3092: /search.vts: This might be interesting...
+ OSVDB-3092: /stats.htm: This might be interesting...
+ OSVDB-3092: /stats.txt: This might be interesting...
+ OSVDB-3092: /stats/: This might be interesting...
+ OSVDB-3092: /Stats/: This might be interesting...
+ OSVDB-3093: /.wwwacl: Contains authorization information
+ OSVDB-3093: /.www_acl: Contains authorization information
+ OSVDB-3093: /.htpasswd: Contains authorization information
+ OSVDB-3093: /.access: Contains authorization information
+ OSVDB-3093: /.addressbook: PINE addressbook, may store sensitive e-mail address contact information and notes
+ OSVDB-3093: /.bashrc: User home dir was found with a shell rc file. This may reveal file and path information.
+ OSVDB-3093: /.bash_history: A user's home directory may be set to the web root, the shell history was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.forward: User home dir was found with a mail forward file. May reveal where the user's mail is being forwarded to.
+ OSVDB-3093: /.history: A user's home directory may be set to the web root, the shell history was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.htaccess: Contains configuration and/or authorization information
+ OSVDB-3093: /.lynx_cookies: User home dir found with LYNX cookie file. May reveal cookies received from arbitrary web sites.
+ OSVDB-3093: /.mysql_history: Database SQL?
+ OSVDB-3093: /.passwd: Contains authorization information
+ OSVDB-3093: /.pinerc: User home dir found with a PINE rc file. May reveal system information, directories and more.
+ OSVDB-3093: /.plan: User home dir with a .plan, a now mostly outdated file for delivering information via the finger protocol
+ OSVDB-3093: /.proclog: User home dir with a Procmail rc file. May reveal mail traffic, directories and more.
+ OSVDB-3093: /.procmailrc: User home dir with a Procmail rc file. May reveal subdirectories, mail contacts and more.
+ OSVDB-3093: /.profile: User home dir with a shell profile was found. May reveal directory information and system configuration.
+ OSVDB-3093: /.rhosts: A user's home directory may be set to the web root, a .rhosts file was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.sh_history: A user's home directory may be set to the web root, the shell history was retrieved. This should not be accessible via the web.
+ OSVDB-3093: /.ssh: A user's home directory may be set to the web root, an ssh file was retrieved. This should not be accessible via the web.
+ OSVDB-5709: /.nsconfig: Contains authorization information
+ /portal/changelog: Vignette richtext HTML editor changelog found.
+ 7587 requests: 4 error(s) and 55 item(s) reported on remote host
+ End Time:           2018-12-05 22:42:41 (GMT-8) (3249 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

上面,我们可以看到有一个 Varnish 服务器和一些标头,有助于指示网站的配置方式。但是,更多汁的是找到的目录,这些目录可以帮助捕获可能包含凭据或其他配置错误且无意访问的内容的配置文件。

带有OSVDB前缀的项目是开源漏洞数据库(2016年关闭的站点)中报告的漏洞。它类似于其他漏洞数据库,如SecurityFocus,Microsoft的Technet和Common Vulnerability and Exposures。我更喜欢查看国家漏洞数据库.

虽然此扫描没有任何重大漏洞可以利用,但如果存在,您可以使用 CVE 参考工具将 OSVDB 标识符转换为 CVE 条目,以便您可以使用上面的其他站点之一来阅读有关该漏洞的更多信息。

假设我们发现了一些值得探索的东西,例如CVE-2018-10933,这是我们之前详细介绍过的Libssh漏洞。CVE 包含有关可利用的内容、严重性分数(如严重)的信息,以及可帮助确定攻击媒介的其他一些信息。如果它值得使用,你可以搜索Metasploit,因为有人可能已经开发了一个武器化模块,以便更容易地利用它。

怎么黑入网站后台入侵渗透教程

步骤 7将扫描与 Metasploit 配对

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

nikto -h <IP or hostname> -Format msf+

因此,在本指南中,我们从确定目标的表面积到发现漏洞,然后将其与武器化漏洞配对,这样我们就不必做所有的工作。由于 Nikto 不是一个隐蔽的工具,因此明智的做法是从 VPN、Tor 或其他类型的服务执行这些类型的扫描,这样您的真实 IP 地址就不会被标记为可疑行为。

不要错过: 如何使用没有root的Android手机扫描网站漏洞