Suggestion for Enhancing Documentation: Adding Details and Examples for the Name Class
Closed this issue ยท 3 comments
First and foremost, I want to extend my congratulations on this incredible library! I've been using pyobfuscator to obfuscate my Python code, and I'm impressed with its effectiveness and user-friendliness.
However, while exploring the documentation, I noticed there could be a small improvement, especially regarding the Name class. The current documentation, although clear, could benefit from some additional practical examples to help the community better understand how the Name class works. For instance, it would be interesting to know if it's possible to dynamically modify imports when there are two obfuscated files that import functions, variables, or classes from each other. Specifically, more details on the namespace_name and is_defined parameters would be appreciated.
Suggestion for Enhancement:
It would be great to see more details and examples in the documentation, especially regarding the syntax and proper use of namespace_name. Perhaps some practical examples in different scenarios, such as within a specific class or function, would make the documentation even more valuable.
I'm excited about the ongoing potential of this incredible library, and I believe these adjustments to the documentation could make it even more accessible and useful for the community.
Thank you so much for your hard work and attention to this suggestion. I'm looking forward to seeing PyObfuscator achieve even greater success!
Thanks @wendelgomesdev for opening this issue.
I will work on documentations and examples.
First i will train to explain here some details about the Name
class. I will update the documentation in second time.
The is_defined
argument is used to define if an attribute should be obfuscated. I write a little example:
Code:
from threading import Thread
Thread(target=print).start()
def start():
print("start")
Thread(target=start).start()
Configuration:
from PyObfuscator import Obfuscator, Name
Obfuscator(
"test.py",
"obfu.py",
1,
{"start": Name("start", "start_obfu", False, None)},
True,
).default_obfuscation()
Obfuscator(
"test.py",
"obfu2.py",
1,
{"start": Name("start", "start_obfu", True, None)},
True,
).default_obfuscation()
- In the first case with the
is_defined
set toFalse
the firstThread.start
will no be obfuscated, the second will be obfuscated because the functionstart
will defined thestart
name in this file. - In the second case with the
is_defined
set toTrue
the firstThread.start
will be obfuscated and the second too.
First case obfuscation:
... # imports initialization
GyMj1VQxCHCq, = (oogmSQDvptU0(afSgkw6LC0fD('threading', 'Thread'), 'Thread'),)
oogmSQDvptU0(Thread(target=print), 'start')()
def start_obfu():
d9FDXKC0yxSD('start')
oogmSQDvptU0(Thread(target=start), 'start_obfu')()
Second case obfuscation:
... # imports initialization
nrp3Hk7u_OCY, = (SbacsnPNpGyu(ail8cmsN8wHI('threading', 'Thread'), 'Thread'),)
SbacsnPNpGyu(Thread(target=print), 'start_obfu')()
def start_obfu():
wnIdMRsWNTah('start')
SbacsnPNpGyu(Thread(target=start), 'start_obfu')()
This argument can help you to bypass some bugs when you use a same name (like start
) for an obfuscated element and a non obfuscated element. This example described in the documentation come from the issue #8 . This argument/attribute should probably set to False
by default. I think this behavior can be improved with the namespace to define if the FunctionDef
is a method or function to define better when an attribute should be obfuscate and solve the precedent example and the issue #8, but is not a perfect fix.
The namespace_name
argument is used for de-obfuscation and debugging, i think it can be useful in future development to improve obfuscation and solve bugs. This arguments doesn't have any impact on obfuscated program yet.
Since version 0.1.8 (last version and last commit), the is_defined
is replaced by is_attribute
and should be False
by default. The only case where it should be to True
is: when it's defined and obfuscate as attribute in other file (useful to obfuscate multiples files). The namespace_name
is used to set the is_attribute
in variable name definition, namespace_name
should not be used in obfuscation configuration.