Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haslayer() fails in for loop #29

Open
Lcreager opened this issue Dec 12, 2017 · 0 comments
Open

haslayer() fails in for loop #29

Lcreager opened this issue Dec 12, 2017 · 0 comments

Comments

@Lcreager
Copy link

When running haslayer('HTTP') over all packets in a for loop, I get the below:

for p in pkts:
    p.haslayer('HTTP')
    
Traceback (most recent call last):
  File "<input>", line 2, in <module>
  File "C:\Python27\lib\site-packages\scapy\packet.py", line 890, in haslayer
    return self.payload.haslayer(cls)
  File "C:\Python27\lib\site-packages\scapy\packet.py", line 890, in haslayer
    return self.payload.haslayer(cls)
  File "C:\Python27\lib\site-packages\scapy\packet.py", line 890, in haslayer
    return self.payload.haslayer(cls)
  File "C:\Python27\lib\site-packages\scapy\layers\ntp.py", line 217, in haslayer
    elif issubclass(cls, NTP):
TypeError: issubclass() arg 1 must be a class

Doing a similar command with a different layer is successful:

for p in pkts:
    p.haslayer(TCP)

I narrowed down the exact packets causing problems here:

i = 0
for p in pkts:
	i += 1
	try:
		p.haslayer('HTTP')
	except Exception as e:
		print(e)
		print(i)
        
issubclass() arg 1 must be a class
101
issubclass() arg 1 must be a class
109
issubclass() arg 1 must be a class
113
issubclass() arg 1 must be a class
116
issubclass() arg 1 must be a class
118
issubclass() arg 1 must be a class
119
issubclass() arg 1 must be a class
120
issubclass() arg 1 must be a class
121

It looks like NTP packets cause problems for some reason. I have attached a pcap with one of the packets which causes the error.

ntp.pcap.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant