Initial commit

This commit is contained in:
unknown
2026-06-06 01:22:00 +02:00
commit f07fa412f0
132 changed files with 22246 additions and 0 deletions

160
Rose-Obfv2/.gitignore vendored Normal file
View File

@@ -0,0 +1,160 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

21
Rose-Obfv2/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 gumbobr0t
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

166
Rose-Obfv2/README.md Normal file

File diff suppressed because one or more lines are too long

285
Rose-Obfv2/obfuscate.py Normal file
View File

@@ -0,0 +1,285 @@
__name__ = "rose_obfuscator"
__author__ = "gumbobr0t"
__version__ = "1.0.3"
from logging import INFO, DEBUG, getLogger, Formatter, FileHandler
from ast import (
parse,
unparse,
walk,
Name,
Assign,
ClassDef,
FunctionDef,
AsyncFunctionDef,
)
from random import choice
from string import ascii_letters, ascii_uppercase, digits, punctuation
from os import path, getcwd
from re import sub
from lzma import compress, decompress
from argparse import ArgumentParser
from colorlog import StreamHandler, ColoredFormatter
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.backends import default_backend
from base64 import urlsafe_b64encode, urlsafe_b64decode
log_format = "%(asctime)s [%(levelname)s] [%(module)s.%(funcName)s] %(message)s"
handler = StreamHandler()
handler.setFormatter(ColoredFormatter(log_format))
handler.setLevel(INFO)
file_handler = FileHandler("rose-obf.log", encoding="utf-8")
file_handler.setLevel(DEBUG)
file_formatter = Formatter(log_format)
file_handler.setFormatter(file_formatter)
root_logger = getLogger()
root_logger.addHandler(handler)
root_logger.addHandler(file_handler)
root_logger.setLevel(DEBUG)
def generate_key(length=16):
characters = ascii_letters + punctuation
key = "".join(choice(characters) for _ in range(length))
return key
def generate_random_string(length):
characters = ascii_uppercase + digits
return "".join(choice(characters) for _ in range(length))
def getCustom():
dec = choice([1, 2, 3])
if dec == 1:
return generate_pattern1()
elif dec == 2:
return generate_pattern2()
elif dec == 3:
return generate_pattern3()
def generate_pattern1():
return "__" + "".join(choice("O0") for _ in range(10))
def generate_pattern2():
return "__" + "".join(choice("0123456789") for _ in range(10)) + "__"
def generate_pattern3():
return "".join(choice("Il") for _ in range(15)) + "I"
def encryptData(text, key):
cipher = Cipher(algorithms.AES(key), modes.ECB(), backend=default_backend())
encryptor = cipher.encryptor()
padder = padding.PKCS7(128).padder()
padded_data = padder.update(text.encode()) + padder.finalize()
ciphertext = encryptor.update(padded_data) + encryptor.finalize()
return urlsafe_b64encode(ciphertext).decode()
def decryptData(ciphertext, key):
cipher = Cipher(algorithms.AES(key), modes.ECB(), backend=default_backend())
decryptor = cipher.decryptor()
decrypted_data = (
decryptor.update(urlsafe_b64decode(ciphertext)) + decryptor.finalize()
)
unpadder = padding.PKCS7(128).unpadder()
unpadded_data = unpadder.update(decrypted_data) + unpadder.finalize()
return unpadded_data.decode()
def process_node(node, name_dict):
if isinstance(node, Name) and node.id in name_dict:
node.id = name_dict[node.id]
def obfuscate_code(input_file):
with open(input_file, "r", encoding="utf-8", errors="ignore") as f:
content = f.read()
content = sub(r"\n\s*\n", "\n", content)
tree = parse(content)
name_dict = {}
root_logger.info(
"Renaming Classes, Functions, Arguments, Keyword Arguments and Variables..."
)
for node in walk(tree):
if isinstance(node, (FunctionDef, AsyncFunctionDef)):
old_name = node.name
new_name = getCustom()
root_logger.debug(
f"Function Name: {old_name} ---> New Function Name: {new_name}"
)
name_dict[old_name] = new_name
node.name = new_name
for arg in node.args.args:
old_arg_name = arg.arg
new_arg_name = getCustom()
root_logger.debug(
f"Argument Name: {old_arg_name} ---> New Argument Name: {new_arg_name}"
)
name_dict[old_arg_name] = new_arg_name
arg.arg = new_arg_name
for keyword in node.args.kwonlyargs:
old_kwarg_name = keyword.arg
new_kwarg_name = getCustom()
root_logger.debug(
f"Keyword Argument Name: {old_kwarg_name} ---> New Keyword Argument Name: {new_kwarg_name}"
)
name_dict[old_kwarg_name] = new_kwarg_name
keyword.arg = new_kwarg_name
elif isinstance(node, ClassDef):
old_name = node.name
new_name = getCustom()
root_logger.debug(f"Class Name: {old_name} ---> New Class Name: {new_name}")
name_dict[old_name] = new_name
node.name = new_name
for node in walk(tree):
if isinstance(node, Assign):
for target in node.targets:
if isinstance(target, Name):
old_var_name = target.id
new_var_name = getCustom()
root_logger.debug(
f"Variable Name: {old_var_name} ---> New Variable Name: {new_var_name}"
)
name_dict[old_var_name] = new_var_name
target.id = new_var_name
process_node(node, name_dict)
root_logger.info(
"Renaming of classes, functions, arguments, keyword arguments and variables done."
)
return unparse(tree)
key = [ord(char) for char in generate_key()]
decryptionFun = getCustom()
ciphertextParam = getCustom()
base64decodeVar = getCustom()
lzmadecompressVar = getCustom()
keyVar = getCustom()
cipherVar = getCustom()
decryptorVar = getCustom()
decrypted_textVar = getCustom()
unpadderVar = getCustom()
unpadded_dataVar = getCustom()
def replace_string(match):
s = match.group(1)
encrypted_string = encryptData(s, bytes(key))
encrypted_string = encrypted_string.replace("'", r"\'")
chr_format = "+".join([f"chr({ord(char)})" for char in repr(encrypted_string)])
b_format = [ord(char) for char in encrypted_string]
stage_1 = f"{decryptionFun}(eval({base64decodeVar}({urlsafe_b64encode(f'bytes({b_format})'.encode('utf-8'))})).decode(\"utf-8\"))"
stringified_stage_1 = str(urlsafe_b64encode(stage_1.encode("utf-8")))
stage_2 = f'eval({base64decodeVar}({stringified_stage_1}).decode("utf-8"))[1:-1]'
decrypted_string = decryptData(encrypted_string, bytes(key))
root_logger.debug(
f"String: {s} ---> Encrypted String: {encrypted_string} ---> Char Encrypted String: {chr_format} ---> Bytes Encrypted String: {b_format} ---> Evalized encoded string: {stage_2} ---> Aes Decrypted String: {decrypted_string}"
)
return stage_2
def obfuscate_strings(content):
root_logger.info("Encrypting strings...")
data = sub(r"(\'[^\']*\'|\"[^\"]*\")", replace_string, content)
root_logger.info("Encryption of strings done.")
return data
def main(input_file, output_file):
root_logger.debug("Entered main function.")
content = obfuscate_code(input_file)
with open(output_file, "w") as f:
data = "".join(
[
"from cryptography.hazmat.primitives.ciphers import Cipher,algorithms,modes\n",
"from cryptography.hazmat.primitives import padding\n",
"from cryptography.hazmat.backends import default_backend\n",
f"def {decryptionFun}({ciphertextParam}):\n",
f" {keyVar}=bytes({key})\n"
f" {cipherVar}=Cipher(algorithms.AES({keyVar}),modes.ECB(),backend=default_backend())\n",
f" {decryptorVar}={cipherVar}.decryptor()\n",
f" {decrypted_textVar}={decryptorVar}.update({base64decodeVar}({ciphertextParam}))+{decryptorVar}.finalize()\n",
f" {unpadderVar}=padding.PKCS7(128).unpadder()\n",
f" {unpadded_dataVar}={unpadderVar}.update({decrypted_textVar}) + {unpadderVar}.finalize()\n",
f" return {unpadded_dataVar}.decode()\n\n",
obfuscate_strings(content),
]
)
compressed_data = compress(
f'str({base64decodeVar}({urlsafe_b64encode(str(data).encode("utf-8"))}).decode("utf-8"))'.encode(
"utf-8"
)
)
data = f"from base64 import urlsafe_b64decode as {base64decodeVar};from lzma import decompress as {lzmadecompressVar};exec(eval({lzmadecompressVar}({compressed_data})))"
data = (
"""# Obfuscated with Rose\n# github.com/rose-dll\n\n# ^..^ /\n# /_/\_____/\n# /\ /\\\n# / \ / \\\n\n"""
+ data
)
f.write(data)
if __name__ == "rose_obfuscator":
parser = ArgumentParser(
description="Obfuscate Python code efficiently with Rose-obf."
)
parser.add_argument(
"-i",
"--input",
help="Input file name (required, .py)",
dest="in_file",
metavar="<input_file>",
required=True,
)
parser.add_argument(
"-o",
"--output",
help="Output file name",
dest="out_file",
metavar="<output_file>",
required=False,
)
args = parser.parse_args()
input_file = args.in_file
output_file = (
path.join(getcwd(), f"obf-{generate_random_string(10)}.py")
if args.out_file is None
else args.out_file
)
if input_file.endswith(".py"):
try:
root_logger.info(f"{input_file} ---> {output_file}...")
root_logger.debug("Entering main function.")
main(input_file, output_file)
root_logger.info(f"Done. {input_file} ---> {output_file}")
except Exception as e:
root_logger.error(f"Error: {e}")
else:
root_logger.error(
"Invalid Python file entered. Please make sure the file has a .py extension."
)

File diff suppressed because one or more lines are too long

126
Rose-Obfv2/tests/script.py Normal file
View File

@@ -0,0 +1,126 @@
print("hello, world!\nHI")
print("wassup?!?!?!\nHI")
# Dictionaries are a key-value object in Python.
# Like sets, you create them using { and }, but unlike sets, they must be
# created as key-value pairs using the : symbol.
# The values used can be any object.
my_dictionary = {"banana": "$10.00", "cheese": True}
# Access items like with lists, except keys are usually strings.
my_dictionary["banana"] # returns the string '$10.00'
my_dictionary["cheese"] # returns True
# If accessing a key that doesn't exist using [ ], Python raises a KeyError.
# e.g. my_dictionary['optimus'] will raise a KeyError.
# Adding new items.
my_dictionary["optimus"] = "Truck"
# Changing existing items.
my_dictionary["cheese"] = False
# Get all the keys. (used for looping/iterating later on)
my_dictionary.keys()
# Get all the values.
my_dictionary.values()
# Get all the items (key-value pairs)
my_dictionary.items()
# See help(dict) for other methods.
for i in range(1, 10):
print(i)
# A tuple is a read-only data structure for storing collections that
# don't need to be changed. You create one using ( and ) characters.
# Create a tuple with ( and )
my_tuple = (1, 2, "hello", 3.14, False, "hello")
print(type(my_tuple))
# Access an item by index using [ and ]. Indexes start at 0
print(my_tuple[0])
print(my_tuple[3])
# Access a container from right-to-left
print(my_tuple[-1])
print(my_tuple[-3])
# Count number of items in a tuple
my_tuple.count("hello")
my_tuple.count(3.14)
my_tuple.count("blahblah")
# Search and get the index of an item
my_tuple.index("hello")
my_tuple.index(3.14)
my_tuple.index(False)
# Trying to change the value of an item in a tuple causes an error.
# Warning: If creating a tuple with only 1 item, you need to use this special syntax with a comma.
my_tuple2 = (42,)
type(my_tuple2) # is a 'tuple' type
# If you forget the comma, then Python doesn't create the tuple.
fake_tuple = 42
type(fake_tuple) # is an 'int' type
import random
import math
from functools import reduce
# Define a custom function to calculate factorial recursively
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
# Generate a random list of numbers using list comprehension
random_numbers = [random.randint(1, 100) for _ in range(20)]
# Filter even numbers from the list
even_numbers = list(filter(lambda x: x % 2 == 0, random_numbers))
# Find square roots of all numbers in the list
square_roots = list(map(math.sqrt, random_numbers))
# Calculate the sum of all numbers in the list
total_sum = reduce(lambda x, y: x + y, random_numbers)
# Print the list of random numbers
print("Random numbers:", random_numbers)
# Print the list of even numbers
print("Even numbers:", even_numbers)
# Print the list of square roots
print("Square roots:", square_roots)
# Print the total sum of the numbers
print("Total sum:", total_sum)
# Generate a random dictionary with random keys and values
random_dict = {chr(random.randint(97, 122)): random.randint(1, 100) for _ in range(10)}
# Print the random dictionary
print("Random dictionary:", random_dict)
# Calculate the factorial of a random number
random_number = random.choice(random_numbers)
factorial_result = factorial(random_number)
# Print the factorial result
print("Factorial of {}: {}".format(random_number, factorial_result))