sql injection...sql injection prof. dr. m. ameer ali professor & chairman department of computer...

93
SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Upload: others

Post on 14-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL INJECTION

Prof. Dr. M. Ameer Ali

Professor & ChairmanDepartment of Computer Science & Engineering

Bangladesh University of Business and Technology (BUBT)

Page 2: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Statistics

Page 3: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Most Prevalent Vulnerability 2015

Page 4: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Module Objective

Page 5: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

What is SQL Injection?

Page 6: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Why Bother About SQL Injection?

Page 7: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

How Web Applications Work

Page 8: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection and Server-side Technologies

Page 9: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Understanding HTTP Post Request

Page 10: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Example: Normal SQL Query

Page 11: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Understanding and SQL Injection Query

Page 12: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Understanding and SQL Injection Query- Code Analysis

Page 13: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Example of Web App Vulnerability to SQL Injection: BadProductList.aspx

Page 14: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Example of Web App Vulnerable to SQL Injection: Attack Analysis

Page 15: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Example of SQL Injection: Updating Table

Page 16: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Example of SQL Injection: Adding New Records

Page 17: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Example of SQL Injection: Identifying the Table Name

Page 18: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Example of SQL Injection: Deleting Table

Page 19: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Types of SQL Injection

Page 20: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Error Based SQL Injection

Page 21: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Error Based SQL Injection

Page 22: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Union SQL Injection

Page 23: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Blind SQL Injection

Page 24: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

No Error Messages Returned

Page 25: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Blind SQL Injection: WAITFOR DELY( YES or NO Response)

Page 26: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Boolean Exploitation Technique

Page 27: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Methodology

Page 28: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Information Gathering

Page 29: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Identify Data Entry Paths

Page 30: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Extracting Information through Error Messages

Page 31: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Extracting Information through Error Messages (Cont’d)

Page 32: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Extracting Information through Error Messages (Cont’d)

Page 33: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Extracting Information through Error Messages (Cont’d)

Page 34: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Testing for SQL Injection

Page 35: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Additional Methods to Detect SQL Injection

Page 36: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Black Box Pen Testing

Page 37: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Source Code Review to Detect SQL Injection Vulnerabilities

Page 38: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Methodology

Page 39: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Perform Union SQL Injection

Page 40: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Perform Error Based SQL Injection

Page 41: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Perform Error Based SQL Injection: Using Stored Procedure Injection

Page 42: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Bypass Website Logins Using SQL Injection

Page 43: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Perform Blind SQL Injection: Exploitation (MySQL)

Page 44: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Blind SQL Injection: Extract Database User

Page 45: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Blind SQL Injection: Extract Database Name

Page 46: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Blind SQL Injection: Extract Column Name

Page 47: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Blind SQL Injection: Extract Data From ROWS

Page 48: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Perform Double Blind SQL Injection: Classical Exploitation (MySQL)

Page 49: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Perform Blind SQL Injection Using Out of Band Exploitation Technique

Page 50: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Exploitation Second-Order SQL Injection

Page 51: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Methodology

Page 52: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Database, Table and Column Enumeration

Page 53: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Advanced Enumeration

Page 54: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Features of Different DBMSs

Page 55: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Creating Database Accounts

Page 56: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Password Grabbing

Page 57: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Grabbing SQL Server Hashes

Page 58: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Extracting SQL Hashes (In Single Statement)

Page 59: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Transfer Database to Attacker’s Machine

Page 60: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Interacting with the Operating System

Page 61: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Interacting with the File System

Page 62: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Network Reconnaissance Using SQL Injection

Page 63: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Network Reconnaissance Full Query

Page 64: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool: BSQLHacker

Page 65: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool: Marathon Tool

Page 66: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool: SQL Power Injector

Page 67: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool: Havij

Page 68: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool: Tools

Page 69: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool: Tools

Page 70: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool for Mobile : DroidSQLi

Page 71: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Tool for Mobile : SQLmapchik

Page 72: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evading IDS

Page 73: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Types of Signature Evasion Techniques

Page 74: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evasion Techniques: Sophisticated Matches

Page 75: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evasion Technique: Hex Encoding

Page 76: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evasion Technique: Manipulating White Spaces

Page 77: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evasion Technique: In-line Comment

Page 78: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evasion Technique: Char Encoding

Page 79: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evasion Technique: String Concatenation

Page 80: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Evasion Technique: Obfuscated Codes

Page 81: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

How to Defend Against SQL Injection Attacks

Page 82: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

How to Defend Against SQL Injection Attacks

Page 83: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

How to Defend Against SQL Injection Attacks

Page 84: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

How to Defend Against SQL Injection Attacks

Page 85: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

How to Defend Against SQL Injection Attacks: Use Type-Safe SQL Parameters

Page 86: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

How to Defend Against SQL Injection Attacks

Page 87: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Detection Tool: dotDefender

Page 88: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Detection Tool: IBM Security AppScan

Page 89: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Detection Tool: WebCruiser

Page 90: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Short Rule to Detect SQL Injection Attacks

Page 91: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

SQL Injection Detection Tools

Page 92: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Next Class• DVWA• sql injection• Sqlmap• Burp Suite

Page 93: SQL INJECTION...SQL INJECTION Prof. Dr. M. Ameer Ali Professor & Chairman Department of Computer Science & Engineering Bangladesh University of Business and Technology (BUBT)

Thank you

Q & A