rocky / rocky/python-xdis

Dissasembling failing in xasm format

Open
#93 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
371
Forks
106
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm currently trying to extract the bytecode, edit a few strings and assemble it back to a .pyc file.
Pydisasm without any flags work just fine but as soon as I try to dissamble the file with Pydisasm -F xasm ./file.pyc it fails with the following traceback:

Traceback (most recent call last):
  File "/usr/local/bin/pydisasm", line 33, in <module>
    sys.exit(load_entry_point('xdis', 'console_scripts', 'pydisasm')())
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/root/python-xdis/xdis/bin/pydisasm.py", line 72, in main
    disassemble_file(path, sys.stdout, format)
  File "/root/python-xdis/xdis/disasm.py", line 329, in disassemble_file
    disco(
  File "/root/python-xdis/xdis/disasm.py", line 160, in disco
    disco_loop_asm_format(opc, version_tuple, co, real_out, {}, set([]))
  File "/root/python-xdis/xdis/disasm.py", line 220, in disco_loop_asm_format
    disco_loop_asm_format(
  File "/root/python-xdis/xdis/disasm.py", line 220, in disco_loop_asm_format
    disco_loop_asm_format(
  File "/root/python-xdis/xdis/disasm.py", line 249, in disco_loop_asm_format
    assert mapped_name not in fn_name_map
AssertionError

I also printed out the vars from the assert:

mapped_name='listcomp_0x7f3d301932f0'

fn_name_map={'listcomp_0x7f3d30192ff0': 'listcomp', 'listcomp_0x7f3d301932f0': 'listcomp'}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with pydisasm -F xasm ./file.pyc, then inspect xdis/disasm.py, especially disassemble_file and disco_loop_asm_format around the recursive call and assertion. Check how duplicate listcomp names enter fn_name_map; done means the xasm disassembly completes without the reported AssertionError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.