黑客绕过iptables

(从SO移动)

我有保护SIP服务器的iptables。 它阻止除了我专门打开的IP以外的所有IP,而且似乎几乎适用于所有人。 我已经从很多不是白名单的IP地址进行testing,他们都应该放弃。

但是,我拿起了一个似乎能够绕过iptables规则的“黑客”。 他的调查邀请通过,我不知道如何,甚至可能。 在十年之内,我还没有见过这个。

我想这一定是我所做的,但是我看不见。

这样创build的iptables(在顶部定义了MYIP – redacted):

iptables -F iptables -X iptables -N ALLOWEDSIP iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -p tcp -d $MYIP --dport 22 -j ACCEPT iptables -t filter -A INPUT -j ALLOWEDSIP # This is my white list. iptables -A ALLOWEDSIP -j RETURN 

现在,在ALLOWEDSIP中没有任何东西,我应该可以做的就是SSH(我可以)。 如果我打电话给他们,他们都会被抛弃。 但wireshark显示我这(我的ip编辑):

 89.163.146.25 -> xxxx SIP/SDP 805 Request: INVITE sip:521088972597572280@xxxx | xxxx -> 89.163.146.25 SIP 417 Status: 100 Giving a try | xxxx -> 89.163.146.25 SIP 875 Status: 407 Proxy Authentication Required | 

他的电话打到了我的转换器,虽然最终被ACL拒绝了,但他们不应该到达那里。 没有别的东西可以通过 把我的头发拉出来。 有人知道吗?

只是为了完整性,这里是iptables -L的结果:

 # iptables -L --line-numbers -v Chain INPUT (policy DROP 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 10 640 ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED 2 0 0 ACCEPT all -- lo any anywhere anywhere 3 0 0 ACCEPT tcp -- any any anywhere <redacted>.com tcp dpt:6928 4 0 0 ALLOWEDSIP all -- any any anywhere anywhere Chain FORWARD (policy DROP 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 6 packets, 544 bytes) num pkts bytes target prot opt in out source destination Chain ALLOWEDSIP (1 references) num pkts bytes target prot opt in out source destination 1 0 0 RETURN all -- any any anywhere anywhere 

编辑:刚刚从wireshark看到这个。 他们是否可以做一些可怕的事情,比如按照既定的规则来build立其他方式? 也许他们在RELATED的某个洞打球了?

 89.163.146.25 -> <redacted> RTCP 806 Source port: tag-pm Destination port: sip 

编辑2:UDP是这里的关键。 当我将OpenSIPS设置为仅侦听TCP时,问题似乎消失。 尽pipe他们正在发送更多的“tag-pm”消息,他们的尝试都不再有任何尝试。 这并不能解释为什么数据包甚至可以打开opensips。 iptables应该先阻止他们。 想知道我在这里做错了什么。

编辑3:如果我删除RELATED我停止回复他们,所以这是有关的。 但是我觉得我需要关系。 有关解决方法的任何提示?

你可能无法路由。 这应该绕过iptables。

 route add 89.163.146.25 gw 127.0.0.1 lo 

核实

 netstat -nr 

要么

 route -n