當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。