-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
TypeError: can't concat str to bytes #1819
Comments
Hi, could you provide some context on how you got that raw ip packet? |
The code is designed to handle cases where the packet length (packetlen) does not match the expected fixed size (hdr_len). When the provided aBuffer is shorter than hdr_len, the code attempts to pad aBuffer with additional bytes by appending '\x00'. This padding is meant as an error handling step to ensure aBuffer reaches the required length. However, this approach is causing a crash because aBuffer is a byte string, and appending '\x00' (a regular string) results in a TypeError, as you can't concatenate a string to a byte object. To fix this, we need to change '\x00' to b'\x00' so that aBuffer is padded with bytes instead of a regular string. Here's how the modified code would look:
|
Nice catch! I'm creating a PR with this fix. |
#1851 solved this issue |
closing this one |
Configuration
impacket version: Impacket v0.12.0
Python version: Python 3.10.12
Target OS: Linux ubuntu
Debug Output With Command String
Raw IP packet: b'o\x05\x05\x05\x05\x05\x05\x05\x05\x01\x05s\x05\x05\x05\x05q\x03\x05\x05\x05\x05p\x01\x05\x05'
Traceback (most recent call last):
File "/home/youwei/XDiff/Impacket/IP.py", line 22, in
ip_packet = decoder.decode(Ip_packet)
File "/home/youwei/.local/share/pipx/venvs/impacket/lib/python3.10/site-packages/impacket/ImpactDecoder.py", line 191, in decode
ip6_packet = IP6.IP6(buffer)
File "/home/youwei/.local/share/pipx/venvs/impacket/lib/python3.10/site-packages/impacket/IP6.py", line 32, in init
self.load_header(buffer)
File "/home/youwei/.local/share/pipx/venvs/impacket/lib/python3.10/site-packages/impacket/ImpactPacket.py", line 435, in load_header
aBuffer += '\x00'
TypeError: can't concat str to bytes
The text was updated successfully, but these errors were encountered: