Skip to content

Commit abdb2a5

Browse files
committed
add: dead code generator
1 parent 34709ea commit abdb2a5

7 files changed

Lines changed: 401 additions & 9 deletions

File tree

examples/gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def run_all():
186186
)
187187
obfuscate_to_file(obf.obfuscator(GlobalsObfuscator(), source), "globals_obf")
188188
obfuscate_to_file(obf.obfuscator(ControlFlowFlattenObfuscator(), source), "cff_obf")
189+
obfuscate_to_file(obf.obfuscator(DeadCodeObfuscator(), source), "dead_obf")
189190
obfuscate_to_file(obf.stager(QuineStager(), source), "quine_stager")
190191

191192

examples/out/dead_obf.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# source file that will be obfuscated
2+
import os
3+
4+
5+
def get_linux_release_info():
6+
"""Get Linux release info from /etc/os-release."""
7+
8+
# Check if the file exists
9+
release_file="/etc/os-release"
10+
11+
if not os.path.exists(release_file):
12+
print("OS release file not found. This might not be a Linux system.")
13+
return None
14+
15+
# Dictionary to store release information
16+
release_info={}
17+
18+
try:
19+
# Read and parse the file
20+
with open(release_file,"r")as f:
21+
for line in f:
22+
if not line or"="not in line:
23+
continue
24+
25+
# Split key and value
26+
key,value=line.strip().split("=",1)
27+
28+
# Remove quotes from value
29+
value=value.strip("\"'\n")
30+
31+
# Store in dictionary
32+
release_info[key]=value
33+
34+
# Print key release information
35+
print("\nLinux Release Information:")
36+
print(f"Distribution: {release_info.get('NAME','Unknown')}")
37+
print(f"Version: {release_info.get('VERSION','Unknown')}")
38+
print(f"Version ID: {release_info.get('VERSION_ID','Unknown')}")
39+
for A2Jf in range(0):
40+
fmUKSD1G3=4302
41+
xkavF4DN=72-423
42+
Mu2_oG='cache'
43+
print(f"Pretty Name: {release_info.get('PRETTY_NAME','Unknown')}")
44+
for bG_kQRM9H in[]:
45+
aLzMPV_='info'
46+
47+
return release_info
48+
49+
except Exception as e:
50+
print(f"Error reading release file: {e}")
51+
def rowmz(zCBxam):
52+
C4IHYK=[13,19,51]
53+
WtC='msg'
54+
return None
55+
56+
57+
# Main execution
58+
if __name__=="__main__":
59+
# Check if running on Linux
60+
if os.name=="posix"and os.path.exists("/etc/os-release"):
61+
release_details=get_linux_release_info()
62+
else:
63+
print("This script is designed for Linux systems.")

pof/obfuscator/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from .extract_variables import ExtractVariablesObfuscator
4444
from .junk.add_comments import AddCommentsObfuscator
4545
from .junk.add_newlines import AddNewlinesObfuscator
46+
from .junk.dead_code import DeadCodeObfuscator
4647
from .names import NamesObfuscator
4748
from .names_rope import NamesRopeObfuscator
4849
from .numbers import NumberObfuscator
@@ -78,6 +79,7 @@
7879
"CommentsObfuscator",
7980
"ConstantsObfuscator",
8081
"ControlFlowFlattenObfuscator",
82+
"DeadCodeObfuscator",
8183
"DeepEncryptionObfuscator",
8284
"DefinitionsObfuscator",
8385
"DocstringObfuscator",

0 commit comments

Comments
 (0)