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

fixes #26 "TypeError: a bytes-like object is required, not str" #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

fixes #26 "TypeError: a bytes-like object is required, not str" #27

wants to merge 1 commit into from

Conversation

sim0nx
Copy link

@sim0nx sim0nx commented Jul 12, 2017

This PR fixes #26

@arslanmughal99
Copy link

Hi...>!
i'm getting this error in python3 but not in python2 even i have updated scapy and scapy-http on latest release ?

i'm writing a simple packet sniffer with which i can monitor the traffic so that i can get packets in my desire output format

WARNING: Unless called manually, this could indicate deprecated use. Should be changed to bytes(self)
Source IP               : xxxxxxxxx
Source mac_address      : xxxxxxxxx
Destination IP          : xxxxxxxx
Destination mac_address : xxxxxxxxx
Destination PORT        : 80
Traceback (most recent call last):
  File "/root/Desktop/PythonForH/src/Packet_sniffer/packet_sniffer.py", line 24, in <module>
    sniff("wlan1")
  File "/root/Desktop/PythonForH/src/Packet_sniffer/packet_sniffer.py", line 9, in sniff
    scapy.sniff(iface=interface, store=False, prn=sniff_callback)
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy/sendrecv.py", line 603, in sniff
    r = prn(p)
  File "/root/Desktop/PythonForH/src/Packet_sniffer/packet_sniffer.py", line 18, in sniff_callback
    print(Fore.BLUE + Style.BRIGHT + "HTTP Packet             : " + Fore.RED + Style.BRIGHT + str(packet[3]))
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy/packet.py", line 289, in __str__
    return repr(bytes(self)) 
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy/packet.py", line 291, in __bytes__
    return self.build()
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy/packet.py", line 359, in build
    p = self.do_build()
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy/packet.py", line 351, in do_build
    pay = self.do_build_payload()
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy/packet.py", line 343, in do_build_payload
    return self.payload.do_build()
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy/packet.py", line 348, in do_build
    pkt = self.self_build()
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy_http/http.py", line 179, in self_build
    return _self_build(self, field_pos_list)
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy_http/http.py", line 101, in _self_build
    val = _get_field_value(obj, f.name)
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy_http/http.py", line 74, in _get_field_value
    headers = _parse_headers(val)
  File "/root/Desktop/PythonForH/venv/lib/python3.7/site-packages/scapy_http/http.py", line 18, in _parse_headers
    headers = s.split("\r\n")
TypeError: a bytes-like object is required, not 'str'

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

Successfully merging this pull request may close these issues.

TypeError: a bytes-like object is required, not 'str'
2 participants