r/pythonhelp • • Dec 20 '22

Stealth Port Scanner with Scapy and Python

I am doing a college assignment right now and am writing code in python to build a "Stealth Port Scanner with Scapy and Python". This is quite difficult for me so I am hoping for help. I did 11/41 subsections, but I think I messed up somewhere. What should I do differently? Below I send the code and a link of tasks: https://ibb.co/1dYk970

target = input("Adres IP: ")
Registered_Ports = range(1023)

open_ports = []

def scanport(port):
port = RandShort()
conf.verb = 0
SYNACKpkt = sr1(IP(dst=target) / TCP(sport=srcport, dport=port, flags="S", timeout=0.5))
flags = SYNACKpkt.getlayer(TCP).flags
if flags == SYNACKpkt:
return True
else:
return False
SynPkt1 = IP() / TCP()
SynPkt1.haslayer(TCP)
1
SynPkt2 = IP() / UDP()
SynPkt2.haslayer(TCP)
0

2 Upvotes

0 comments sorted by