-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update doc, refactor for code quality
- Loading branch information
1
committed
Aug 23, 2023
1 parent
31f5d40
commit e709e43
Showing
24 changed files
with
336 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Pof examples | ||
|
||
In this directory you'll find 2 files, the source and then generator file. The source file `source.py` contains the Python source file to obfuscate, and the generator file `gen.py` contain the obfuscator code. All outputs are produce to the `out/` directory. | ||
|
||
This is useful to test pof, get a feel for the Python API, and how to use it, but also with some outputs and test the result. | ||
|
||
Note that you'll need to install pof first. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import pathlib | ||
|
||
import pof | ||
|
||
|
||
class ExampleObfuscator(pof.BaseObfuscator): | ||
def constant_obf(self, source): | ||
tokens = self._get_tokens(source) | ||
tokens = pof.obfuscator.ConstantsObfuscator().obfuscate_tokens(tokens) | ||
return self._untokenize(tokens) | ||
|
||
|
||
def obfuscate_to_file(obf_class, func_name, source): | ||
out = getattr(obf_class, func_name)(source) | ||
file_name = func_name + ".py" | ||
file = pathlib.Path(__file__).parent / "out" / file_name | ||
with file.open("w") as f: | ||
f.write(out) | ||
|
||
|
||
def run_all(): | ||
obf = ExampleObfuscator() | ||
|
||
file = pathlib.Path(__file__).parent / "source.py" | ||
with file.open() as f: | ||
source = f.read() | ||
|
||
obfuscate_to_file(obf, "constant_obf", source) | ||
|
||
|
||
if __name__ == "__main__": | ||
run_all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
TB_="My pet is name: " | ||
LoIC1lyQ=1 | ||
Mm9IyM=print | ||
tkBdI=8 | ||
B6iSi8_=range | ||
# source file that will be obfuscated | ||
import random | ||
import string | ||
|
||
|
||
def get_random_letter(): | ||
"""This is a docstring.""" | ||
return random.choice(string.ascii_lowercase) | ||
|
||
|
||
def get_random_name(name_len): | ||
# this is a comment | ||
name=get_random_letter().upper() | ||
for _ in B6iSi8_(name_len-LoIC1lyQ): | ||
name+=get_random_letter() | ||
return name | ||
|
||
|
||
def present_my_pet(): | ||
pet_name=get_random_name(tkBdI) | ||
message=TB_+pet_name | ||
Mm9IyM(message) | ||
|
||
|
||
present_my_pet() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# source file that will be obfuscated | ||
import random | ||
import string | ||
|
||
|
||
def get_random_letter(): | ||
"""This is a docstring.""" | ||
return random.choice(string.ascii_lowercase) | ||
|
||
|
||
def get_random_name(name_len): | ||
# this is a comment | ||
name = get_random_letter().upper() | ||
for _ in range(name_len - 1): | ||
name += get_random_letter() | ||
return name | ||
|
||
|
||
def present_my_pet(): | ||
pet_name = get_random_name(8) | ||
message = "My pet is name: " + pet_name | ||
print(message) | ||
|
||
|
||
present_my_pet() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.