FACT_core
FACT_core copied to clipboard
Binwalk analysis fails because of ParseException during entropy graph drawing
FACT version
latest commit
Environment
ubuntu 24 on Docker
Steps to reproduce
- Analyze 9307037151e8488069e0d4166333803dd5f708c1bcffde15dd1b784dfcb59c0c_67 with binwalk plugin
Observed Behavior
- Exception
Expeced Behavior
- No exception and graph
Installation logs
install.log
PASTE HERE
Backend logs
fact_main_backend.log
[ERROR]: Binwalk analysis on 9307037151e8488069e0d4166333803dd5f708c1bcffde15dd1b784dfcb59c0c_67 failed:
DECIMAL HEXADECIMAL DESCRIPTION
--------------------------------------------------------------------------------
10 0xA Unix path: /sys/class/net/wifi0 -o "${dirs#ath}" = "${dirs}" ];then
Entropy Exception:
Unix path: /sys/class/net/wifi0 -o "${dirs#ath}" = "${dirs}" ];then
^
ParseException: Expected end of text, found '$' (at char 36), (line:1, col:37)
----------------------------------------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/FACT_core/venv/lib/python3.12/site-packages/binwalk/core/module.py", line 595, in main
retval = self.run()
^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/binwalk/modules/entropy.py", line 136, in run
self._run()
File "/opt/FACT_core/venv/lib/python3.12/site-packages/binwalk/modules/entropy.py", line 158, in _run
self.calculate_file_entropy(fp)
File "/opt/FACT_core/venv/lib/python3.12/site-packages/binwalk/modules/entropy.py", line 232, in calculate_file_entropy
self.plot_entropy(fp.name)
File "/opt/FACT_core/venv/lib/python3.12/site-packages/binwalk/modules/entropy.py", line 342, in plot_entropy
fig.savefig(self.output_file, bbox_inches='tight')
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/figure.py", line 3378, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/backend_bases.py", line 2342, in print_figure
self.figure.draw(renderer)
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/artist.py", line 95, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/figure.py", line 3175, in draw
mimage._draw_list_compositing_images(
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 3064, in draw
mimage._draw_list_compositing_images(
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/legend.py", line 726, in draw
bbox = self._legend_box.get_window_extent(renderer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 400, in get_window_extent
bbox = self.get_bbox(renderer)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 367, in get_bbox
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 485, in _get_bbox_and_child_offsets
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 367, in get_bbox
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 512, in _get_bbox_and_child_offsets
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 367, in get_bbox
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 485, in _get_bbox_and_child_offsets
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 367, in get_bbox
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 512, in _get_bbox_and_child_offsets
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/offsetbox.py", line 801, in get_bbox
bbox, info, yd = self._text._get_layout(renderer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/text.py", line 386, in _get_layout
w, h, d = _get_text_metrics_with_cache(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/text.py", line 97, in _get_text_metrics_with_cache
return _get_text_metrics_with_cache_impl(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/text.py", line 105, in _get_text_metrics_with_cache_impl
return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/backends/backend_agg.py", line 230, in get_text_width_height_descent
self.mathtext_parser.parse(s, self.dpi, prop)
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/mathtext.py", line 226, in parse
return self._parse_cached(s, dpi, prop)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/mathtext.py", line 247, in _parse_cached
box = self._parser.parse(s, fontset, fontsize, dpi)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/FACT_core/venv/lib/python3.12/site-packages/matplotlib/_mathtext.py", line 1971, in parse
raise ValueError("\n" + ParseException.explain(err, 0)) from None
ValueError:
Unix path: /sys/class/net/wifi0 -o "${dirs#ath}" = "${dirs}" ];then
^
ParseException: Expected end of text, found '$' (at char 36), (line:1, col:37)
----------------------------------------------------------------------------------------------------
Frontend logs
fact_main_frontend.log
PASTE HERE
Other information
File content:
if [ ! -d /sys/class/net/wifi0 -o "${dirs#ath}" = "${dirs}" ];then
Hi, it seems to me binwalk erroneously thinks /sys/class/net/wifi0 -o "${dirs#ath}" = "${dirs}" ];then
is a path (when it should have ended at /sys/class/net/wifi0
) and tries to use this as a label in matplotlib when generating the entropy graph. Matplotlib then probably tries to interpret this as a latex math string (because of the $
) which obviously doesn't work. This seems to be a bug in binwalk.
Fix hit fork's upstream, need to wait for release and #1209