本文整理匯總了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"]
示例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)
示例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
示例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()
示例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)