Is there a way to track a specific dns request back to the app making it?

Is there a way to track a specific dns request back to the app making it?

我的防火墙已将我的 ubuntu 网络服务器标记为向其认为可能与恶意软件相关的域发出A记录 DNS 请求。.su

tcpdump在服务器上的端口 53 上做了几天,直到再次弹出域请求(因为下游防火墙不记录实际的 URL),现在已经请求了实际的域。我查了一下,它在几个 RBL 中,但我想知道我的服务器上是什么在发出这些特定的 DNS 查询。

它不是桌面环境,而是命令行 Ubuntu Server。它ISPConfig主要作为基本的网络服务器运行,因此请求可以来自任何已安装的东西。也许操作系统或组件试图连接到其所有者的更新服务器、传入邮件查找等...但这些NSA记录该域的请求,没有MXTXT任何其他...这真的很令人愤怒。

知道如何找出哪个进程正在调用 Bind 来查找该域吗?

答案1

这很粗糙,但您可以用来iptables监视数据包,然后lsof查找正在使用进行查询的端口的内容。

基本上是这样的:

iptables -I OUTPUT -p UDP --dport 53 -m string --algo bm --string foobar.su -j LOG --log-uid --log-prefix FOOBAR_MATCH

journalctl -t kernel -f | perl -ne '/FOOBAR_MATCH/ && /SPT=(\d+)/ && system("lsof -i udp:$1")'

^ 更改foobar.su为您正在观看的任何内容。

如果您的系统启用了 IPv6,您将需要执行该iptables命令并再次运行它ip6tables

Once done, run the iptables command again, but with -D instead of -I to delete the rule(s).

 

The --log-uid on the iptables rule is optional. I included it in case for some reason the lsof isn't able to capture the process, then you can still glean some potentially useful information.

You might also need to add another iptables rule to drop the request. Otherwise the application might get a response and disappear too fast for the lsof to catch it.

相关内容