当前位置: 首页>>代码示例>>Python>>正文


Python all.Packet方法代码示例

本文整理汇总了Python中scapy.all.Packet方法的典型用法代码示例。如果您正苦于以下问题:Python all.Packet方法的具体用法?Python all.Packet怎么用?Python all.Packet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.all的用法示例。


在下文中一共展示了all.Packet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_multiple_packets

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Packet [as 别名]
def test_multiple_packets():
    packets = [
        # HTTP Packet
        Ether(src="ab:ab:ab:ab:ab:ab", dst="12:12:12:12:12:12")
        / IP(src="127.0.0.1", dst="192.168.1.1")
        / TCP(sport=12345, dport=80)
        / HTTP()
        / HTTPRequest(Method="GET", Path="/foo", Host="https://google.com"),
        # DNS Packet
        Ether(src="ab:ab:ab:ab:ab:ab", dst="12:12:12:12:12:12")
        / IP(src="127.0.0.1", dst="192.168.1.1")
        / UDP(sport=80, dport=53)
        / DNS(rd=1, qd=DNSQR(qtype="A", qname="google.com"), an=DNSRR(rdata="123.0.0.1")),
        # TCP Packet
        Ether(src="ab:ab:ab:ab:ab:ab", dst="12:12:12:12:12:12")
        / IP(src="127.0.0.1", dst="192.168.1.1")
        / TCP(sport=80, dport=5355),
    ]

    events = list(packets_to_datasource_events(packets).events())
    assert len(events) == 3

    assert [e["event_type"] for e in events] == ["HTTPRequest", "DNS", "TCP"] 
开发者ID:yampelo,项目名称:beagle,代码行数:25,代码来源:test_pcap.py

示例2: __repr__

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Packet [as 别名]
def __repr__(self):
        if self.reserved != 0:
            return scapy_all.Packet.__repr__(self)

        # Known status
        if self.status in self.ERROR_CODES and self.additional_size == 0:
            return "<CIP_ResponseStatus  status={}>".format(self.ERROR_CODES[self.status])

        # Simple status
        if self.additional_size == 0:
            return "<CIP_ResponseStatus  status=%#x>" % self.status

        # Forward Open failure
        if self.status == 1 and self.additional == b"\x00\x01":
            return "<CIP_ResponseStatus  status=Connection failure>"
        return scapy_all.Packet.__repr__(self) 
开发者ID:scy-phy,项目名称:scapy-cip-enip,代码行数:18,代码来源:cip.py

示例3: packets_to_datasource_events

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Packet [as 别名]
def packets_to_datasource_events(packets: List[Packet]) -> PCAP:
    f = BytesIO()
    PcapWriter(f).write(packets)
    f.seek(0)
    return PCAP(f)  # type: ignore 
开发者ID:yampelo,项目名称:beagle,代码行数:7,代码来源:test_pcap.py

示例4: test_from_datasources

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Packet [as 别名]
def test_from_datasources():
    packets_1 = [
        Ether(src="ab:ab:ab:ab:ab:ab", dst="12:12:12:12:12:12")
        / IP(src="127.0.0.1", dst="192.168.1.1")
        / TCP(sport=12345, dport=80)
        / HTTP()
        / HTTPRequest(Method="GET", Path="/foo", Host="https://google.com")
    ]

    packets_2 = [
        # HTTP Packet
        Ether(src="ab:ab:ab:ab:ab:ab", dst="12:12:12:12:12:12")
        / IP(src="127.0.0.1", dst="192.168.1.1")
        / TCP(sport=12345, dport=80)
        / HTTP()
        / HTTPRequest(Method="GET", Path="/foo", Host="https://google.com"),
        # DNS Packet
        Ether(src="ab:ab:ab:ab:ab:ab", dst="12:12:12:12:12:12")
        / IP(src="127.0.0.1", dst="192.168.1.1")
        / UDP(sport=80, dport=53)
        / DNS(rd=1, qd=DNSQR(qtype="A", qname="google.com"), an=DNSRR(rdata="123.0.0.1")),
        # TCP Packet
        Ether(src="ab:ab:ab:ab:ab:ab", dst="12:12:12:12:12:12")
        / IP(src="127.0.0.1", dst="192.168.1.1")
        / TCP(sport=80, dport=5355),
    ]

    nx = NetworkX.from_datasources(
        [packets_to_datasource_events(packets) for packets in [packets_1, packets_2]]
    )

    # Make the graph
    nx.graph()

    assert not nx.is_empty() 
开发者ID:yampelo,项目名称:beagle,代码行数:37,代码来源:test_networkx.py

示例5: verify

# 需要导入模块: from scapy import all [as 别名]
# 或者: from scapy.all import Packet [as 别名]
def verify(self, test_params):
        """Verify whether remote host is vulnerable to this vulnerability."""
        test_result = sr1_file(test_params, VULN_DB_PATH + self.payload_file)
        print ("[*] Payload for {} sent".format(self.name))
        if test_result is not None:
            if test_result is Packet:
                show_verbose(test_params, test_result)
        print (
            "[+] Vulnerability {} is memory leak - verify manually result of "
            "this test.".format(self.name)
        )
        self.report_potential_result(test_params) 
开发者ID:Samsung,项目名称:cotopaxi,代码行数:14,代码来源:vulnerability_tester.py


注:本文中的scapy.all.Packet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。