BASE64 Over DNS, (Wed, Sep 10th)
文章讨论了后门程序如何利用BASE64编码与DNS标签结合进行通信的问题。由于DNS标签不允许使用+、/和=等字符,作者通过测试发现虽然某些工具(如nslookup)可以直接解析包含这些特殊字符的标签,但Windows API无法处理。这表明恶意软件需直接与DNS服务器通信才能实现此类功能。 2025-9-10 14:55:7 Author: isc.sans.edu(查看原文) 阅读量:6 收藏

On the Stormcast, Johannes talked about BASE64 and DNS used by a backdoor.

I was interested to learn more about this, because DNS labels can only contain letters, digits and a hyphen. If you make a distinction between uppercase and lowercase letters, you have exactly 63 characters to choose from. While BASE64 requires 64 characters (and a 65th character for padding: =).

So how can the backdoor use BASE64 in a label, since RFC 1035 (and updates) does not allow characters +, / and = ?

I did some tests.

I had my dnsresolver.py tool running on a server, configured to answer DNS A requests for label Aa0+/=.

And it just worked:

nslookup doesn't check the format of the labels, and neither did the DNS servers that forwarded my queries to my dnsresolver.py tool.

But the Windows APIs that help with resolving hostnames, do care about the format.

For example, the ping tool that uses the Windows API, doesn't work:

Neither does the DnsApi:

Error 9560 is because of the +, / and = characters I used:

Thus malware can use special characters in DNS labels as a C2 channel, but then it has to talk directly to the DNS server (like nslookup does), it can't use Windows APIs to achieve this.

It might be interesting to check your DNS logs (if you have them) for labels with special characters. It's something I'll investigate and report later.

Didier Stevens
Senior handler
blog.DidierStevens.com


文章来源: https://isc.sans.edu/diary/rss/32274
如有侵权请联系:admin#unsafe.sh