Jan-27-2021, 12:03 PM
hello all ...
im trying to write a port scanner using scapy module
my code :
im trying to write a port scanner using scapy module
my code :
from scapy.all import * target = "192.168.1.81" print("Scanning .... " + target + " For Open Ports!\n") for x in range(20 , 100): packet = IP(dst=target)/TCP(dport=x,flags='S') res = sr1(packet ,timeout=0.5) if res.haslayer(TCP) and res.getlayer(TCP).flags==0x12: print("port" + str(x) + "is open!") sr(IP(dst=target)/TCP(dport=res.sport,flags='R'),timeout=0.5) print("scan is complete")Output:Scanning .... 192.168.1.81 For Open Ports! Begin emission: Finished sending 1 packets. ..... Received 5 packets, got 0 answers, remaining 1 packets Traceback (most recent call last): File "/home/evilcode1/Downloads/Course/ping.py", line 11, in <module> if res.haslayer(TCP) and res.getlayer(TCP).flags==0x12: AttributeError: 'NoneType' object has no attribute 'haslayer'any help please 