Time-Based Blind SQL Injection using Heavy Queries

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    Time-Based Blind SQL Injection using Heavy Queries - Presentation Transcript

    1. Speakers: Chema Alonso José Parada Informática64 Microsoft MS MVP Windows Security IT Pro Evangelist [email_address] [email_address]
    2. Agenda
      • Code Injections
        • What are Blind Attacks?
        • Blind SQL Injection Attacks
        • Time-Based Blind SQL Injection
      • Time-Based Blind SQL Injection using heavy queries
        • Heavy Queries
        • Optimization processes
          • Demos with MS SQL Server, Oracle, Acess
        • Marathon Tool
          • Demo
        • Conclusions
    3. Code Injection Attacks
      • (Lazy) Developers use input parameters directly in queries without sanitizing them previously.
        • Command Injection
        • SQL Injection
        • LDAP Injection
        • Xpath Injection
    4. Blind Attacks
      • Attacker injects code but can´t access directly to the data.
      • However this injection changes the behavior of the web application.
      • Then the attacker looks for differences between true code injections (1=1) and false code injections (1=2) in the response pages to extract data.
        • Blind SQL Injection
        • Biind Xpath Injection
        • Blind LDAP Injection
    5. Blind SQL Injection Attacks
      • Attacker injects:
        • “ True where clauses”
        • “ False where clauses“
        • Ex:
          • Program.php?id=1 and 1=1
          • Program.php?id=1 and 1=2
      • Program doesn’t return any visible data from database or data in error messages.
      • The attacker can´t see any data extracted from the database.
    6. Blind SQL Injection Attacks
      • Attacker analyzes the response pages looking for differences between “True-Answer Page” and “False-Answer Page”:
        • Different hashes
        • Different html structure
        • Different patterns (keywords)
        • Different linear ASCII sums
        • “ Different behavior”
          • By example: Response Time
    7. Blind SQL Injection Attacks
      • If any difference exists, then:
        • Attacker can extract all information from database
        • How? Using “booleanization”
          • MySQL:
            • Program.php?id=1 and 100>(ASCII(Substring(user(),1,1)))
              • “ True-Answer Page” or “False-Answer Page”?
          • MSSQL:
            • Program.php?id=1 and 100>(Select top 1 ASCII(Substring(name,1,1))) from sysusers)
          • Oracle:
            • Program.php?id=1 and 100>(Select ASCII(Substr(username,1,1))) from all_users where rownum<=1)
    8. Blind SQL Injection Attacks: Tools
        • SQLbfTools: Extract all information from MySQL databases using patterns
    9. Blind SQL Injection Attacks: Tools
      • Absinthe: Extract all information from MSSQL, PostgreSQL, Sybase and Oracle Databases using Linear sum of ASCII values.
    10. Blind SQL Injection Attacks: Tools
      • Absinthe: Extract all information from MSSQL, PostgreSQL, Sybase and Oracle Databases using Linear sum of ASCII values.
    11. Time-Based Blind SQL Injection
      • In scenarios with no differences between “True-Answer Page” and “False-Answer Page”, time delays could be use.
      • Injection forces a delay in the response page when the condition injected is True.
        • - Delay functions:
          • SQL Server: waitfor
          • Oracle: dbms_lock.sleep
          • MySQL: sleep or Benchmark Function
        • Ex:
          • ; if (exists(select * from users)) waitfor delay '0:0:5’
    12. Exploit for Solar Empire Web Game
    13. Time-Based Blind SQL Injection: Tools
      • SQL Ninja: Use exploitation of “Waitfor” method in MSSQL Databases
    14. Time-Based Blind SQL Injection
      • And in these scenarios with no differences between “true-answer page” and “false-answer page”…
      • What about databases engines without delay functions, i.e., MS Access, Oracle connection without PL/SQL support, DB2, etc…?
      • Is possible to perform an exploitation of Time-Based Blind SQL Injection Attacks?
    15. “ Where-Clause” execution order
      • Select “whatever “
      • From whatever
      • Where condition1 and condition2
      • - Condition1 lasts 10 seconds
      • - Condition2 lasts 100 seconds
      • Which condition should be executed first?
    16. The heavy condition first Condition2 (100 sec) Condition1 (10 sec) Condition2 & condition1 Response Time TRUE FALSE FALSE 110 sec TRUE TRUE TRUE 110 sec FALSE Not evaluated FALSE 100 sec
    17. The light condition first Condition1 (10 sec) Condition2 (100 sec) Condition1 & condition2 Response Time TRUE FALSE FALSE 110 sec TRUE TRUE TRUE 110 sec FALSE Not evaluated FALSE 10 sec
    18. Time-Based Blind SQL Injection using Heavy Queries
      • Attacker can perform an exploitation delaying the “True-answer page” using a heavy query.
      • It depends on how the database engine evaluates the where clauses in the query.
      • There are two types of database engines:
        • Databases without optimization process
        • Databases with optimization process
    19. Databases without optimization process
        • The engine evaluates the condition in the where-clause from left to right or from right to left depending on the database engine
          • Select items from table where codition1 and condition2.
        • It is a developer task to evaluate the lighter condition in first place for better performance.
        • Examples:
          • Oracle (without statistics or poor tuned): Right to Left
          • Access: Right to Left
    20. Databases with optimization process
      • The engine estimates the cost of the condition evaluations in the where clause and executes the lighter first. No matter where it is.
          • Select items from table where codition1 and condition2.
        • It is a database engine task to improve the performance of the query.
      • Examples
        • MS SQL Server
        • Oracle (statistics ON and well tuned)
      • An Attacker could exploit a Blind SQL Injection attack using heavy queries to obtain a delay in the “True-answer page” in both cases.
    21. Time-Based Blind SQL Injection using Heavy Queries
      • Attacker could inject a heavy Cross-Join condition for delaying the response page in True-Injections.
      • The Cross-join injection must be heavier than the other condition.
      • Attacker only have to know or to guess the name of a table with select permission in the database.
      • Example in MSSQL:
        • Program.php?id=1 and (SELECT count(*) FROM sysusers AS sys1, sysusers as sys2, sysusers as sys3, sysusers AS sys4, sysusers AS sys5, sysusers AS sys6, sysusers AS sys7, sysusers AS sys8)>0 and 300>(select top 1 ascii(substring(name,1,1)) from sysusers)
    22. “ Default” tables to construct a heavy queries
        • Microsoft SQL Server
          • sysusers
        • Oracle
          • all_users
        • MySQL (versión 5)
          • information_schema.columns
        • Microsoft Access
          • MSysAccessObjects (97 & 2000 version)
          • MSysAccessStorage (2003 & 2007)
    23. “ Default” tables to construct a heavy queries
      • … or whatever you can guess
        • Clients
        • Customers
        • News
        • Logins
        • Users
        • Providers
        • … .Use your imagination…
    24. Demo 1: MS SQL Server
      • Query lasts 14 seconds -> True-Answer
    25. Demo 1: MS SQL Server
      • Query lasts 1 second -> False-Answer
    26. Demo 2: Oracle
      • Query Lasts 22 seconds –> True-Answer
    27. Demo 2: Oracle
      • Query Lasts 1 second –> False-Answer
    28. Demo 3: Access 2000
      • Query Lasts 6 seconds –> True-Answer
    29. Demo 3: Access 2000
      • Query Lasts 1 second –> False-Answer
    30. Demo 4: Access 2007
      • Query Lasts 39 seconds –> True-Answer
    31. Demo 4: Access 2007
      • Query Lasts 1 second –> False-Answer
    32. Marathon Tool
      • Automates Time-Based Blind SQL Injection Attacks using Heavy Queries in SQL Server, MySQL, MS Access and Oracle Databases.
      • Schema Extraction from known databases
      • Extract data using heavy queries not matter in which database engine (without schema)
      • Developed in .NET
      • Source code available
    33.  
    34. Conclusions
      • Time-Based Blind SQL Injection using Heavy Queries works with any database.
      • The delay generated with a heavy query depends on the environment of the database and the network connection.
      • It is possible to extract all the information stored in the database using this method.
      • It is another bullet….
    35. Questions?
      • Speakers:
        • Chema Alonso
          • [email_address]
          • Microsoft MVP Windows Security
          • Security Consultant
          • Informática64
        • José Parada
          • [email_address]
          • Microsoft IT Pro Evangelist
          • Microsoft
      • Authors:
        • Chema Alonso ( [email_address] )
        • Daniel Kachakil ( [email_address] )
        • Rodolfo Bordón ( [email_address] )
        • Antonio Guzmán ( [email_address] )
        • Marta Beltrán ( [email_address] )

    + chemai64chemai64, 2 years ago

    custom

    2744 views, 1 favs, 7 embeds more stats

    This presentation was delivered in Defcon 16 held i more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2744
      • 2392 on SlideShare
      • 352 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 65
    Most viewed embeds
    • 309 views on http://elladodelmal.blogspot.com
    • 24 views on http://www.hackrock.com.ar
    • 10 views on http://sqlinjections.blogspot.com
    • 5 views on http://www.cyberhades.com
    • 2 views on http://www.elladodelmal.blogspot.com

    more

    All embeds
    • 309 views on http://elladodelmal.blogspot.com
    • 24 views on http://www.hackrock.com.ar
    • 10 views on http://sqlinjections.blogspot.com
    • 5 views on http://www.cyberhades.com
    • 2 views on http://www.elladodelmal.blogspot.com
    • 1 views on file://
    • 1 views on http://static.slideshare.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories