本文整理汇总了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)