SlideShare a Scribd company logo
Heuristic methods
used in sqlmap
Miroslav Štampar
(dev@sqlmap.org)
Heuristic methods
used in sqlmap
Miroslav Štampar
(dev@sqlmap.org)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 2
Heuristic method
Heuristic (/hjʉˈrɪstɨk/; Greek: “Εὑρίσκω”, “find” or
“discover”)
Educational shortcuts to ease the cognitive load of
making a decision
Speeding up the process of finding a satisfactory
solution
Serve as an aid to learning, discovery and problem
solving
Experimental and trial-and-error approach
Resulting with a solution which is not guaranteed to
be optimal
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 3
Heuristic SQL injection checks (1)
In some cases DBMS error reporting is enabled
Deliberately invalid parameter value is sent (e.g.
())'”(''”')
 ”SQL error: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL
server version...”
Narrowing down tests to only those specific to
recognized/parsed DBMS
Automatically extending with DBMS specific tests that
would be done (only) on higher level
Switch --smart for finding targets in minutes
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 4
Heuristic SQL injection checks (2)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 5
Heuristic SQL injection checks (3)
Particularly interesting cases when parameter
contains integer value (e.g. id=1)
Response is changing with value changed (e.g. id=2)
Response is the same for arithmetic operation resulting
in original value (e.g. id=1183-1182)
Warning the user that the processed parameter is
most probably prone to SQL injection attack(s)
Making user aware to persist in eventual further tests
(to use higher --level/--risk and/or --tamper)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 6
Heuristic SQL injection checks (4)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 7
Heuristic SQL injection checks (5)
In cases when error reporting is turned off
At least one generic (i.e. non-DBMS dependent) SQL
injection technique is found
Single request per supported DBMS is being sent
Using form supported by only the targeted one (e.g.
id=1 AND (SELECT 0x41597548)=0x41597548)
for MySQL)
If getting response as expected, narrowing and/or
expanding tests for particular DBMS
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 8
Heuristic SQL injection checks (6)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 9
Type casting detection (1)
In some cases (preventive) hard type casting (e.g.
$id=intval($_REQUEST['id'])) is used
Especially noticeable on integer parameter values
(e.g. id=1)
Different responses for different integer values (e.g.
id=2)
Same response for appended random string values
(e.g. id=1vHxr)
High probability that the type casting is being used
(hence, not exploitable)
Warning the user of a potentially futile run
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 10
Type casting detection (2)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 11
Length constraining detection (1)
Suhosin ( ) - popular open source PHP patch
“...protecting servers and users from known and
unknown flaws in PHP applications and PHP core...”
Constraining the length of request parameter values
(e.g. GET values constrained to less than 512 chars)
Problematic when longer payloads are used (e.g.
injecting of PHP shell through SELECT..INTO
OUTFILE statement)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 12
Length constraining detection (2)
One lengthy payload containing a simple boolean
question (e.g. id=1 AND 3182=...3182) is sent
right after successful identification of SQL injection
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 13
WAF detection/fingeprinting (1)
Web Application Firewall (engl. abbr. WAF)
“...commonly used mechanism for prevention of
malicious web application attacks...”
Modsecurity returns HTTP error code 501 on detected
attack
F5 BIG-IP adds its own X-Cnection HTTP header to
the response
Generic detection (switch --check-waf)
Fingeprinting 28 different WAF products (switch
--identify-waf)
Sending deliberately suspicious payloads and
checking response(s) for unique characteristics
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 14
WAF detection/fingeprinting (2)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 15
False positive detection (1)
“...term used for describing a result that indicates
that a given condition is present when it is not...”
Another way of saying “mistake”
Giving false sense of certainty while in reality there is
nothing exploitable at the other side
Especially noticeable in boolean-based blind and time-
based blind cases
Simple tests are being done after the detection phase
Inspecting responses to predetermined boolean
operations (e.g. id=1 AND 95>27)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 16
False positive detection (2)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 17
Delay detection (1)
Network latency (or lagging) is the main problem of
time-based blind technique
For example, used deliberate delay is 1 sec, normal
response times are >0.5 and <2.0 secs, what we can
conclude for 1.5 sec response?
Also, how to recognize delays in hard-queries (e.g.
BENCHMARK(5000000,MD5('foobar')))?
Mathematical statistics to the rescue
Gaussian bell-shaped curve for the normal distribution
is being calculated
Everything inside is considered as “normal”, outside
as “not normal”
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 18
Delay detection (2)
Everything that's normal (i.e. not deliberately
delayed) should fit under the curve
μ(t) represents a mean, while σ(t) represents a
standard deviation of response times
99.99% of normal response times fall under the
upper border value μ(t) + 7σ(t)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 19
Delay detection (3)
sqlmap learns what's normal and what's not from
non-delay based payload responses (e.g. boolean-
based blind)
Also, few dummy requests are done if there is a need
for more
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 20
Delay detection (4)
In case of considerable network latency user is
warned to use as high delay value as possible
On the other hand, if negligible, sqlmap optimizes the
delay value (if applicable) to a more appropriate one
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 21
Finding number of query fields (1)
For successful usage of UNION-based technique,
number of fields has to be known
Foremost method used is ORDER BY clause
If response for an arbitrary large value (e.g. id=1
ORDER BY 9664#) drastically differs from neutral
(e.g. id=1 ORDER BY 1#)
sqlmap uses adapted (chunked) binary search
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 22
Finding number of query fields (2)
If ORDER BY method is not usable, similar approach
is used as in delay detection
Constant field value (e.g. NULL) used across a
(current chunk of) search space in UNION ALL
SELECT statement
Searching for the number of fields that, compared to
the original response, “sticks out” out of others in a
statistical manner
Responses for non-valid number of fields will not
much differ from each other
Response for the right number of fields will appear
not normal compared to others
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 23
Finding number of query fields (3)
FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 24
Questions?

More Related Content

What's hot

Sql Injection 0wning Enterprise
Sql Injection 0wning EnterpriseSql Injection 0wning Enterprise
Sql Injection 0wning Enterprise
n|u - The Open Security Community
 
Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)
Bernardo Damele A. G.
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
Bernardo Damele A. G.
 
SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)
Bernardo Damele A. G.
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmap
Herman Duarte
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionNeat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
Mikhail Egorov
 
Expanding the control over the operating system from the database
Expanding the control over the operating system from the databaseExpanding the control over the operating system from the database
Expanding the control over the operating system from the database
Bernardo Damele A. G.
 
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
Marco Balduzzi
 
Time based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webserviceTime based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webservice
Frans Rosén
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
Yurii Bilyk
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
SQL injection prevention techniques
SQL injection prevention techniquesSQL injection prevention techniques
SQL injection prevention techniques
SongchaiDuangpan
 
Command injection
Command injectionCommand injection
Command injection
penetration Tester
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
Rodolfo Assis (Brute)
 
Advanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection ProtectionAdvanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection Protection
amiable_indian
 
XXE - XML External Entity Attack
XXE - XML External Entity Attack	XXE - XML External Entity Attack
XXE - XML External Entity Attack
Cysinfo Cyber Security Community
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug ClassJava Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug Class
CODE WHITE GmbH
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
Blueinfy Solutions
 
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
Mikhail Egorov
 

What's hot (20)

Sql Injection 0wning Enterprise
Sql Injection 0wning EnterpriseSql Injection 0wning Enterprise
Sql Injection 0wning Enterprise
 
Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)Advanced SQL injection to operating system full control (whitepaper)
Advanced SQL injection to operating system full control (whitepaper)
 
Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)Advanced SQL injection to operating system full control (slides)
Advanced SQL injection to operating system full control (slides)
 
SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)SQL injection: Not Only AND 1=1 (updated)
SQL injection: Not Only AND 1=1 (updated)
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmap
 
Neat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protectionNeat tricks to bypass CSRF-protection
Neat tricks to bypass CSRF-protection
 
Expanding the control over the operating system from the database
Expanding the control over the operating system from the databaseExpanding the control over the operating system from the database
Expanding the control over the operating system from the database
 
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
HTTP Parameter Pollution Vulnerabilities in Web Applications (Black Hat EU 2011)
 
Time based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webserviceTime based CAPTCHA protected SQL injection through SOAP-webservice
Time based CAPTCHA protected SQL injection through SOAP-webservice
 
XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
Sql injection
Sql injectionSql injection
Sql injection
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
 
SQL injection prevention techniques
SQL injection prevention techniquesSQL injection prevention techniques
SQL injection prevention techniques
 
Command injection
Command injectionCommand injection
Command injection
 
Building Advanced XSS Vectors
Building Advanced XSS VectorsBuilding Advanced XSS Vectors
Building Advanced XSS Vectors
 
Advanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection ProtectionAdvanced Topics On Sql Injection Protection
Advanced Topics On Sql Injection Protection
 
XXE - XML External Entity Attack
XXE - XML External Entity Attack	XXE - XML External Entity Attack
XXE - XML External Entity Attack
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug ClassJava Deserialization Vulnerabilities - The Forgotten Bug Class
Java Deserialization Vulnerabilities - The Forgotten Bug Class
 
XSS - Attacks & Defense
XSS - Attacks & DefenseXSS - Attacks & Defense
XSS - Attacks & Defense
 
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
What’s wrong with WebSocket APIs? Unveiling vulnerabilities in WebSocket APIs.
 

Viewers also liked

2014 – Year of Broken Name Generator(s)
2014 – Year of Broken Name Generator(s)2014 – Year of Broken Name Generator(s)
2014 – Year of Broken Name Generator(s)
Miroslav Stampar
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and NowRiding the Overflow - Then and Now
Riding the Overflow - Then and Now
Miroslav Stampar
 
Curious Case of SQLi
Curious Case of SQLiCurious Case of SQLi
Curious Case of SQLi
Miroslav Stampar
 
Hash DoS Attack
Hash DoS AttackHash DoS Attack
Hash DoS Attack
Miroslav Stampar
 
Smashing the Buffer
Smashing the BufferSmashing the Buffer
Smashing the Buffer
Miroslav Stampar
 
Analysis of mass SQL injection attacks
Analysis of mass SQL injection attacksAnalysis of mass SQL injection attacks
Analysis of mass SQL injection attacks
Miroslav Stampar
 
Spot the Web Vulnerability
Spot the Web VulnerabilitySpot the Web Vulnerability
Spot the Web Vulnerability
Miroslav Stampar
 
Methods and strategies of teaching by Jerrin Issac
Methods and strategies of teaching  by Jerrin IssacMethods and strategies of teaching  by Jerrin Issac
Methods and strategies of teaching by Jerrin IssacSchool of eduction, PU
 
7 Ways to Stay 7 Years Ahead of the Threat
7 Ways to Stay 7 Years Ahead of the Threat7 Ways to Stay 7 Years Ahead of the Threat
7 Ways to Stay 7 Years Ahead of the Threat
IBM Security
 
Balancing the line by using heuristic method based on cpm in salbp –a case study
Balancing the line by using heuristic method based on cpm in salbp –a case studyBalancing the line by using heuristic method based on cpm in salbp –a case study
Balancing the line by using heuristic method based on cpm in salbp –a case study
eSAT Journals
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and NowRiding the Overflow - Then and Now
Riding the Overflow - Then and Now
Miroslav Stampar
 
Advance algebra
Advance algebraAdvance algebra
Advance algebra
lyra matalubos
 
SQLMAP Tool Usage - A Heads Up
SQLMAP Tool Usage - A  Heads UpSQLMAP Tool Usage - A  Heads Up
SQLMAP Tool Usage - A Heads Up
Mindfire Solutions
 
Michael Bolton - Heuristics: Solving Problems Rapidly
Michael Bolton - Heuristics: Solving Problems RapidlyMichael Bolton - Heuristics: Solving Problems Rapidly
Michael Bolton - Heuristics: Solving Problems Rapidly
TEST Huddle
 
Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013
Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013
Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013Laila Mustafa
 
A R E
A R EA R E
A R E
Yan Aquino
 
redBorder: Open or die
redBorder: Open or dieredBorder: Open or die
redBorder: Open or die
Nextel S.A.
 
Administracion de sistemas
Administracion de sistemasAdministracion de sistemas
Administracion de sistemaskitty-katita
 
Bilgi Teknolojilerinin Temel Kavramları 1
Bilgi Teknolojilerinin Temel Kavramları 1Bilgi Teknolojilerinin Temel Kavramları 1
Bilgi Teknolojilerinin Temel Kavramları 1
Zekai Uçan
 
Konvensyen doktor muda daerah seremban
Konvensyen doktor muda daerah serembanKonvensyen doktor muda daerah seremban
Konvensyen doktor muda daerah serembanLaila Mustafa
 

Viewers also liked (20)

2014 – Year of Broken Name Generator(s)
2014 – Year of Broken Name Generator(s)2014 – Year of Broken Name Generator(s)
2014 – Year of Broken Name Generator(s)
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and NowRiding the Overflow - Then and Now
Riding the Overflow - Then and Now
 
Curious Case of SQLi
Curious Case of SQLiCurious Case of SQLi
Curious Case of SQLi
 
Hash DoS Attack
Hash DoS AttackHash DoS Attack
Hash DoS Attack
 
Smashing the Buffer
Smashing the BufferSmashing the Buffer
Smashing the Buffer
 
Analysis of mass SQL injection attacks
Analysis of mass SQL injection attacksAnalysis of mass SQL injection attacks
Analysis of mass SQL injection attacks
 
Spot the Web Vulnerability
Spot the Web VulnerabilitySpot the Web Vulnerability
Spot the Web Vulnerability
 
Methods and strategies of teaching by Jerrin Issac
Methods and strategies of teaching  by Jerrin IssacMethods and strategies of teaching  by Jerrin Issac
Methods and strategies of teaching by Jerrin Issac
 
7 Ways to Stay 7 Years Ahead of the Threat
7 Ways to Stay 7 Years Ahead of the Threat7 Ways to Stay 7 Years Ahead of the Threat
7 Ways to Stay 7 Years Ahead of the Threat
 
Balancing the line by using heuristic method based on cpm in salbp –a case study
Balancing the line by using heuristic method based on cpm in salbp –a case studyBalancing the line by using heuristic method based on cpm in salbp –a case study
Balancing the line by using heuristic method based on cpm in salbp –a case study
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and NowRiding the Overflow - Then and Now
Riding the Overflow - Then and Now
 
Advance algebra
Advance algebraAdvance algebra
Advance algebra
 
SQLMAP Tool Usage - A Heads Up
SQLMAP Tool Usage - A  Heads UpSQLMAP Tool Usage - A  Heads Up
SQLMAP Tool Usage - A Heads Up
 
Michael Bolton - Heuristics: Solving Problems Rapidly
Michael Bolton - Heuristics: Solving Problems RapidlyMichael Bolton - Heuristics: Solving Problems Rapidly
Michael Bolton - Heuristics: Solving Problems Rapidly
 
Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013
Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013
Majlis pelantikan pengawas pss Sk Kompleks KLIA Sesi 2013
 
A R E
A R EA R E
A R E
 
redBorder: Open or die
redBorder: Open or dieredBorder: Open or die
redBorder: Open or die
 
Administracion de sistemas
Administracion de sistemasAdministracion de sistemas
Administracion de sistemas
 
Bilgi Teknolojilerinin Temel Kavramları 1
Bilgi Teknolojilerinin Temel Kavramları 1Bilgi Teknolojilerinin Temel Kavramları 1
Bilgi Teknolojilerinin Temel Kavramları 1
 
Konvensyen doktor muda daerah seremban
Konvensyen doktor muda daerah serembanKonvensyen doktor muda daerah seremban
Konvensyen doktor muda daerah seremban
 

More from Miroslav Stampar

sqlmap - "One Tiny Step At a Time"
sqlmap - "One Tiny Step At a Time"sqlmap - "One Tiny Step At a Time"
sqlmap - "One Tiny Step At a Time"
Miroslav Stampar
 
Blind WAF identification
Blind WAF identificationBlind WAF identification
Blind WAF identification
Miroslav Stampar
 
sqlmap internals
sqlmap internalssqlmap internals
sqlmap internals
Miroslav Stampar
 
Why everybody should do CTF / Wargames?
Why everybody should do CTF / Wargames?Why everybody should do CTF / Wargames?
Why everybody should do CTF / Wargames?
Miroslav Stampar
 
Improving Network Intrusion Detection with Traffic Denoise
Improving Network Intrusion Detection with Traffic DenoiseImproving Network Intrusion Detection with Traffic Denoise
Improving Network Intrusion Detection with Traffic Denoise
Miroslav Stampar
 
APT Attacks on Critical Infrastructure
APT Attacks on Critical InfrastructureAPT Attacks on Critical Infrastructure
APT Attacks on Critical Infrastructure
Miroslav Stampar
 
WARNING: Do Not Feed the Bears
WARNING: Do Not Feed the BearsWARNING: Do Not Feed the Bears
WARNING: Do Not Feed the Bears
Miroslav Stampar
 
Non-Esoteric XSS Tips & Tricks
Non-Esoteric XSS Tips & TricksNon-Esoteric XSS Tips & Tricks
Non-Esoteric XSS Tips & Tricks
Miroslav Stampar
 
Data Retrieval over DNS in SQL Injection Attacks
Data Retrieval over DNS in SQL Injection AttacksData Retrieval over DNS in SQL Injection Attacks
Data Retrieval over DNS in SQL Injection Attacks
Miroslav Stampar
 

More from Miroslav Stampar (9)

sqlmap - "One Tiny Step At a Time"
sqlmap - "One Tiny Step At a Time"sqlmap - "One Tiny Step At a Time"
sqlmap - "One Tiny Step At a Time"
 
Blind WAF identification
Blind WAF identificationBlind WAF identification
Blind WAF identification
 
sqlmap internals
sqlmap internalssqlmap internals
sqlmap internals
 
Why everybody should do CTF / Wargames?
Why everybody should do CTF / Wargames?Why everybody should do CTF / Wargames?
Why everybody should do CTF / Wargames?
 
Improving Network Intrusion Detection with Traffic Denoise
Improving Network Intrusion Detection with Traffic DenoiseImproving Network Intrusion Detection with Traffic Denoise
Improving Network Intrusion Detection with Traffic Denoise
 
APT Attacks on Critical Infrastructure
APT Attacks on Critical InfrastructureAPT Attacks on Critical Infrastructure
APT Attacks on Critical Infrastructure
 
WARNING: Do Not Feed the Bears
WARNING: Do Not Feed the BearsWARNING: Do Not Feed the Bears
WARNING: Do Not Feed the Bears
 
Non-Esoteric XSS Tips & Tricks
Non-Esoteric XSS Tips & TricksNon-Esoteric XSS Tips & Tricks
Non-Esoteric XSS Tips & Tricks
 
Data Retrieval over DNS in SQL Injection Attacks
Data Retrieval over DNS in SQL Injection AttacksData Retrieval over DNS in SQL Injection Attacks
Data Retrieval over DNS in SQL Injection Attacks
 

Recently uploaded

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 

Recently uploaded (20)

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 

Heuristic methods used in sqlmap

  • 1. Heuristic methods used in sqlmap Miroslav Štampar (dev@sqlmap.org) Heuristic methods used in sqlmap Miroslav Štampar (dev@sqlmap.org)
  • 2. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 2 Heuristic method Heuristic (/hjʉˈrɪstɨk/; Greek: “Εὑρίσκω”, “find” or “discover”) Educational shortcuts to ease the cognitive load of making a decision Speeding up the process of finding a satisfactory solution Serve as an aid to learning, discovery and problem solving Experimental and trial-and-error approach Resulting with a solution which is not guaranteed to be optimal
  • 3. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 3 Heuristic SQL injection checks (1) In some cases DBMS error reporting is enabled Deliberately invalid parameter value is sent (e.g. ())'”(''”')  ”SQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version...” Narrowing down tests to only those specific to recognized/parsed DBMS Automatically extending with DBMS specific tests that would be done (only) on higher level Switch --smart for finding targets in minutes
  • 4. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 4 Heuristic SQL injection checks (2)
  • 5. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 5 Heuristic SQL injection checks (3) Particularly interesting cases when parameter contains integer value (e.g. id=1) Response is changing with value changed (e.g. id=2) Response is the same for arithmetic operation resulting in original value (e.g. id=1183-1182) Warning the user that the processed parameter is most probably prone to SQL injection attack(s) Making user aware to persist in eventual further tests (to use higher --level/--risk and/or --tamper)
  • 6. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 6 Heuristic SQL injection checks (4)
  • 7. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 7 Heuristic SQL injection checks (5) In cases when error reporting is turned off At least one generic (i.e. non-DBMS dependent) SQL injection technique is found Single request per supported DBMS is being sent Using form supported by only the targeted one (e.g. id=1 AND (SELECT 0x41597548)=0x41597548) for MySQL) If getting response as expected, narrowing and/or expanding tests for particular DBMS
  • 8. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 8 Heuristic SQL injection checks (6)
  • 9. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 9 Type casting detection (1) In some cases (preventive) hard type casting (e.g. $id=intval($_REQUEST['id'])) is used Especially noticeable on integer parameter values (e.g. id=1) Different responses for different integer values (e.g. id=2) Same response for appended random string values (e.g. id=1vHxr) High probability that the type casting is being used (hence, not exploitable) Warning the user of a potentially futile run
  • 10. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 10 Type casting detection (2)
  • 11. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 11 Length constraining detection (1) Suhosin ( ) - popular open source PHP patch “...protecting servers and users from known and unknown flaws in PHP applications and PHP core...” Constraining the length of request parameter values (e.g. GET values constrained to less than 512 chars) Problematic when longer payloads are used (e.g. injecting of PHP shell through SELECT..INTO OUTFILE statement)
  • 12. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 12 Length constraining detection (2) One lengthy payload containing a simple boolean question (e.g. id=1 AND 3182=...3182) is sent right after successful identification of SQL injection
  • 13. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 13 WAF detection/fingeprinting (1) Web Application Firewall (engl. abbr. WAF) “...commonly used mechanism for prevention of malicious web application attacks...” Modsecurity returns HTTP error code 501 on detected attack F5 BIG-IP adds its own X-Cnection HTTP header to the response Generic detection (switch --check-waf) Fingeprinting 28 different WAF products (switch --identify-waf) Sending deliberately suspicious payloads and checking response(s) for unique characteristics
  • 14. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 14 WAF detection/fingeprinting (2)
  • 15. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 15 False positive detection (1) “...term used for describing a result that indicates that a given condition is present when it is not...” Another way of saying “mistake” Giving false sense of certainty while in reality there is nothing exploitable at the other side Especially noticeable in boolean-based blind and time- based blind cases Simple tests are being done after the detection phase Inspecting responses to predetermined boolean operations (e.g. id=1 AND 95>27)
  • 16. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 16 False positive detection (2)
  • 17. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 17 Delay detection (1) Network latency (or lagging) is the main problem of time-based blind technique For example, used deliberate delay is 1 sec, normal response times are >0.5 and <2.0 secs, what we can conclude for 1.5 sec response? Also, how to recognize delays in hard-queries (e.g. BENCHMARK(5000000,MD5('foobar')))? Mathematical statistics to the rescue Gaussian bell-shaped curve for the normal distribution is being calculated Everything inside is considered as “normal”, outside as “not normal”
  • 18. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 18 Delay detection (2) Everything that's normal (i.e. not deliberately delayed) should fit under the curve μ(t) represents a mean, while σ(t) represents a standard deviation of response times 99.99% of normal response times fall under the upper border value μ(t) + 7σ(t)
  • 19. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 19 Delay detection (3) sqlmap learns what's normal and what's not from non-delay based payload responses (e.g. boolean- based blind) Also, few dummy requests are done if there is a need for more
  • 20. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 20 Delay detection (4) In case of considerable network latency user is warned to use as high delay value as possible On the other hand, if negligible, sqlmap optimizes the delay value (if applicable) to a more appropriate one
  • 21. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 21 Finding number of query fields (1) For successful usage of UNION-based technique, number of fields has to be known Foremost method used is ORDER BY clause If response for an arbitrary large value (e.g. id=1 ORDER BY 9664#) drastically differs from neutral (e.g. id=1 ORDER BY 1#) sqlmap uses adapted (chunked) binary search
  • 22. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 22 Finding number of query fields (2) If ORDER BY method is not usable, similar approach is used as in delay detection Constant field value (e.g. NULL) used across a (current chunk of) search space in UNION ALL SELECT statement Searching for the number of fields that, compared to the original response, “sticks out” out of others in a statistical manner Responses for non-valid number of fields will not much differ from each other Response for the right number of fields will appear not normal compared to others
  • 23. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 23 Finding number of query fields (3)
  • 24. FSec – FOI 2013, Varaždin (Croatia) September 19th, 2013 24 Questions?