SlideShare une entreprise Scribd logo
1  sur  34
Télécharger pour lire hors ligne
Curious Case of SQLi
Miroslav Štampar
dev@sqlmap.org
Target (1)
• High profile (i.e. very important to be secure)
• It was a fancy new Web 2.0 site (lots of
Javascript) – while it first appeared as a Flash site
• Very little user interaction (but lots of clicking)
• Automatic vulnerability scanners reported nothing
more than usual nagging (e.g. clickjacking
possible, lack of security headers, etc.)
• Used Javascript libraries were up-to-date
• Custom Javascript parts were clean (e.g. no DOM
based XSS, open redirections, etc.)
Target (2)
• No user management (everybody is/was
anonymous)
• Web server was up-to-date
• Only attack points suceptable to (malicious)
user interaction were:
➢
➢

Ajax call for user search (let's call it search.asp)
search.asp)
Ajax call for search within categories (let's call it
category.asp)
category.asp)

• Burp to the rescue
Attack points (1)
Attack points (2)
Typical response
Day #1 (.1)
• First tests resulted only with #FAIL
• Trashing of values (e.g. foo')><"bar)
foo')><"bar)
resulted in prolonged HTTP error 500 responses
(cca. 90 seconds before server timeout)
• '-- resulted with SQLi (response differentiation)
• '-- WAITFOR DELAY '0:0:5' resulted in
immediate HTTP error 500 response
• Though, ' WAITFOR DELAY foobar resulted
the same
• Usual stuff like ' AND 1=1-- and/or ' OR
2>1-- resulted in prolonged error responses too
Day #1 (.2)
• Everything point(ed) that there was some kind of
WAF involved (as said, high profile target)
• Colleagues told me to "just leave it"
• Boss told me that there is no hurry and that I can
work on it as much as I want :)
• As a sqlmap developer I had an "obligation" to, at
least try to, "break it"
• I told that I need 1-2 more days to be 100% sure
• One of first ideas was to write a SQLi fuzzer that
would do the "monkey test" job
Day #1 (.3)
• At the end of the working day, left sqlmap (over
the night) to test all the parameters
• Turned on all possible boundary & payload
combinations (--level=5 --risk=3)
(--level=5 --risk=3)
• Hoped that something usable will turn out of it
• During commuting (local overcrowded bus)
thought of all the stuff learned through years
• ..., WAF bypass tricks, non-ASCII SQLi payloads,
non-disclosed SQLi attacks, non-mainstream SQL
statements (Love Thy Reference Manual), etc.
Day #2 (.1)
•
•
•
•
•

Tried literary everything in my knowledge domain
Lots of delayed responses (very cumbersome)
sqlmap was still running (still nothing)
Almost quit (during the coffee break)
Had a hard look once more into the original
requests
• That ASC was "provoking" as hell
• Tried to Google in hope that something will turn
out
Day #2 (.2)
Day #2 (.3)
Day #2 (.4)
Day #2 (.5)
Day #2 (.6)
Day #2 (.7)
• Windows Search/Indexing Service can be SQL-ed
• Advanced Query Syntax (AQS) #FTW
• "AQS is the default query syntax used by
Windows Search to query the index and to refine
and narrow search parameters"
• A basic query searches for items that satisfy a
restriction over a property
• Users can limit the scope of their searches to
specific folder locations or data stores
• There is no single reported case of SQLi
Day #2 (.8)
Day #2 (.9)
Day #2 (.10)
Day #2 (.11)
Day #2 (.12)
Day #2 (.13)
Day #2 (.14)
Day #2 (.15)
• At the end of the day, summarized findings
• Columns of interest (SYSTEMINDEX catalog):
(SYSTEMINDEX
System.ItemFolderPathDisplay,
System.ItemFolderPathDisplay,
System.Filename,
System.Filename,
System.ItemPathDisplay, System.Size,
System.ItemPathDisplay, System.Size,
System.FileOwner
• Some columns had interesting names, but
appeared to be always empty (System.Author,
(System.Author,
System.Comment, System.ComputerName,
System.Comment, System.ComputerName,
System.Keywords, System.Subject,
System.Keywords, System.Subject,
System.Title, etc.)
System.Title, etc.)
Day #2 (.16)
• All in all, nothing special than proof of SQLi and
complete file listing with (semi-)interesting
attributes
• Went home and thought (again) in overcrowded
local bus "is that the best I can do?"
• That SQL/AQS was really limited (i.e. crippled)
• Nothing special is stored inside (than local file
listing) from security point of view
• "...or, wait a minute..."
Day #2 (.17)
• There must be a way how to search files with
keywords (it's called Search for a reason)
• Came to homeplace and immediatelly read
the whole reference manual
• Found a special operator: CONTAINS
• Using it's wildcard functionality it should be
possible to infer the content of files
• ...AND
System.ItemPathDisplay='...' AND
CONTAINS('""a*""')--
Day #3 (.1)
• Manually tried file content inference trick and it
worked as charm
• Usually, user permissions of process running the
search would pose a problem (e.g. if run with
default anonymous IIS account
IUSR_<computer_name>)
IUSR_<computer_name>)
• Administrator used external VBS script, most
probably because of simplicity and usability
• It was being run with different (more permissive)
credentials
Day #3 (.2)
• Retrieved a list of "all" local files (accessible by
the searching VBS process)
• System directories were missing (e.g.
C:Windows & C:Program Files)
Files)
• Out of the rest, directories that appeared
especially interesting were:
C:InetpubwwwrootfoobarOld &
C:InetpubwwwrootfoobarBackup
• Inside both of those there was a web.config file
• Started implementing file content inference
mechanism using CONTAINS
Day #3 (.3)
Day #3 (.4)
•
•
•
•
•
•
•
•
•
•

..AND
..AND
...
..AND
..AND
..AND
..AND
..AND
...
..AND

CONTAINS('""a*""')..
CONTAINS('""aa*""')..

(true)
(false)

CONTAINS('""ad*""').. (true)
CONTAINS('""ada*""').. (false)
CONTAINS('""adb*""').. (false)
CONTAINS('""add*""').. (true)
CONTAINS('""adda*""')..(false)
CONTAINS('""add""')..

(true)
Day #3 (.5)
Day #3 (.6)
• Inference of a configuration file containing a
sa password for a (local) SQL Server was a
pretty good catch :)
• As said, search process was constrained with
used user rights (limiting wider exposée)
• There were no opened ports than 80 (e.g.
port 1433 would be great)
• There were no (exposed) administrator pages
• Called it a day and finished a test altogether
Conclusion
• Use automatic vulnerability scanners only to
get a "sense" of target's security settings
• To get a deep understanding of target's inner
workings you'll always need to "get dirty"
• If you have a "hunch" stick with it
• You'll most probably be wrong, but you'll
learn a lot along the way
• In case that your "hunch" was right, you'll
have an interesting story to tell (highly
subjective opinion ;)
Questions?

Contenu connexe

Tendances

Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr Workshop
JSGB
 
Apache Solr crash course
Apache Solr crash courseApache Solr crash course
Apache Solr crash course
Tommaso Teofili
 
03 standard class library
03 standard class library03 standard class library
03 standard class library
eleksdev
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
Erik Hatcher
 

Tendances (20)

Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr Workshop
 
Professional Help for PowerShell Modules
Professional Help for PowerShell ModulesProfessional Help for PowerShell Modules
Professional Help for PowerShell Modules
 
DanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino APIDanNotes 2013: OpenNTF Domino API
DanNotes 2013: OpenNTF Domino API
 
Ln monitoring repositories
Ln monitoring repositoriesLn monitoring repositories
Ln monitoring repositories
 
Java JDBC
Java JDBCJava JDBC
Java JDBC
 
Apache Solr - Enterprise search platform
Apache Solr - Enterprise search platformApache Solr - Enterprise search platform
Apache Solr - Enterprise search platform
 
User defined-functions-cassandra-summit-eu-2014
User defined-functions-cassandra-summit-eu-2014User defined-functions-cassandra-summit-eu-2014
User defined-functions-cassandra-summit-eu-2014
 
Apache Solr crash course
Apache Solr crash courseApache Solr crash course
Apache Solr crash course
 
03 standard class library
03 standard class library03 standard class library
03 standard class library
 
OpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview IntroductionOpenNTF Domino API - Overview Introduction
OpenNTF Domino API - Overview Introduction
 
What is new in CFEngine 3.6
What is new in CFEngine 3.6What is new in CFEngine 3.6
What is new in CFEngine 3.6
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
SUTOL 2015 - Utilizing the OpenNTF Domino API
SUTOL 2015 - Utilizing the OpenNTF Domino APISUTOL 2015 - Utilizing the OpenNTF Domino API
SUTOL 2015 - Utilizing the OpenNTF Domino API
 
Data file handling
Data file handlingData file handling
Data file handling
 
libAttachSQL, The Next-Generation C Connector For MySQL
libAttachSQL, The Next-Generation C Connector For MySQLlibAttachSQL, The Next-Generation C Connector For MySQL
libAttachSQL, The Next-Generation C Connector For MySQL
 
Unix/Linux
Unix/Linux Unix/Linux
Unix/Linux
 
CNIT 127 Ch 3: Shellcode
CNIT 127 Ch 3: ShellcodeCNIT 127 Ch 3: Shellcode
CNIT 127 Ch 3: Shellcode
 
Introduction to Solr
Introduction to SolrIntroduction to Solr
Introduction to Solr
 
XNA L01–Introduction
XNA L01–IntroductionXNA L01–Introduction
XNA L01–Introduction
 
Introduction to char device driver
Introduction to char device driverIntroduction to char device driver
Introduction to char device driver
 

En vedette

Psychological science and beliefs
Psychological science and beliefsPsychological science and beliefs
Psychological science and beliefs
Lance Jones
 
Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...
Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...
Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...
ProstirUA
 
Program pss bersama kartunis
Program pss bersama kartunisProgram pss bersama kartunis
Program pss bersama kartunis
Laila Mustafa
 
Kejohanan balapan & padang
Kejohanan balapan & padangKejohanan balapan & padang
Kejohanan balapan & padang
Laila Mustafa
 

En vedette (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
 
Hash DoS Attack
Hash DoS AttackHash DoS Attack
Hash DoS Attack
 
Smashing the Buffer
Smashing the BufferSmashing the Buffer
Smashing the Buffer
 
sqlmap - Under the Hood
sqlmap - Under the Hoodsqlmap - Under the Hood
sqlmap - Under the Hood
 
sqlmap - security development in Python
sqlmap - security development in Pythonsqlmap - security development in Python
sqlmap - security development in Python
 
Analysis of mass SQL injection attacks
Analysis of mass SQL injection attacksAnalysis of mass SQL injection attacks
Analysis of mass SQL injection attacks
 
Heuristic methods used in sqlmap
Heuristic methods used in sqlmapHeuristic methods used in sqlmap
Heuristic methods used in sqlmap
 
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)
 
sqlmap - why (not how) it works?
sqlmap - why (not how) it works?sqlmap - why (not how) it works?
sqlmap - why (not how) it works?
 
Spot the Web Vulnerability
Spot the Web VulnerabilitySpot the Web Vulnerability
Spot the Web Vulnerability
 
DNS exfiltration using sqlmap
DNS exfiltration using sqlmapDNS exfiltration using sqlmap
DNS exfiltration using sqlmap
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and NowRiding the Overflow - Then and Now
Riding the Overflow - Then and Now
 
Bilgi Teknolojilerinin Temel Kavramları 1
Bilgi Teknolojilerinin Temel Kavramları 1Bilgi Teknolojilerinin Temel Kavramları 1
Bilgi Teknolojilerinin Temel Kavramları 1
 
Psychological science and beliefs
Psychological science and beliefsPsychological science and beliefs
Psychological science and beliefs
 
Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...
Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...
Проект змін до ЗУ «Про сприяння соціальному становленню та розвитку молоді в ...
 
CHS Reunion Slide Show 2001
CHS Reunion Slide Show 2001CHS Reunion Slide Show 2001
CHS Reunion Slide Show 2001
 
Program pss bersama kartunis
Program pss bersama kartunisProgram pss bersama kartunis
Program pss bersama kartunis
 
Kejohanan balapan & padang
Kejohanan balapan & padangKejohanan balapan & padang
Kejohanan balapan & padang
 
redBorder: Open or die
redBorder: Open or dieredBorder: Open or die
redBorder: Open or die
 

Similaire à Curious Case of SQLi

Oracle forensics 101
Oracle forensics 101Oracle forensics 101
Oracle forensics 101
fangjiafu
 
Esage on non-existent 0-days, stable binary exploits and user interaction
Esage   on non-existent 0-days, stable binary exploits and user interactionEsage   on non-existent 0-days, stable binary exploits and user interaction
Esage on non-existent 0-days, stable binary exploits and user interaction
DefconRussia
 
SQL Queries on Smalltalk Objects
SQL Queries on Smalltalk ObjectsSQL Queries on Smalltalk Objects
SQL Queries on Smalltalk Objects
ESUG
 
Windows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-publicWindows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-public
CTIN
 

Similaire à Curious Case of SQLi (20)

Oracle forensics 101
Oracle forensics 101Oracle forensics 101
Oracle forensics 101
 
Introduction to libre « fulltext » technology
Introduction to libre « fulltext » technologyIntroduction to libre « fulltext » technology
Introduction to libre « fulltext » technology
 
Advanced Windows Exploitation
Advanced Windows ExploitationAdvanced Windows Exploitation
Advanced Windows Exploitation
 
SQL Injection Defense in Python
SQL Injection Defense in PythonSQL Injection Defense in Python
SQL Injection Defense in Python
 
Workshop - Linux Memory Analysis with Volatility
Workshop - Linux Memory Analysis with VolatilityWorkshop - Linux Memory Analysis with Volatility
Workshop - Linux Memory Analysis with Volatility
 
Esage on non-existent 0-days, stable binary exploits and user interaction
Esage   on non-existent 0-days, stable binary exploits and user interactionEsage   on non-existent 0-days, stable binary exploits and user interaction
Esage on non-existent 0-days, stable binary exploits and user interaction
 
On non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits andOn non existent 0-days, stable binary exploits and
On non existent 0-days, stable binary exploits and
 
CamSec Sept 2016 - Tricks to improve web app excel export attacks
CamSec Sept 2016 - Tricks to improve web app excel export attacksCamSec Sept 2016 - Tricks to improve web app excel export attacks
CamSec Sept 2016 - Tricks to improve web app excel export attacks
 
SQL Queries on Smalltalk Objects
SQL Queries on Smalltalk ObjectsSQL Queries on Smalltalk Objects
SQL Queries on Smalltalk Objects
 
.NET Core Summer event 2019 in Prague, CZ - War stories from .NET team -- Kar...
.NET Core Summer event 2019 in Prague, CZ - War stories from .NET team -- Kar....NET Core Summer event 2019 in Prague, CZ - War stories from .NET team -- Kar...
.NET Core Summer event 2019 in Prague, CZ - War stories from .NET team -- Kar...
 
Live Memory Forensics on Android devices
Live Memory Forensics on Android devicesLive Memory Forensics on Android devices
Live Memory Forensics on Android devices
 
Introduction to .NET Performance Measurement
Introduction to .NET Performance MeasurementIntroduction to .NET Performance Measurement
Introduction to .NET Performance Measurement
 
Mac Memory Analysis with Volatility
Mac Memory Analysis with VolatilityMac Memory Analysis with Volatility
Mac Memory Analysis with Volatility
 
Memory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual MachineMemory Analysis of the Dalvik (Android) Virtual Machine
Memory Analysis of the Dalvik (Android) Virtual Machine
 
06.1 .Net memory management
06.1 .Net memory management06.1 .Net memory management
06.1 .Net memory management
 
ShmooCON 2009 : Re-playing with (Blind) SQL Injection
ShmooCON 2009 : Re-playing with (Blind) SQL InjectionShmooCON 2009 : Re-playing with (Blind) SQL Injection
ShmooCON 2009 : Re-playing with (Blind) SQL Injection
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
 
Getting Started with Java
Getting Started with JavaGetting Started with Java
Getting Started with Java
 
Windows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-publicWindows 7 forensics jump lists-rv3-public
Windows 7 forensics jump lists-rv3-public
 
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
Memcached-инъекции - они существуют и работают, Иван Новиков (ONsec)
 

Plus de Miroslav Stampar

Plus de Miroslav Stampar (10)

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?
 
sqlmap internals
sqlmap internalssqlmap internals
sqlmap internals
 
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
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Curious Case of SQLi

  • 1. Curious Case of SQLi Miroslav Štampar dev@sqlmap.org
  • 2. Target (1) • High profile (i.e. very important to be secure) • It was a fancy new Web 2.0 site (lots of Javascript) – while it first appeared as a Flash site • Very little user interaction (but lots of clicking) • Automatic vulnerability scanners reported nothing more than usual nagging (e.g. clickjacking possible, lack of security headers, etc.) • Used Javascript libraries were up-to-date • Custom Javascript parts were clean (e.g. no DOM based XSS, open redirections, etc.)
  • 3. Target (2) • No user management (everybody is/was anonymous) • Web server was up-to-date • Only attack points suceptable to (malicious) user interaction were: ➢ ➢ Ajax call for user search (let's call it search.asp) search.asp) Ajax call for search within categories (let's call it category.asp) category.asp) • Burp to the rescue
  • 7. Day #1 (.1) • First tests resulted only with #FAIL • Trashing of values (e.g. foo')><"bar) foo')><"bar) resulted in prolonged HTTP error 500 responses (cca. 90 seconds before server timeout) • '-- resulted with SQLi (response differentiation) • '-- WAITFOR DELAY '0:0:5' resulted in immediate HTTP error 500 response • Though, ' WAITFOR DELAY foobar resulted the same • Usual stuff like ' AND 1=1-- and/or ' OR 2>1-- resulted in prolonged error responses too
  • 8. Day #1 (.2) • Everything point(ed) that there was some kind of WAF involved (as said, high profile target) • Colleagues told me to "just leave it" • Boss told me that there is no hurry and that I can work on it as much as I want :) • As a sqlmap developer I had an "obligation" to, at least try to, "break it" • I told that I need 1-2 more days to be 100% sure • One of first ideas was to write a SQLi fuzzer that would do the "monkey test" job
  • 9. Day #1 (.3) • At the end of the working day, left sqlmap (over the night) to test all the parameters • Turned on all possible boundary & payload combinations (--level=5 --risk=3) (--level=5 --risk=3) • Hoped that something usable will turn out of it • During commuting (local overcrowded bus) thought of all the stuff learned through years • ..., WAF bypass tricks, non-ASCII SQLi payloads, non-disclosed SQLi attacks, non-mainstream SQL statements (Love Thy Reference Manual), etc.
  • 10. Day #2 (.1) • • • • • Tried literary everything in my knowledge domain Lots of delayed responses (very cumbersome) sqlmap was still running (still nothing) Almost quit (during the coffee break) Had a hard look once more into the original requests • That ASC was "provoking" as hell • Tried to Google in hope that something will turn out
  • 16. Day #2 (.7) • Windows Search/Indexing Service can be SQL-ed • Advanced Query Syntax (AQS) #FTW • "AQS is the default query syntax used by Windows Search to query the index and to refine and narrow search parameters" • A basic query searches for items that satisfy a restriction over a property • Users can limit the scope of their searches to specific folder locations or data stores • There is no single reported case of SQLi
  • 24. Day #2 (.15) • At the end of the day, summarized findings • Columns of interest (SYSTEMINDEX catalog): (SYSTEMINDEX System.ItemFolderPathDisplay, System.ItemFolderPathDisplay, System.Filename, System.Filename, System.ItemPathDisplay, System.Size, System.ItemPathDisplay, System.Size, System.FileOwner • Some columns had interesting names, but appeared to be always empty (System.Author, (System.Author, System.Comment, System.ComputerName, System.Comment, System.ComputerName, System.Keywords, System.Subject, System.Keywords, System.Subject, System.Title, etc.) System.Title, etc.)
  • 25. Day #2 (.16) • All in all, nothing special than proof of SQLi and complete file listing with (semi-)interesting attributes • Went home and thought (again) in overcrowded local bus "is that the best I can do?" • That SQL/AQS was really limited (i.e. crippled) • Nothing special is stored inside (than local file listing) from security point of view • "...or, wait a minute..."
  • 26. Day #2 (.17) • There must be a way how to search files with keywords (it's called Search for a reason) • Came to homeplace and immediatelly read the whole reference manual • Found a special operator: CONTAINS • Using it's wildcard functionality it should be possible to infer the content of files • ...AND System.ItemPathDisplay='...' AND CONTAINS('""a*""')--
  • 27. Day #3 (.1) • Manually tried file content inference trick and it worked as charm • Usually, user permissions of process running the search would pose a problem (e.g. if run with default anonymous IIS account IUSR_<computer_name>) IUSR_<computer_name>) • Administrator used external VBS script, most probably because of simplicity and usability • It was being run with different (more permissive) credentials
  • 28. Day #3 (.2) • Retrieved a list of "all" local files (accessible by the searching VBS process) • System directories were missing (e.g. C:Windows & C:Program Files) Files) • Out of the rest, directories that appeared especially interesting were: C:InetpubwwwrootfoobarOld & C:InetpubwwwrootfoobarBackup • Inside both of those there was a web.config file • Started implementing file content inference mechanism using CONTAINS
  • 30. Day #3 (.4) • • • • • • • • • • ..AND ..AND ... ..AND ..AND ..AND ..AND ..AND ... ..AND CONTAINS('""a*""').. CONTAINS('""aa*""').. (true) (false) CONTAINS('""ad*""').. (true) CONTAINS('""ada*""').. (false) CONTAINS('""adb*""').. (false) CONTAINS('""add*""').. (true) CONTAINS('""adda*""')..(false) CONTAINS('""add""').. (true)
  • 32. Day #3 (.6) • Inference of a configuration file containing a sa password for a (local) SQL Server was a pretty good catch :) • As said, search process was constrained with used user rights (limiting wider exposée) • There were no opened ports than 80 (e.g. port 1433 would be great) • There were no (exposed) administrator pages • Called it a day and finished a test altogether
  • 33. Conclusion • Use automatic vulnerability scanners only to get a "sense" of target's security settings • To get a deep understanding of target's inner workings you'll always need to "get dirty" • If you have a "hunch" stick with it • You'll most probably be wrong, but you'll learn a lot along the way • In case that your "hunch" was right, you'll have an interesting story to tell (highly subjective opinion ;)