rocky / rocky/python-xdis

Warn or fix whitespace in variable names

Open
#58 2 comments 1 reaction 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

Continuing the discussion from here: https://github.com/rocky/python-uncompyle6/issues/312

@rocky directed me to post here instead.

It's possible to easily fool a lot of decompilers by renaming variables to names containing whitespace. For example, running this little script:

$ git clone https://github.com/ZetaTwo/python-obfuscator
$ cd python-obfuscator
$ ./test.sh

Will demonstrate how uncompyle6 can be tricked into decompiling the bytecode into valid code that does not reflect the actual bytecode.

My proposal is to add a small check that will at least warn about the presence of variables with invalid names and possinly even replace the invalid characters with for example "_".

I'm willing to make a PR with these changes but I would first just like to hear if I'm in the right place and if you have opinions on where/how this should be implemented?

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

Start with the linked discussion and reproduce the behavior using the python-obfuscator repository and its ./test.sh script. Then trace how python-xdis handles variable names during bytecode disassembly; done means invalid whitespace-containing names are warned about or replaced, with the obfuscator example no longer producing misleading output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 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.