Page cover

BlockBlock

Synopsis

BlockBlock is a linux hard machine created by 0xOZ. The report user feature is vulnerable to XSS. Got the admin JWT token by exploiting XSS and admin account is accessed. The blockchain block can be viewed and one of the block contains the keira user password. The keira user can run forge command as a paul which is vulnerable to RCE and exploitable to gain the paul user reverse shell. The paul has a sudo privilege to run the pacman command which is package manager for arch linux. The malicious package is created to privilege escalate to root using pacman.

OS
Difficulty
Points
Release Date
Retired Date

Linux

Hard

40

16-11-2024

29-03-2025


Enumeration

Nmap

Starting the nmap scan and found ssh and http services running.

nmap -Pn -sC -sV --min-rate=1000 10.10.11.43                                      
Starting Nmap 7.95 ( https://nmap.org ) at 2025-03-30 10:40 EDT
Nmap scan report for 10.10.11.43
Host is up (0.95s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 9.7 (protocol 2.0)
| ssh-hostkey: 
|   256 d6:31:91:f6:8b:95:11:2a:73:7f:ed:ae:a5:c1:45:73 (ECDSA)
|_  256 f2:ad:6e:f1:e3:89:38:98:75:31:49:7a:93:60:07:92 (ED25519)
80/tcp open  http    Werkzeug httpd 3.0.3 (Python 3.12.3)
|_http-title:          Home  - DBLC    
|_http-server-header: Werkzeug/3.0.3 Python/3.12.3

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 57.36 seconds

Web - Port 80

The port 80 is hosting the Decentralized Chat app where the ethereum is used for making chat application .

Visiting the Chat and Profile endpoints without login gives us the {"msg":"Missing cookie "token""} message. The Register and Login endpoints provides us the form for registration and login.

Registering, gives us the access to the chat and profile endpoints. The chat has a messaging and reporting user features. The BOT sends us the greetings message in secure blockchain chat app. The profile shows the username, role and recent messages history. Currently I have a user role.

chat
profile

Sending message doesn't do anything and intercepting the request shows the JWT token.

The chat endpoints gives us link to the smart contracts. The two smart contract Chat.sol and Database.sol is present. The Chat.sol is used for handling chats and Database.sol is used database.

File - Database.sol

The above code creates the struct with password, role and exists. It contains the functions for registering user, updating role, changing password, deleting messages and so on.


Exploitation

Report User Feature - XSS [ Getting Admin JWT token ]

Opening the python server and testing the XSS payload in Report User feature gives us the positive result.

I am going to get the admin JWT token. The cookie has the HttpOnly flag set, so the document.cookie doesn't gives us the cookie. The /app/info endpoint leaks the JWT token and I will be using script to fetch the token from the endpoint and send the request to my nc listener.

Changed the value of cookie using dev tools and refreshed the page. Got the admin access.


Foothold

Shell - keira [ Getting Raw Blockchain ]

The admin panel is making /api/chat_address GET request and /api/json-rpc POST request.

/api/chat_address
/api/json-rpc

The /api/json-rpc can be used to get the block details with the help of eth_getBlockByNumber(). function. Sending the request to /api/json-rpc with method as eth_getBlockByNumber gives us the information about the blocks.

Getting the block 1 input and decoding it using cyberchef leaks the credentials of user keira.

The credentials is also used in ssh.

The user.txt file contains the user flag 👏


Lateral Movement

Pillaging - keira [ user ]

The user keira has a privilege to run the foundry forge with sudo privilege as paul user which is present in paul home directory.

Shell - paul [ RCE via forge ]

Forge is a command-line tool that ships with Foundry. Forge tests, builds, and deploys smart contracts.

Methodology

The forge build contains the --use flag for specifying the solc version, or a path to a local solc, to build with. It can be used to specify the path to reverse shell file and forge will build with the reverse shell and the reverse shell is established in our nc.

Exploit

1

Create the reverse shell

Make it executable.

2

Getting shell

Open nc listener and run the forge build with --use flag.


Privilege Escalation

Pillaging - paul [ user ]

The paul is privileged to run the pacman cli as root which is the arch linux package manager same as apt on debian based linux distros.

Shell - root [ pacman privilege escalation ]

TheCyberSimon has created the blog post about privilege escalation using pacman.

Methodology

Creating malicious package which is used to add our public SSH key to root authorized_keys file.

Exploit

1

Creating PKGBUILD file

2

Generating SSH keys

3

Building package

The makepkg is used to build packages in arch linux.

4

Install the package

Previously the makepkg command created the .zst file. To install the package the pacman command is used.

5

Transfering id_rsa to our machine

The python3 is present in machine. So, I will be using python http server for serving the file.

Change the permission of id_rsa to 600.

6

Getting shell

The root.txt file contains the root flag 🎉


Proof of Concept

The below video provides the PoC of BlockBlock machine.

Last updated