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

uncompyle6 can cause exception #304

Open
kam193 opened this issue Jan 17, 2025 · 0 comments
Open

uncompyle6 can cause exception #304

kam193 opened this issue Jan 17, 2025 · 0 comments
Assignees
Labels
assess We still haven't decided if this will be worked on or not bug Something isn't working service-extract

Comments

@kam193
Copy link

kam193 commented Jan 17, 2025

Describe the bug
I've come across an exception from Extractor trying to decompile a PYC file. It looks like some files may cause an exception in uncompyle that isn't handled and/or processed by the alternative decompiler.

To Reproduce
When processing this file: tools.cpython-38.pyc.zip (pass: zippy)

there was an exception generated:

 File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/assemblyline_v4_service/common/base.py", line 181, in handle_task
    self.execute(request)
  File "/opt/al_service/extract/extract.py", line 423, in execute
    extracted = self.extract_pyc(request, request.file_path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/al_service/extract/extract.py", line 2610, in extract_pyc
    py_file, embedded_filename = py_uncompyle6.decompile_pyc(filepath, self.working_directory)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/al_service/extract/ext/py_uncompyle6.py", line 98, in decompile_pyc
    _ = uncompyle6.main.main(
        ^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/main.py", line 340, in main
    deparsed_objects = decompile_file(
                       ^^^^^^^^^^^^^^^
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/main.py", line 243, in decompile_file
    decompile(
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/main.py", line 163, in decompile
    deparsed = deparse_fn(
               ^^^^^^^^^^^
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 1413, in code_deparse
    deparsed.gen_source(
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 1183, in gen_source
    self.text = self.traverse(ast, is_lambda=is_lambda)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 458, in traverse
    self.preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 117, in preorder
    self.preorder(kid)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 117, in preorder
    self.preorder(kid)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/customize35.py", line 230, in n_function_def
    self.default(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 896, in default
    self.template_engine(table[key.kind], node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 790, in template_engine
    self.preorder(node[index])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 1059, in n_mkfunc
    self.make_function(node, is_lambda=False, code_node=code_node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 554, in make_function
    make_function36(self, node, is_lambda, nested, code_node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/make_function36.py", line 354, in make_function36
    self.gen_source(
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 1183, in gen_source
    self.text = self.traverse(ast, is_lambda=is_lambda)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 458, in traverse
    self.preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 117, in preorder
    self.preorder(kid)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 85, in n_assign
    self.default(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 896, in default
    self.template_engine(table[key.kind], node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 819, in template_engine
    self.preorder(node[index])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 702, in n_expr
    self.preorder(node[0])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 117, in preorder
    self.preorder(kid)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 823, in n_lambda_body
    self.make_function(node, is_lambda=True, code_node=node[-2])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 554, in make_function
    make_function36(self, node, is_lambda, nested, code_node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/make_function36.py", line 354, in make_function36
    self.gen_source(
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 1183, in gen_source
    self.text = self.traverse(ast, is_lambda=is_lambda)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 458, in traverse
    self.preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 117, in preorder
    self.preorder(kid)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 1105, in n_return_expr_lambda
    self.preorder(node[0])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 1087, in n_return_expr
    self.n_expr(node[0])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 702, in n_expr
    self.preorder(node[0])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/customize37.py", line 405, in n_call
    self.template_engine(
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 819, in template_engine
    self.preorder(node[index])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 117, in preorder
    self.preorder(kid)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 702, in n_expr
    self.preorder(node[0])
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/pysource.py", line 436, in preorder
    super(SourceWalker, self).preorder(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 110, in preorder
    func(node)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/n_actions.py", line 721, in n_generator_exp
    self.closure_walk(node, collection_index=4)
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/uncompyle6/semantics/gencomp.py", line 56, in closure_walk
    store = tree[3]
            ~~~~^^^
  File "/var/lib/assemblyline/.local/lib/python3.11/site-packages/spark_parser/ast.py", line 23, in __getitem__
    return self.data[i]
           ~~~~~~~~~^^^
IndexError: list index out of range

Expected behavior
Any error in uncompyle6 triggers processing by Decompyle++ without breaking the service.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information if pertinent):

  • Assemblyline Version: 4.5.0.67, Extract 4.5.0.58

Additional context
Add any other context about the problem here.

@kam193 kam193 added assess We still haven't decided if this will be worked on or not bug Something isn't working labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assess We still haven't decided if this will be worked on or not bug Something isn't working service-extract
Projects
None yet
Development

No branches or pull requests

3 participants