Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
KingKDot committed Jan 25, 2024
1 parent ca19719 commit 692dc6f
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 25 deletions.
10 changes: 8 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from rich.syntax import Syntax
from rich.text import Text

__version__ = "2.8.1"
__version__ = "2.8.2"


@dataclass
Expand All @@ -51,7 +51,10 @@ def compose(self) -> ComposeResult:

class SomalifuscatorV2(App):
CSS_PATH = "util\\ui\\style.tcss"
BINDINGS = [Binding("d", "toggle_debug", "Toggle Debug")]
BINDINGS = [
Binding("d", "toggle_debug", "Toggle Debug"),
Binding("q", "quit", "Quit"),
]

def on_button_pressed(self, _: Button.Pressed) -> None:
OBF(
Expand All @@ -78,6 +81,9 @@ def action_toggle_debug(self) -> None:
)
self.query_one(RichLog).write(debug_msg)

def action_quit(self) -> None:
self.exit()

def on_print(self, event: Print) -> None:
self.query_one(RichLog).write(Text.from_markup(event.text.strip()))
# ill fix this soon
Expand Down
4 changes: 3 additions & 1 deletion src/util/methods/anti_methods/anti_console.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from util.obfuscation.obf_oneline import Obfuscate_Single

from util.supporting.types import Code_Block


class AntiConsole:
def __init__(self) -> None:
pass

@staticmethod
def main(code: list) -> list:
def main(code: list) -> Code_Block:
"""
Restarts the bat file so there is no console at all (hidden)
"""
Expand Down
23 changes: 20 additions & 3 deletions src/util/methods/common/common.py

Large diffs are not rendered by default.

38 changes: 27 additions & 11 deletions src/util/obfuscation/obf_oneline.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import re
import random

from typing import List, Union
from typing import List, Union, NewType

from util.supporting.settings import Settings
from util.supporting.types import Obfuscated_String

from util.methods.common.common import make_random_string, random_capitalization
from util.methods.custom.decorators.custom_decorators import check_string_length

Expand All @@ -22,7 +24,7 @@ def __init__(
self.out_code = ""

@check_string_length
def out(self) -> str:
def out(self) -> Obfuscated_String:
if Settings.debug:
return self.code
"""returns the desired obfuscated code
Expand All @@ -35,15 +37,19 @@ def out(self) -> str:
for line in self.code:
if "%TO_SCRAMBLE_PLZ%" in line:
line = line.replace("%TO_SCRAMBLE_PLZ%", "")
self.out_code += "%TO_SCRAMBLE_PLZ%" + self.obfuscate_simple(line) + "\n"
self.out_code += (
"%TO_SCRAMBLE_PLZ%" + self.obfuscate_simple(line) + "\n"
)
else:
self.out_code += self.obfuscate_simple(line) + "\n"
return self.out_code
else:
for line in self.code:
if "%TO_SCRAMBLE_PLZ%" in line:
line = line.replace("%TO_SCRAMBLE_PLZ%", "")
self.out_code += "%TO_SCRAMBLE_PLZ%" + self.obfuscate_normal(line) + "\n"
self.out_code += (
"%TO_SCRAMBLE_PLZ%" + self.obfuscate_normal(line) + "\n"
)
else:
self.out_code += self.obfuscate_normal(line) + "\n"
return self.out_code
Expand All @@ -54,7 +60,9 @@ def out(self) -> str:
for line in self.code:
if "%TO_SCRAMBLE_PLZ%" in line:
line = line.replace("%TO_SCRAMBLE_PLZ%", "")
self.out_code += "%TO_SCRAMBLE_PLZ%" + self.obfuscate_simple(line) + "\n"
self.out_code += (
"%TO_SCRAMBLE_PLZ%" + self.obfuscate_simple(line) + "\n"
)
else:
self.out_code += self.obfuscate_simple(line) + "\n"
return self.out_code
Expand All @@ -69,7 +77,9 @@ def out(self) -> str:
for line in self.code:
if "%TO_SCRAMBLE_PLZ%" in line:
line = line.replace("%TO_SCRAMBLE_PLZ%", "")
self.out_code += "%TO_SCRAMBLE_PLZ%" + self.obfuscate_normal(line) + "\n"
self.out_code += (
"%TO_SCRAMBLE_PLZ%" + self.obfuscate_normal(line) + "\n"
)
else:
self.out_code += self.obfuscate_normal(line) + "\n"
return self.out_code
Expand All @@ -79,7 +89,7 @@ def out(self) -> str:
else:
return self.obfuscate_normal(self.code) + "\n"

def obfuscate_normal(self, line: str) -> str:
def obfuscate_normal(self, line: str) -> Obfuscated_String:
if Settings.FUD:
return self.obfuscate_simple(line)
"""Obfuscates code but this method is very simple and made for small lines of code that needs to be obfuscated
Expand Down Expand Up @@ -153,7 +163,9 @@ def obfuscate_normal(self, line: str) -> str:
filtered_lists = [i for i in new_lists if char in i]

if len(filtered_lists) == 0:
final_string += f"{char}%{make_random_string(special_chars=False)}%"
final_string += (
f"{char}%{make_random_string(special_chars=False)}%"
)
continue

new = random.choice(filtered_lists)
Expand All @@ -163,16 +175,20 @@ def obfuscate_normal(self, line: str) -> str:
random_index = random.choice(ammount)
new2 = options[new]
negative_index = random_index - len(new)
final_string += f"%{random_capitalization(new2)}:~{negative_index},1%"
final_string += (
f"%{random_capitalization(new2)}:~{negative_index},1%"
)
else:
ammount = [i for i, letter in enumerate(new) if letter == char]
random_index = random.choice(ammount)
new2 = options[new]
final_string += f"%{random_capitalization(new2)}:~{random_index},1%"
final_string += (
f"%{random_capitalization(new2)}:~{random_index},1%"
)
final_string += " "
return final_string

def obfuscate_simple(self, char_line: str) -> str:
def obfuscate_simple(self, char_line: str) -> Obfuscated_String:
"""Very simple obfuscated method for chars that aren't in any arrays
Args:
Expand Down
8 changes: 5 additions & 3 deletions src/util/obfuscation/obfuscate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from util.supporting.gens import c_val
from util.supporting.settings import log, Settings
from util.supporting.types import Code_Block

from util.methods.anti_methods.anti_changes import AntiChanges
from util.methods.anti_methods.anti_s_screen import AntiSScreen
Expand All @@ -20,8 +21,6 @@

from util.methods.dead_code.dead_code import DeadCode

from textual.widgets import RichLog

letter_assignments_cypher = CaesarCipher.both(c_val.value)

code1 = f"%TO_SCRAMBLE_PLZ%@echo off"
Expand Down Expand Up @@ -104,6 +103,9 @@ def obfuscate(self, file):

with open(self.new_file, "a+", encoding="utf8", errors="ignore") as f:
f.write(random_capitalization("\n::Made by K.Dot using SomalifuscatorV2\n"))
f.write(
"REM \xff\xfeS\x00o\x00m\x00a\x00l\x00i\x00f\x00u\x00s\x00c\x00a\x00t\x00o\x00r\x00 \x00i\x00s\x00 \x00v\x00e\x00r\x00y\x00 \x00c\x00o\x00o\x00l\x00 \x00m\x00y\x00 \x00b\x00r\x00o\x00t\x00h\x00a\x00 \x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00l\x00o\x00l\x00"
)
characters = string.ascii_letters + string.digits
random_order = "".join(random.sample(characters, len(characters)))

Expand Down Expand Up @@ -325,7 +327,7 @@ def write_code_chunk(self, code_chunk: list) -> None:
for array in code_chunk:
f.writelines(array)

def convert_code_chunk_and_write_bytes(self, code_chunk: list) -> None:
def convert_code_chunk_and_write_bytes(self, code_chunk: Code_Block) -> None:
out_hex = ["FF", "FE", "26", "63", "6C", "73", "0D", "0A", "FF", "FE"]

self.write_code_chunk(code_chunk)
Expand Down
24 changes: 19 additions & 5 deletions src/util/obfuscation/scrambler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
from util.obfuscation.obf_oneline import Obfuscate_Single
from util.methods.anti_methods.anti_changes import AntiChanges

from util.methods.common.common import random_semi_and_comma, random_single_carrot, random_capitalization, random_spaces
from util.methods.common.common import (
random_semi_and_comma,
random_single_carrot,
random_capitalization,
random_spaces,
)

from util.supporting.settings import log
from util.supporting.types import Code_Block


class Scrambler:
def __init__(self):
self.scramble_regex = r":[0-9]+"

def scramble(self, code: list, checks: bool = True) -> list:
def scramble(self, code: list, checks: bool = True) -> Code_Block:
"""Take a list or arrays and scramble the ones that can be scrambled. This is the main function for this class.
Args:
Expand Down Expand Up @@ -71,7 +77,10 @@ def full_scramble(self, line: str) -> str:
math_problem = set_command_values[0]

# first value we add in before code this goes to the code and allows it to go back to the normal part of the script
set_command = Obfuscate_Single(f"{random_semi_and_comma()}{random_single_carrot('set')}{Scrambler.random_single_space()}{random_single_carrot('/a')} {random_single_carrot(random_capitalization('ans') + '=')}{math_problem}\n{random_semi_and_comma()}{random_single_carrot(random_capitalization('goto'))} {random_semi_and_comma()} {random_single_carrot(True)}%{random_capitalization('ans')}%\n:{self.escape_label}\n", simple=False).out()
set_command = Obfuscate_Single(
f"{random_semi_and_comma()}{random_single_carrot('set')}{Scrambler.random_single_space()}{random_single_carrot('/a')} {random_single_carrot(random_capitalization('ans') + '=')}{math_problem}\n{random_semi_and_comma()}{random_single_carrot(random_capitalization('goto'))} {random_semi_and_comma()} {random_single_carrot(True)}%{random_capitalization('ans')}%\n:{self.escape_label}\n",
simple=False,
).out()

# first value we add in after code
out_command_values = self.bit_math.generate_math_problem(self.escape_label)
Expand All @@ -80,9 +89,14 @@ def full_scramble(self, line: str) -> str:
lined = f"{line}\n"

if self.checks:
last = Obfuscate_Single(f"set /a ans={math_problem2}\n{self.random_anti_method()}goto %ans%\n", simple=False).out()
last = Obfuscate_Single(
f"set /a ans={math_problem2}\n{self.random_anti_method()}goto %ans%\n",
simple=False,
).out()
else:
last = Obfuscate_Single(f"set /a ans={math_problem2}\ngoto %ans%\n", simple=False).out()
last = Obfuscate_Single(
f"set /a ans={math_problem2}\ngoto %ans%\n", simple=False
).out()
# we make this a array so we can scramble it later and so it won't interfere with any of the other code and stay in its own place
label_code = [second_set_command + lined + last]

Expand Down
5 changes: 5 additions & 0 deletions src/util/supporting/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from typing import NewType
from typing import List

Obfuscated_String = NewType("Obfuscated_String", str)
Code_Block = NewType("Code_Block", List[List[str]])

0 comments on commit 692dc6f

Please sign in to comment.