Skip to content

Commit

Permalink
e
Browse files Browse the repository at this point in the history
  • Loading branch information
exersalza committed Jan 7, 2024
1 parent ebfcee7 commit ffcff9a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 23 additions & 1 deletion cipherFinder/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
_counter = {"failed": 0}
_hooks = {"__blanc": _PluginDummy()}

_args = {"skip": False}


def __update_hooks(new_hooks: dict) -> int:
"""Update the Hook dict because of python can't
Expand Down Expand Up @@ -109,7 +111,15 @@ def validate_lines(lines: list) -> list[tuple]:

for ln, line in enumerate(lines, start=1):
if x := do_regex(line, _REGEX):
ret.append((ln, line, de_obfs(x, line)))
ret.append(
(
ln,
line,
de_obfs(x, line)
if not _args["skip"]
else "Disabled de obfuscation",
)
)

__execute_hook("GetValidatedLines", ret)
return ret
Expand Down Expand Up @@ -413,9 +423,20 @@ def main(arg_list: list) -> int:
help="Get remote plugins to your local environment.",
)

parser.add_argument(
"--no-deobfs",
action="store_true",
help="Don't run the De Obfuscation part, can help when "
"you an MemoryError",
)

args = parser.parse_args(arg_list)
os.environ["DEBUG"] = str(DEBUG)

if not args.path:
print("No Path given to argument -p")
sys.exit(1)

if args.get_remote_plugins:
get_remote_plugins()
return 0
Expand All @@ -438,6 +459,7 @@ def main(arg_list: list) -> int:
]
)
local_path = args.path
_args["skip"] = args.no_deobfs
count = 0

for d, _, files in os.walk(local_path):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ def test_find_encoding():
def test_detect_encoding(tmp_path):
# Create a temporary file with known encoding
p = tmp_path / "temp.txt"
p.write_text("This is a test file with ascii encoding.", encoding="ascii")
p.write_text("This is a test file with utf-8 encoding.", encoding="utf-8")

enc, confidence = detect_encoding(str(p))
assert enc == "ascii"
assert enc == "utf-8"
assert 0 <= confidence <= 1


Expand Down

0 comments on commit ffcff9a

Please sign in to comment.