kitty icon indicating copy to clipboard operation
kitty copied to clipboard

TypeError: Object of type bytes is not JSON serializable

Open winux138 opened this issue 3 years ago • 1 comments

nccgroup/umap2 is a USB assessment tool, and they are using the kitty engine to fuzz USB host.

The issue I encounter is the following, I can't access any report, they all have the label "trigger timed out", and when I access the detail for a report I get an alert window with "Failed to load report" while in the console running the kitty engine (and the web server I guess) I get the following message :

Exception occurred during processing of request from ('127.0.0.1', 35804)
Traceback (most recent call last):
  File "/usr/lib64/python3.10/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib64/python3.10/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib64/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 72, in __init__
    BaseHTTPRequestHandler.__init__(
  File "/usr/lib64/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib64/python3.10/http/server.py", line 432, in handle
    self.handle_one_request()
  File "/usr/lib64/python3.10/http/server.py", line 420, in handle_one_request
    method()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 116, in do_GET
    self._my_handle()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 261, in _my_handle
    response = endpoints[endpoint]()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 199, in _handle_api_request
    response = self._get_report()
  File "/usr/local/lib/python3.10/site-packages/kittyfuzzer-0.7.4-py3.10.egg/kitty/interfaces/web.py", line 234, in _get_report
    return json.dumps(response)
  File "/usr/lib64/python3.10/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib64/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib64/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type bytes is not JSON serializable

I think the issue is related to kitty rather than umap2, but I might be wrong, in that case let me know and I will close the issue.

If you need additional information let me know, I will do my best to provide them.

winux138 avatar Sep 30 '22 12:09 winux138

After some digging, here are some update

In data/report.py, the method to_dict has a loop to iterate over every item and convert every byte array encountered to a string. The issue is, it is not recursive. If an item is a list of byte array, it will remain so, causing an issue later on.

I will clean up my implementation and submit a PR later on.

winux138 avatar Oct 07 '22 08:10 winux138