http-request-capture
http-request-capture copied to clipboard
IndexError: Layer [IP] not found
Hi Jack, thank you for sharing this script, it's really useful!
Although the script captures the http requests, I'm getting the following error:
$ sudo python3 http_request_capture.py --iface wlp0s20f3 --port 80
Sun, 04 Apr 2021 19:57:03 +0300: sniffing http requests on port 80 using network interface wlp0s20f3
Sun, 04 Apr 2021 19:58:39 +0300: www.secdev.org/projects/scapy/
Sun, 04 Apr 2021 19:58:39 +0300: www.secdev.org/.well-known/http-opportunistic
Traceback (most recent call last):
File "http_request_capture.py", line 56, in <module>
sniff(
File "/usr/local/lib/python3.8/dist-packages/kamene/sendrecv.py", line 608, in sniff
r = prn(p)
File "http_request_capture.py", line 33, in parse_http_request
if pkt[IP].ack == last_ack:
File "/usr/local/lib/python3.8/dist-packages/kamene/packet.py", line 820, in __getitem__
raise IndexError("Layer [%s] not found" % lname)
IndexError: Layer [IP] not found
Python: 3.8.5 OS: Pop!_OS 20.04 LTS
Hello @sp1thas I'm glad to hear that you think this is useful to you. I don't know what's the issue and how to solve it, I only tested on Mac OSX. kamene is a fork of scapy so I think you can search "scapy Layer [IP] not found" issue on google and github issues so you can find more information about that. I hope you can find the solution!
Based on this, if you replace L33 in http_request_capture.py with this: if IP in pkt and pkt[IP].ack == last_ack, this IndexError will be fixed.