davidteather / python-obfuscator

I got tired of writing good code so I made good code to make bad code
MIT License
151 stars 33 forks source link

Obfuscation changes __name__ variable name #14

Open joaopfg opened 2 years ago

joaopfg commented 2 years ago

I am trying to obfuscate a very simple file like the following:

from file1 import f1
from file2 import f2

if __name__ == "__main__":
    f1()
    f2()
    print("f3")

The __name__ variable name is converted to a garbage string and it avoids the program to run. Any idea where is the bug ? I can try a PR.

billythegoat356 commented 2 years ago

It seems to me that the vars are renamed with a regex, so you would have to fully change how the script works. Renaming vars with a regex results in a lot of bugs, you should try tokenize or ast.