当 SCTP 是 Scapy/Python 的传输协议时,获取所有 Diameter 数据包

问题描述

我有 2 条跟踪wireshark,一条使用 TCP 和 Diameter 协议,另一条使用 SCTP 和 Diameter 协议。 我想使用以下代码使用 scapy 和 Python 检索所有数据包直径 SCTP:

bind_layers(SCTP,DiamG,dport=port_de_test)
bind_layers(SCTP,sport=port_de_test)
bind_layers(TCP,dport=port_de_test)
bind_layers(TCP,sport=port_de_test)
class CallFlow:
    def __init__(self,pcap_adress=""):
        portsGx = {4458,3870,3868,4468,49857,48868,59368}
        portsGy = {4457,4467,49871,48871}
        self.messages = []
        try:
            if pcap_adress != '':
                
                packets = rdpcap(pcap_adress)
                for packet in packets:
                    
                    if DiamG in packet:
                        
                        if TCP in packet:
                            p = packet[TCP]
                            
                            d = p.payload
                            
                            
                            if (packet[TCP].sport in portsGx) | (packet[TCP].dport in portsGx):
                                interface = "Gx"
                            elif (packet[TCP].sport in portsGy) | (packet[TCP].dport in portsGy):
                                interface = "Gy"
                        elif SCTP in packet:
                            p = packet[SCTP]
                            
                            d = p.payload
                            print (d)
                            if (packet[SCTP].sport in portsGx) | (packet[SCTP].dport in portsGx):
                                interface = "Gx"
                            elif (packet[SCTP].sport in portsGy) | (packet[SCTP].dport in portsGy):
                                interface = "Gy"
                        else:
                            print("Diameter should be TCP or SCTP")
                            `break

当我运行此代码时,当 TCP 是传输协议时,我可以获得所有直径数据包,但是当我在 sctp 是传输协议时运行此代码时,我只得到第一条消息,而不是所有跟踪。

你能不能检查一下这段代码,告诉我哪里出了问题。

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)