SlideShare a Scribd company logo
1 of 36
Download to read offline
sqlmap internalssqlmap internals
Miroslav Štampar
(mstampar@zsis.hr; miroslav@sqlmap.org)
sqlmap internalssqlmap internals
Miroslav Štampar
(mstampar@zsis.hr; miroslav@sqlmap.org)
ISACA, Zagreb (Croatia) April 09th, 2018 2
IntroductionIntroduction
Free and open source penetration testing tool
that automates the process of detecting and
exploiting SQL injection flaws and taking over
of database server(s)
Written in Python (2)
11 years old (July 25th
2006)
2 authors / core developers (Bernardo Damele
and Miroslav Stampar)
65K LoC (Lines of Code)
100% accuracy and 0% false-positives by
WAVSEP benchmark of 64 Web Application
Scanners (sectoolmarket.com)
ISACA, Zagreb (Croatia) April 09th, 2018 3
CapabilitiesCapabilities
78 switches (e.g. --tor) and 91 options (e.g.
--url=”...”) in 15 categories (Target,
Request, Optimization, Injection, etc.)
Full coverage for (relational DBMS-es): MySQL,
Oracle, PostgreSQL, Microsoft SQL Server,
Microsoft Access, IBM DB2, SQLite, Firebird,
Sybase, SAP MaxDB, HSQLDB and Informix
Full support for SQLi techniques: boolean-
based blind, time-based blind, error-based,
UNION query-based and stacked queries
Database enumeration, file-system
manipulation, out-of-band communication, etc.
ISACA, Zagreb (Croatia) April 09th, 2018 4
Sample runSample run
ISACA, Zagreb (Croatia) April 09th, 2018 5
Socket pre-connect (1)Socket pre-connect (1)
TCP three-way handshake (SYN, SYN-ACK,
ACK) is inherently slow (“necessary evil”)
Each HTTP request requires a completed
TCP handshake procedure
sqlmap runs a “pre-connect” thread in
background filling a pool of (e.g. 3)
connections with TCP handshake done
Overrides Python’s socket.connect()
25% speed-up of a program’s run on
average
ISACA, Zagreb (Croatia) April 09th, 2018 6
Socket pre-connect (2)Socket pre-connect (2)
ISACA, Zagreb (Croatia) April 09th, 2018 7
NULL connection (1)NULL connection (1)
In boolean-based blind SQLi response sizes
should suffice (e.g. >1000 bytes → TRUE)
“NULL” naming because of skipping the
retrieval of complete HTTP response
Range: bytes=-1
Content-Range: bytes 4789-4789/4790
HEAD /search.aspx HTTP/1.1
Content-Length: 4790
Both are resulting (if applicable) with empty
HTTP body (faster retrieval of responses)
By looking into “length” headers we can
differentiate TRUE from FALSE answers
ISACA, Zagreb (Croatia) April 09th, 2018 8
NULL connection (2)NULL connection (2)
ISACA, Zagreb (Croatia) April 09th, 2018 9
HashDB (1)HashDB (1)
Storage of resumable session data at
centralized place (local SQLite3 database)
Non-string values are being automatically
serialized/deserialized (pickle)
INSERT INTO storage VALUES
(INT(MD5(target_url, uid, MILESTONE_SALT)
[:8]), stored_value)
uid uniquely describes stored_value for a
given target_url (e.g.: KB_INJECTIONS, SELECT
VERSION(), etc.)
MILESTONE_SALT changed whenever there is an
incompatible update of HashDB mechanism
ISACA, Zagreb (Croatia) April 09th, 2018 10
HashDB (2)HashDB (2)
ISACA, Zagreb (Croatia) April 09th, 2018 11
BigArray (1)BigArray (1)
Support for huge table dumps (e.g. millions of
rows)
Raw data needs to be held somewhere before
being processed (and eventually stored)
In memory storage was a good enough choice
until user appetites went bigger (!)
Memory mapping into smaller chunks (1MB) –
memory pages
Temporary files store (compressed) chunks
In-memory caching of currently used chunk
O(1) read/write access
ISACA, Zagreb (Croatia) April 09th, 2018 12
BigArray (2)BigArray (2)
ISACA, Zagreb (Croatia) April 09th, 2018 13
Heuristics (1)Heuristics (1)
“Educational shortcuts to ease the cognitive
load of making a decision”
Resulting with a solution which is not
guaranteed to be optimal (though very helpful)
Type casting (e.g. ?id=1foobar)
DBMS error reporting (e.g. ?id=1())'”(”')
Character filtering (e.g. ?id=1 AND 7=(7))
Length constraining (e.g. id=1 AND 3182=
3182)
(quick) DBMS detection (e.g. ?id=1 AND
(SELECT 0x73716c)=0x73716c)
ISACA, Zagreb (Croatia) April 09th, 2018 14
Heuristics (2)Heuristics (2)
ISACA, Zagreb (Croatia) April 09th, 2018 15
Boolean inference (1)Boolean inference (1)
Binary search using greater-than operator
O(Log2n) complexity compared to sequential
search with O(n)
Faster than bit-by-bit extraction (on average 6
requests compared to 8 requests)
For example:
Sample initial table ['A','B',...'Z']
AND (...) > 'M' → TRUE → ['N',...'Z']
AND (...) > 'S' → FALSE → ['N',...'S']
AND (...) > 'O' → TRUE → ['P', 'R', 'S']
AND (...) > 'R' → FALSE → ['P', 'R']
AND (...) > 'P' → FALSE → 'P' (result)
ISACA, Zagreb (Croatia) April 09th, 2018 16
Boolean inference (2)Boolean inference (2)
ISACA, Zagreb (Croatia) April 09th, 2018 17
Boundaries / levels / risks (1)Boundaries / levels / risks (1)
SQLi detection requires working payload
(e.g. AND 1=1) together with proper
boundaries (e.g. ?query=test’ AND 1=1
AND ‘x’=’x)
Number of tested prefix/suffix boundaries is
constrained with option --level (e.g.
“)))))
Number of tested payloads is constrained
with option --risk (e.g. OR 1=1)
Greater the level and risk, greater the
number of testing cases
ISACA, Zagreb (Croatia) April 09th, 2018 18
Boundaries / levels / risks (2)Boundaries / levels / risks (2)
ISACA, Zagreb (Croatia) April 09th, 2018 19
Statistics (1)Statistics (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?
sqlmap learns what's “normal” and what's not
from non-delay based payload responses (e.g.
boolean-based blind payloads)
Normal distribution is being calculated
(Gaussian bell-shaped curve)
Everything inside is considered as “normal”,
outside as “not normal”
ISACA, Zagreb (Croatia) April 09th, 2018 20
Statistics (2)Statistics (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)
ISACA, Zagreb (Croatia) April 09th, 2018 21
False-positive detection (1)False-positive detection (1)
Detection of “error” in SQLi detection engine
Giving false sense of certainty while in reality
there is nothing exploitable at the other side
Almost exclusive to boolean-based blind and
time-based blind cases
Simple tests are being done after the detection
Comparing responses to boolean operations
with expected results (e.g. id=1 AND 95=27)
If any of results is contrary to the expected
value, SQLi is discarded as a false-positive (or
unexploitable)
ISACA, Zagreb (Croatia) April 09th, 2018 22
False-positive detection (2)False-positive detection (2)
ISACA, Zagreb (Croatia) April 09th, 2018 23
WAF/IDS/IPS detection (1)WAF/IDS/IPS detection (1)
Sending deliberately suspicious payloads and
checking response(s) for unique characteristics
(e.g.) ?id=1&bwXY=5253 AND 1=1 UNION ALL
SELECT 1,NULL,'<script>alert("XSS")
</script>',table_name FROM
information_schema.tables WHERE
2>1--/**/; EXEC xp_cmdshell('cat ../../
../etc/passwd')#
ModSecurity returns HTTP error code 501 on
detected attack, F5 BIG-IP adds its own X-
Cnection HTTP header, etc.
Fingeprinting 63 different WAF/IDS/IPS products
ISACA, Zagreb (Croatia) April 09th, 2018 24
WAF/IDS/IPS detection (2)WAF/IDS/IPS detection (2)
ISACA, Zagreb (Croatia) April 09th, 2018 25
Tamper scripts (1)Tamper scripts (1)
Auxiliary python scripts modifying the payload
before being sent (e.g. ?id=1 AND 2>1 to
?id=1 AND 2 NOT BETWEEN 0 AND 1)
Currently 56 tamper scripts (between.py,
space2randomblank.py, versionedkeywords.py,
etc.)
User has to choose appropriate script(s) based
on collected knowledge of target's behavior
and/or detected WAF/IDS/IPS product
Chain of tamper scripts (if required) can be
used (e.g. --tamper=”between,
ifnull2ifisnull”)
ISACA, Zagreb (Croatia) April 09th, 2018 26
Tamper scripts (2)Tamper scripts (2)
ISACA, Zagreb (Croatia) April 09th, 2018 27
Brute-forcing identifiers (1)Brute-forcing identifiers (1)
In some cases system tables are unreadable
(e.g. because of lack of permissions)
Hence, no way to retrieve identifier names
(tables and columns)
sqlmap does guessing by brute-forcing
availability of most common identifiers (e.g.
?id=1 AND EXISTS(SELECT 123 FROM users))
Identifiers (3369 table and 2601 column
names) have been collected and frequency-
sorted by retrieving and parsing thousands
of online SQL scripts
ISACA, Zagreb (Croatia) April 09th, 2018 28
Brute-forcing identifiers (2)Brute-forcing identifiers (2)
ISACA, Zagreb (Croatia) April 09th, 2018 29
Hash cracking (1)Hash cracking (1)
Automatic recognition and dictionary
cracking of 30 different hash algorithms
(e.g. mysql, mssql, md5_generic,
sha1_generic, etc.)
Included dictionary with 1.4 million wordlist
entries (RockYou, MySpace, Gawker, etc.)
Multiprocessing (# of cores)
Blazing fast (e.g. under 10 seconds for
whole dictionary pass with mysql routine)
Stores uncracked hashes to file for eventual
further processing (with other tools)
ISACA, Zagreb (Croatia) April 09th, 2018 30
Hash cracking (2)Hash cracking (2)
ISACA, Zagreb (Croatia) April 09th, 2018 31
Stagers / backdoors (1)Stagers / backdoors (1)
Stager uploaded in a first (dirty) stage (e.g.
possibility of a query junk in case of INTO
OUTFILE method)
Stager has a functionality of uploading
arbitrary files
Backdoor (or any binary) uploaded in second
(clean) stage by using stager
Backdoor has a functionality of executing
arbitrary OS commands
Supported platforms: PHP, ASP, ASPX, JSP
ISACA, Zagreb (Croatia) April 09th, 2018 32
Stagers / backdoors (2)Stagers / backdoors (2)
ISACA, Zagreb (Croatia) April 09th, 2018 33
DNS exfiltration (1)DNS exfiltration (1)
In some cases it's possible to incorporate
SQL (sub)query results into DNS resolution
requests
Microsoft SQL Server, Oracle, MySQL and
PostgreSQL
Dozens of resulting characters can be
transferred per single request (compared to
boolean-based blind and time-based blind)
Domain name server entry (e.g.
ns1.attacker.com) has to point to IP
address of machine running sqlmap
ISACA, Zagreb (Croatia) April 09th, 2018 34
DNS exfiltration (2)DNS exfiltration (2)
ISACA, Zagreb (Croatia) April 09th, 2018 35
DNS exfiltration (3)DNS exfiltration (3)
ISACA, Zagreb (Croatia) April 09th, 2018 36
Questions?Questions?

More Related Content

What's hot

Ontologies Ontop Databases
Ontologies Ontop DatabasesOntologies Ontop Databases
Ontologies Ontop DatabasesMartín Rezk
 
Do WAFs dream of static analyzers
Do WAFs dream of static analyzersDo WAFs dream of static analyzers
Do WAFs dream of static analyzersVladimir Kochetkov
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring DataArturs Drozdovs
 
Ontop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational DatabasesOntop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational DatabasesGuohui Xiao
 
IO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingIO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingGurpreet singh
 
The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)Vyacheslav Lapin
 
Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpaStaples
 
Devoxx08 - Nuxeo Core, JCR 2, CMIS
Devoxx08 - Nuxeo Core, JCR 2, CMIS Devoxx08 - Nuxeo Core, JCR 2, CMIS
Devoxx08 - Nuxeo Core, JCR 2, CMIS Nuxeo
 
ShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)SqlShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)SqlChema Alonso
 
MongoDB and Indexes - MUG Denver - 20160329
MongoDB and Indexes - MUG Denver - 20160329MongoDB and Indexes - MUG Denver - 20160329
MongoDB and Indexes - MUG Denver - 20160329Douglas Duncan
 
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Dave Stokes
 
An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring DataOliver Gierke
 
Unethical access to website’s databases hacking using sql injection
Unethical access to website’s databases hacking using sql injectionUnethical access to website’s databases hacking using sql injection
Unethical access to website’s databases hacking using sql injectionSatyajit Mukherjee
 

What's hot (20)

Ontologies Ontop Databases
Ontologies Ontop DatabasesOntologies Ontop Databases
Ontologies Ontop Databases
 
SQL injection: Not only AND 1=1
SQL injection: Not only AND 1=1SQL injection: Not only AND 1=1
SQL injection: Not only AND 1=1
 
Do WAFs dream of static analyzers
Do WAFs dream of static analyzersDo WAFs dream of static analyzers
Do WAFs dream of static analyzers
 
JDBC - JPA - Spring Data
JDBC - JPA - Spring DataJDBC - JPA - Spring Data
JDBC - JPA - Spring Data
 
Ontop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational DatabasesOntop: Answering SPARQL Queries over Relational Databases
Ontop: Answering SPARQL Queries over Relational Databases
 
IO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingIO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxing
 
The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)The art of messaging tune (Joker 2015 edition)
The art of messaging tune (Joker 2015 edition)
 
Java 7 & 8 New Features
Java 7 & 8 New FeaturesJava 7 & 8 New Features
Java 7 & 8 New Features
 
Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Devoxx08 - Nuxeo Core, JCR 2, CMIS
Devoxx08 - Nuxeo Core, JCR 2, CMIS Devoxx08 - Nuxeo Core, JCR 2, CMIS
Devoxx08 - Nuxeo Core, JCR 2, CMIS
 
ShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)SqlShmooCon 2009 - (Re)Playing(Blind)Sql
ShmooCon 2009 - (Re)Playing(Blind)Sql
 
JAXP
JAXPJAXP
JAXP
 
Java
JavaJava
Java
 
MongoDB and Indexes - MUG Denver - 20160329
MongoDB and Indexes - MUG Denver - 20160329MongoDB and Indexes - MUG Denver - 20160329
MongoDB and Indexes - MUG Denver - 20160329
 
55j7
55j755j7
55j7
 
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
Longhorn PHP - MySQL Indexes, Histograms, Locking Options, and Other Ways to ...
 
Blockchain - a simple implementation
Blockchain - a simple implementationBlockchain - a simple implementation
Blockchain - a simple implementation
 
An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring Data
 
Unethical access to website’s databases hacking using sql injection
Unethical access to website’s databases hacking using sql injectionUnethical access to website’s databases hacking using sql injection
Unethical access to website’s databases hacking using sql injection
 

Similar to sqlmap internals

How "·$% developers defeat the web vulnerability scanners
How "·$% developers defeat the web vulnerability scannersHow "·$% developers defeat the web vulnerability scanners
How "·$% developers defeat the web vulnerability scannersChema Alonso
 
ElasticSearch.pptx
ElasticSearch.pptxElasticSearch.pptx
ElasticSearch.pptxTrnHiu748002
 
Datastax day 2016 : Cassandra data modeling basics
Datastax day 2016 : Cassandra data modeling basicsDatastax day 2016 : Cassandra data modeling basics
Datastax day 2016 : Cassandra data modeling basicsDuyhai Doan
 
Artem Storozhuk "Building SQL firewall: insights from developers"
Artem Storozhuk "Building SQL firewall: insights from developers"Artem Storozhuk "Building SQL firewall: insights from developers"
Artem Storozhuk "Building SQL firewall: insights from developers"Fwdays
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management Systempsathishcs
 
SQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail Science
SQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail ScienceSQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail Science
SQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail ScienceUniversity of Washington
 
Miroslav Stampar. Sqlmap — Under the Hood.
Miroslav Stampar. Sqlmap — Under the Hood.Miroslav Stampar. Sqlmap — Under the Hood.
Miroslav Stampar. Sqlmap — Under the Hood.Positive Hack Days
 
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hoodPh days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hoodPositive Hack Days
 
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hoodPh days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hoodPositive Hack Days
 
خطة البحث أمنية سعيد رشدى السيد2014 تعديل اخي
خطة البحث أمنية سعيد رشدى السيد2014 تعديل اخيخطة البحث أمنية سعيد رشدى السيد2014 تعديل اخي
خطة البحث أمنية سعيد رشدى السيد2014 تعديل اخيامنية رشدي
 
RasterFrames + STAC
RasterFrames + STACRasterFrames + STAC
RasterFrames + STACSimeon Fitch
 
Advanced Sql Injection ENG
Advanced Sql Injection ENGAdvanced Sql Injection ENG
Advanced Sql Injection ENGDmitry Evteev
 
Sql injection
Sql injectionSql injection
Sql injectionBee_Ware
 
Using Elasticsearch as the Primary Data Store
Using Elasticsearch as the Primary Data StoreUsing Elasticsearch as the Primary Data Store
Using Elasticsearch as the Primary Data StoreVolkan Yazıcı
 
2014.06.24.what is ubix
2014.06.24.what is ubix2014.06.24.what is ubix
2014.06.24.what is ubixJim Cooley
 
Asegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File DownloadingAsegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File DownloadingChema Alonso
 
QUERY INVERSION TO FIND DATA PROVENANCE
QUERY INVERSION TO FIND DATA PROVENANCE QUERY INVERSION TO FIND DATA PROVENANCE
QUERY INVERSION TO FIND DATA PROVENANCE cscpconf
 
Elasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational databaseElasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational databaseKristijan Duvnjak
 

Similar to sqlmap internals (20)

How "·$% developers defeat the web vulnerability scanners
How "·$% developers defeat the web vulnerability scannersHow "·$% developers defeat the web vulnerability scanners
How "·$% developers defeat the web vulnerability scanners
 
ElasticSearch.pptx
ElasticSearch.pptxElasticSearch.pptx
ElasticSearch.pptx
 
Datastax day 2016 : Cassandra data modeling basics
Datastax day 2016 : Cassandra data modeling basicsDatastax day 2016 : Cassandra data modeling basics
Datastax day 2016 : Cassandra data modeling basics
 
Artem Storozhuk "Building SQL firewall: insights from developers"
Artem Storozhuk "Building SQL firewall: insights from developers"Artem Storozhuk "Building SQL firewall: insights from developers"
Artem Storozhuk "Building SQL firewall: insights from developers"
 
Tutorial On Database Management System
Tutorial On Database Management SystemTutorial On Database Management System
Tutorial On Database Management System
 
SQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail Science
SQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail ScienceSQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail Science
SQL is Dead; Long Live SQL: Lightweight Query Services for Long Tail Science
 
Miroslav Stampar. Sqlmap — Under the Hood.
Miroslav Stampar. Sqlmap — Under the Hood.Miroslav Stampar. Sqlmap — Under the Hood.
Miroslav Stampar. Sqlmap — Under the Hood.
 
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hoodPh days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hood
 
sqlmap - Under the Hood
sqlmap - Under the Hoodsqlmap - Under the Hood
sqlmap - Under the Hood
 
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hoodPh days 2013-miroslav-stampar_-_sqlmap_under_the_hood
Ph days 2013-miroslav-stampar_-_sqlmap_under_the_hood
 
خطة البحث أمنية سعيد رشدى السيد2014 تعديل اخي
خطة البحث أمنية سعيد رشدى السيد2014 تعديل اخيخطة البحث أمنية سعيد رشدى السيد2014 تعديل اخي
خطة البحث أمنية سعيد رشدى السيد2014 تعديل اخي
 
RasterFrames + STAC
RasterFrames + STACRasterFrames + STAC
RasterFrames + STAC
 
Advanced Sql Injection ENG
Advanced Sql Injection ENGAdvanced Sql Injection ENG
Advanced Sql Injection ENG
 
Sql injection
Sql injectionSql injection
Sql injection
 
Using Elasticsearch as the Primary Data Store
Using Elasticsearch as the Primary Data StoreUsing Elasticsearch as the Primary Data Store
Using Elasticsearch as the Primary Data Store
 
2014.06.24.what is ubix
2014.06.24.what is ubix2014.06.24.what is ubix
2014.06.24.what is ubix
 
Asegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File DownloadingAsegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File Downloading
 
QUERY INVERSION TO FIND DATA PROVENANCE
QUERY INVERSION TO FIND DATA PROVENANCE QUERY INVERSION TO FIND DATA PROVENANCE
QUERY INVERSION TO FIND DATA PROVENANCE
 
Elasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational databaseElasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational database
 
JavaCro'15 - Elasticsearch as a search alternative to a relational database -...
JavaCro'15 - Elasticsearch as a search alternative to a relational database -...JavaCro'15 - Elasticsearch as a search alternative to a relational database -...
JavaCro'15 - Elasticsearch as a search alternative to a relational database -...
 

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
 
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 DenoiseMiroslav Stampar
 
APT Attacks on Critical Infrastructure
APT Attacks on Critical InfrastructureAPT Attacks on Critical Infrastructure
APT Attacks on Critical InfrastructureMiroslav Stampar
 
WARNING: Do Not Feed the Bears
WARNING: Do Not Feed the BearsWARNING: Do Not Feed the Bears
WARNING: Do Not Feed the BearsMiroslav Stampar
 
Non-Esoteric XSS Tips & Tricks
Non-Esoteric XSS Tips & TricksNon-Esoteric XSS Tips & Tricks
Non-Esoteric XSS Tips & TricksMiroslav Stampar
 
sqlmap - why (not how) it works?
sqlmap - why (not how) it works?sqlmap - why (not how) it works?
sqlmap - why (not how) it works?Miroslav Stampar
 
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 NowMiroslav Stampar
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and NowRiding the Overflow - Then and Now
Riding the Overflow - Then and NowMiroslav Stampar
 
Spot the Web Vulnerability
Spot the Web VulnerabilitySpot the Web Vulnerability
Spot the Web VulnerabilityMiroslav 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 AttacksMiroslav Stampar
 
It all starts with the ' (SQL injection from attacker's point of view)
It all starts with the ' (SQL injection from attacker's point of view)It all starts with the ' (SQL injection from attacker's point of view)
It all starts with the ' (SQL injection from attacker's point of view)Miroslav Stampar
 

More from Miroslav Stampar (15)

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
 
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
 
sqlmap - why (not how) it works?
sqlmap - why (not how) it works?sqlmap - why (not how) it works?
sqlmap - why (not how) it works?
 
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)
 
Smashing the Buffer
Smashing the BufferSmashing the Buffer
Smashing the Buffer
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and NowRiding the Overflow - Then and Now
Riding the Overflow - Then and Now
 
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
 
Spot the Web Vulnerability
Spot the Web VulnerabilitySpot the Web Vulnerability
Spot the Web Vulnerability
 
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
 
It all starts with the ' (SQL injection from attacker's point of view)
It all starts with the ' (SQL injection from attacker's point of view)It all starts with the ' (SQL injection from attacker's point of view)
It all starts with the ' (SQL injection from attacker's point of view)
 

Recently uploaded

Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Roomdivyansh0kumar0
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Roomdivyansh0kumar0
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Roomdivyansh0kumar0
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 

Recently uploaded (20)

Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With RoomVIP Kolkata Call Girl Dum Dum 👉 8250192130  Available With Room
VIP Kolkata Call Girl Dum Dum 👉 8250192130 Available With Room
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130  Available With RoomVIP Kolkata Call Girl Alambazar 👉 8250192130  Available With Room
VIP Kolkata Call Girl Alambazar 👉 8250192130 Available With Room
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130  Available With RoomVIP Kolkata Call Girl Kestopur 👉 8250192130  Available With Room
VIP Kolkata Call Girl Kestopur 👉 8250192130 Available With Room
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 

sqlmap internals

  • 1. sqlmap internalssqlmap internals Miroslav Štampar (mstampar@zsis.hr; miroslav@sqlmap.org) sqlmap internalssqlmap internals Miroslav Štampar (mstampar@zsis.hr; miroslav@sqlmap.org)
  • 2. ISACA, Zagreb (Croatia) April 09th, 2018 2 IntroductionIntroduction Free and open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database server(s) Written in Python (2) 11 years old (July 25th 2006) 2 authors / core developers (Bernardo Damele and Miroslav Stampar) 65K LoC (Lines of Code) 100% accuracy and 0% false-positives by WAVSEP benchmark of 64 Web Application Scanners (sectoolmarket.com)
  • 3. ISACA, Zagreb (Croatia) April 09th, 2018 3 CapabilitiesCapabilities 78 switches (e.g. --tor) and 91 options (e.g. --url=”...”) in 15 categories (Target, Request, Optimization, Injection, etc.) Full coverage for (relational DBMS-es): MySQL, Oracle, PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite, Firebird, Sybase, SAP MaxDB, HSQLDB and Informix Full support for SQLi techniques: boolean- based blind, time-based blind, error-based, UNION query-based and stacked queries Database enumeration, file-system manipulation, out-of-band communication, etc.
  • 4. ISACA, Zagreb (Croatia) April 09th, 2018 4 Sample runSample run
  • 5. ISACA, Zagreb (Croatia) April 09th, 2018 5 Socket pre-connect (1)Socket pre-connect (1) TCP three-way handshake (SYN, SYN-ACK, ACK) is inherently slow (“necessary evil”) Each HTTP request requires a completed TCP handshake procedure sqlmap runs a “pre-connect” thread in background filling a pool of (e.g. 3) connections with TCP handshake done Overrides Python’s socket.connect() 25% speed-up of a program’s run on average
  • 6. ISACA, Zagreb (Croatia) April 09th, 2018 6 Socket pre-connect (2)Socket pre-connect (2)
  • 7. ISACA, Zagreb (Croatia) April 09th, 2018 7 NULL connection (1)NULL connection (1) In boolean-based blind SQLi response sizes should suffice (e.g. >1000 bytes → TRUE) “NULL” naming because of skipping the retrieval of complete HTTP response Range: bytes=-1 Content-Range: bytes 4789-4789/4790 HEAD /search.aspx HTTP/1.1 Content-Length: 4790 Both are resulting (if applicable) with empty HTTP body (faster retrieval of responses) By looking into “length” headers we can differentiate TRUE from FALSE answers
  • 8. ISACA, Zagreb (Croatia) April 09th, 2018 8 NULL connection (2)NULL connection (2)
  • 9. ISACA, Zagreb (Croatia) April 09th, 2018 9 HashDB (1)HashDB (1) Storage of resumable session data at centralized place (local SQLite3 database) Non-string values are being automatically serialized/deserialized (pickle) INSERT INTO storage VALUES (INT(MD5(target_url, uid, MILESTONE_SALT) [:8]), stored_value) uid uniquely describes stored_value for a given target_url (e.g.: KB_INJECTIONS, SELECT VERSION(), etc.) MILESTONE_SALT changed whenever there is an incompatible update of HashDB mechanism
  • 10. ISACA, Zagreb (Croatia) April 09th, 2018 10 HashDB (2)HashDB (2)
  • 11. ISACA, Zagreb (Croatia) April 09th, 2018 11 BigArray (1)BigArray (1) Support for huge table dumps (e.g. millions of rows) Raw data needs to be held somewhere before being processed (and eventually stored) In memory storage was a good enough choice until user appetites went bigger (!) Memory mapping into smaller chunks (1MB) – memory pages Temporary files store (compressed) chunks In-memory caching of currently used chunk O(1) read/write access
  • 12. ISACA, Zagreb (Croatia) April 09th, 2018 12 BigArray (2)BigArray (2)
  • 13. ISACA, Zagreb (Croatia) April 09th, 2018 13 Heuristics (1)Heuristics (1) “Educational shortcuts to ease the cognitive load of making a decision” Resulting with a solution which is not guaranteed to be optimal (though very helpful) Type casting (e.g. ?id=1foobar) DBMS error reporting (e.g. ?id=1())'”(”') Character filtering (e.g. ?id=1 AND 7=(7)) Length constraining (e.g. id=1 AND 3182= 3182) (quick) DBMS detection (e.g. ?id=1 AND (SELECT 0x73716c)=0x73716c)
  • 14. ISACA, Zagreb (Croatia) April 09th, 2018 14 Heuristics (2)Heuristics (2)
  • 15. ISACA, Zagreb (Croatia) April 09th, 2018 15 Boolean inference (1)Boolean inference (1) Binary search using greater-than operator O(Log2n) complexity compared to sequential search with O(n) Faster than bit-by-bit extraction (on average 6 requests compared to 8 requests) For example: Sample initial table ['A','B',...'Z'] AND (...) > 'M' → TRUE → ['N',...'Z'] AND (...) > 'S' → FALSE → ['N',...'S'] AND (...) > 'O' → TRUE → ['P', 'R', 'S'] AND (...) > 'R' → FALSE → ['P', 'R'] AND (...) > 'P' → FALSE → 'P' (result)
  • 16. ISACA, Zagreb (Croatia) April 09th, 2018 16 Boolean inference (2)Boolean inference (2)
  • 17. ISACA, Zagreb (Croatia) April 09th, 2018 17 Boundaries / levels / risks (1)Boundaries / levels / risks (1) SQLi detection requires working payload (e.g. AND 1=1) together with proper boundaries (e.g. ?query=test’ AND 1=1 AND ‘x’=’x) Number of tested prefix/suffix boundaries is constrained with option --level (e.g. “))))) Number of tested payloads is constrained with option --risk (e.g. OR 1=1) Greater the level and risk, greater the number of testing cases
  • 18. ISACA, Zagreb (Croatia) April 09th, 2018 18 Boundaries / levels / risks (2)Boundaries / levels / risks (2)
  • 19. ISACA, Zagreb (Croatia) April 09th, 2018 19 Statistics (1)Statistics (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? sqlmap learns what's “normal” and what's not from non-delay based payload responses (e.g. boolean-based blind payloads) Normal distribution is being calculated (Gaussian bell-shaped curve) Everything inside is considered as “normal”, outside as “not normal”
  • 20. ISACA, Zagreb (Croatia) April 09th, 2018 20 Statistics (2)Statistics (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)
  • 21. ISACA, Zagreb (Croatia) April 09th, 2018 21 False-positive detection (1)False-positive detection (1) Detection of “error” in SQLi detection engine Giving false sense of certainty while in reality there is nothing exploitable at the other side Almost exclusive to boolean-based blind and time-based blind cases Simple tests are being done after the detection Comparing responses to boolean operations with expected results (e.g. id=1 AND 95=27) If any of results is contrary to the expected value, SQLi is discarded as a false-positive (or unexploitable)
  • 22. ISACA, Zagreb (Croatia) April 09th, 2018 22 False-positive detection (2)False-positive detection (2)
  • 23. ISACA, Zagreb (Croatia) April 09th, 2018 23 WAF/IDS/IPS detection (1)WAF/IDS/IPS detection (1) Sending deliberately suspicious payloads and checking response(s) for unique characteristics (e.g.) ?id=1&bwXY=5253 AND 1=1 UNION ALL SELECT 1,NULL,'<script>alert("XSS") </script>',table_name FROM information_schema.tables WHERE 2>1--/**/; EXEC xp_cmdshell('cat ../../ ../etc/passwd')# ModSecurity returns HTTP error code 501 on detected attack, F5 BIG-IP adds its own X- Cnection HTTP header, etc. Fingeprinting 63 different WAF/IDS/IPS products
  • 24. ISACA, Zagreb (Croatia) April 09th, 2018 24 WAF/IDS/IPS detection (2)WAF/IDS/IPS detection (2)
  • 25. ISACA, Zagreb (Croatia) April 09th, 2018 25 Tamper scripts (1)Tamper scripts (1) Auxiliary python scripts modifying the payload before being sent (e.g. ?id=1 AND 2>1 to ?id=1 AND 2 NOT BETWEEN 0 AND 1) Currently 56 tamper scripts (between.py, space2randomblank.py, versionedkeywords.py, etc.) User has to choose appropriate script(s) based on collected knowledge of target's behavior and/or detected WAF/IDS/IPS product Chain of tamper scripts (if required) can be used (e.g. --tamper=”between, ifnull2ifisnull”)
  • 26. ISACA, Zagreb (Croatia) April 09th, 2018 26 Tamper scripts (2)Tamper scripts (2)
  • 27. ISACA, Zagreb (Croatia) April 09th, 2018 27 Brute-forcing identifiers (1)Brute-forcing identifiers (1) In some cases system tables are unreadable (e.g. because of lack of permissions) Hence, no way to retrieve identifier names (tables and columns) sqlmap does guessing by brute-forcing availability of most common identifiers (e.g. ?id=1 AND EXISTS(SELECT 123 FROM users)) Identifiers (3369 table and 2601 column names) have been collected and frequency- sorted by retrieving and parsing thousands of online SQL scripts
  • 28. ISACA, Zagreb (Croatia) April 09th, 2018 28 Brute-forcing identifiers (2)Brute-forcing identifiers (2)
  • 29. ISACA, Zagreb (Croatia) April 09th, 2018 29 Hash cracking (1)Hash cracking (1) Automatic recognition and dictionary cracking of 30 different hash algorithms (e.g. mysql, mssql, md5_generic, sha1_generic, etc.) Included dictionary with 1.4 million wordlist entries (RockYou, MySpace, Gawker, etc.) Multiprocessing (# of cores) Blazing fast (e.g. under 10 seconds for whole dictionary pass with mysql routine) Stores uncracked hashes to file for eventual further processing (with other tools)
  • 30. ISACA, Zagreb (Croatia) April 09th, 2018 30 Hash cracking (2)Hash cracking (2)
  • 31. ISACA, Zagreb (Croatia) April 09th, 2018 31 Stagers / backdoors (1)Stagers / backdoors (1) Stager uploaded in a first (dirty) stage (e.g. possibility of a query junk in case of INTO OUTFILE method) Stager has a functionality of uploading arbitrary files Backdoor (or any binary) uploaded in second (clean) stage by using stager Backdoor has a functionality of executing arbitrary OS commands Supported platforms: PHP, ASP, ASPX, JSP
  • 32. ISACA, Zagreb (Croatia) April 09th, 2018 32 Stagers / backdoors (2)Stagers / backdoors (2)
  • 33. ISACA, Zagreb (Croatia) April 09th, 2018 33 DNS exfiltration (1)DNS exfiltration (1) In some cases it's possible to incorporate SQL (sub)query results into DNS resolution requests Microsoft SQL Server, Oracle, MySQL and PostgreSQL Dozens of resulting characters can be transferred per single request (compared to boolean-based blind and time-based blind) Domain name server entry (e.g. ns1.attacker.com) has to point to IP address of machine running sqlmap
  • 34. ISACA, Zagreb (Croatia) April 09th, 2018 34 DNS exfiltration (2)DNS exfiltration (2)
  • 35. ISACA, Zagreb (Croatia) April 09th, 2018 35 DNS exfiltration (3)DNS exfiltration (3)
  • 36. ISACA, Zagreb (Croatia) April 09th, 2018 36 Questions?Questions?