-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacketplay.py
52 lines (41 loc) · 1.29 KB
/
packetplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
"""Packet Play
Utilize scapy for network traffic sniffing and manipulation
Usage: $ python3 packetplay.py <src> <dst>
"""
import sys
from scapy.all import *
"""Terminal use
$ scapy
>>>
>>> ls() # Protocol listing
>>> lsc() # List of interactive commands
>>> conf # Change configuration
>>>
>>> packet = IP(dst="website.com", ttl=10) # Create a packet
>>> packet.show()
>>>
>>> conf.color_theme=ColorOnBlackTheme() # Change color theme
>>>
>>> IFACES # Show interfaces
>>> sniffer = sniff(iface="eth0", count=15) # Create a sniffer on eth0 iface
>>> sniffer.show()
>>> sniffer[1].show() # Show specific packet information
>>> sniffer = sniff(filter="port 80 and host 172.253.124.102", count=15, prn=lambda x:x.summary())
"""
def flood(source: str, target: str) -> None:
"""Floods a destination with a lot of packets
Args:
source (str): IP address of source
target (str): IP address of target
"""
for source_port in range(100, 150):
layerIP = IP(src=source, dst=target)
layerTCP = TCP(sport=source_port, dport=600)
packet = layerIP / layerTCP
send(packet)
if __name__ == "__main__":
if len(sys.argv) < 3:
print(f"Usage: python3 {sys.argv[0]} <source> <target>")
sys.exit(1)
flood(sys.argv[1], sys.argv[2])