Python Forum
error in scapy attribute 'haslayer'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error in scapy attribute 'haslayer'
#1
hello all ...
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
Reply


Messages In This Thread
error in scapy attribute 'haslayer' - by evilcode1 - Jan-27-2021, 12:03 PM
RE: error in scapy attribute 'haslayer' - by nilamo - Jan-27-2021, 05:19 PM
RE: error in scapy attribute 'haslayer' - by nilamo - Jan-27-2021, 05:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Error: audioio has no attribute 'AudioOut' netwrok 3 693 Oct-22-2023, 05:53 PM
Last Post: netwrok
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,469 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  Permission issue when using scapy jao 3 10,033 Feb-05-2022, 06:14 PM
Last Post: snippsat
  Getting 'NoneType' object has no attribute 'find' error when WebScraping with BS Franky77 2 5,322 Aug-17-2021, 05:24 PM
Last Post: Franky77
  Attribute Error received not understood (Please Help) crocolicious 5 2,731 Jun-19-2021, 08:45 PM
Last Post: crocolicious
  attribute error instead of correct output MaartenRo 2 2,223 Aug-28-2020, 10:22 AM
Last Post: Larz60+
  attribute error stumped on how to fix it. hank4eva 7 4,845 Aug-11-2020, 04:47 AM
Last Post: hank4eva
  Attribute Error - trying to create a pixel array out of PNG files The_Sarco 1 2,035 Apr-29-2020, 07:10 PM
Last Post: deanhystad
  Attribute Error for Rename / Replace warden89 6 7,995 Jan-07-2020, 06:08 PM
Last Post: warden89
  Reading DBF files from Amazon s3 throwing error - 'int' object has no attribute 'isa abeesm 1 2,951 Sep-22-2019, 05:49 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020