buffer / thug

Python low-interaction honeyclient
GNU General Public License v2.0
967 stars 204 forks source link

TypeError: a bytes-like object is required, not 'str' #335

Closed brian-foley closed 1 year ago

brian-foley commented 1 year ago

https://github.com/buffer/thug/blob/f70114c5b4933e72650b7fb197f18b76b72a835e/thug/Logging/modules/MongoDB.py#L467

Received error message "TypeError: a bytes-like object is required, not 'str'" while running thug on webserver running GlobalLink 2.7.0.8 - ConnectAndEnterRoom ActiveX Control Stack Buffer Overflow exploit. Error is seen here: thug problem

I changed the code to: base64.b64encode(snippet.encode("ascii")).decode("ascii") and it seems to resolve the error. I'm not sure if this will break any other functionality.

buffer commented 1 year ago

Thanks for reporting it. Can you try the following patch and confirm it fixes the issue?

base64.b64encode(snippet.encode() if isinstance(snippet, str) else snippet)

brian-foley commented 1 year ago

This patch fixes the issue. Thanks for the timely response!