Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #14

Merged
merged 8 commits into from
Sep 18, 2023
Merged

Dev #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ In the above example, the directories `cars` and `mlos` are excluded from the se

FivemCipherFinder logs the found ciphers in a file named `CipherLog-HH-MM-SS.txt`, making it easy to review the results.

**Keep in mind**
- The CipherFinder can't find 100% of maybe placed ciphers.
- Should you use a Code Formatter, it's possible when you use the Deletion function, that your scripts can fail to start bc of syntax errors.


## Troubleshooting

If you encounter any issues with FivemCipherFinder, here are some troubleshooting steps you can follow:
Expand Down
1 change: 0 additions & 1 deletion big.model

This file was deleted.

2 changes: 2 additions & 0 deletions cipherFinder/de_obfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
"uber",
"deez",
"nuts",
"jugz",
"hell",
"gyros",
"fries",
"towlie",
"things",
]

TABLE_REGEX = r"(\{([^{}]+)\})"
Expand Down
40 changes: 40 additions & 0 deletions cipherFinder/deleter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
def y_n_validator(x): return x.lower() in {"y", "yes"}

# plan
# Getting a list of all potential cipher lines, so we can remove them.

# did we execute the plan? I think we did.


def deleter_main(del_lines: list) -> int:
""" This function works as the entry point for the
cipher deletion process.

Parameters
----------
del_lines : list
the shadow list thats getting created in the main file.

Returns
-------
int
Return code
"""

# Loop over found ciphers and ask the user if they
# want to remove the line
for cipher, ln, path in del_lines:
if not y_n_validator(input( # pylint: disable=bad-builtin
f"Do you want to delete the following line?: "
f"\n{cipher}\n[y/N]: ")):
continue

with open(path, "r", encoding="utf-8") as f:
lines = f.readlines()

del lines[ln - 1]

with open(path, "w", encoding="utf-8") as f:
f.writelines(lines)

return 0
35 changes: 25 additions & 10 deletions cipherFinder/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from gibberish_detector import detector

from cipherFinder.de_obfs import de_obfs, do_regex
from cipherFinder.deleter import deleter_main, y_n_validator

REGEX = r"(((\\x|\\u)([a-fA-F0-9]{2}))+)"
URL_REGEX = (
Expand All @@ -43,7 +44,9 @@
"FivemCipherFinder/main/big.model"
)


log = []
del_lines = []


def get_big_model_file() -> int:
Expand All @@ -55,6 +58,8 @@ def get_big_model_file() -> int:
status code

"""

# Get a fresh file
if os.path.exists("./big.model"):
os.remove("./big.model")

Expand Down Expand Up @@ -137,13 +142,13 @@ def prepare_log_line(**kw) -> int:
int
Returns the current count
"""
d = kw.pop("d", ".")
ln = kw.pop("ln", "")
file = kw.pop("file", "poggers.lua")
line = kw.pop("line", "")
count = kw.pop("count", 0)
target = kw.pop("target", "")
logged = kw.pop("logged", {})
d = kw.pop("d", ".") # Directory
ln = kw.pop("ln", "") # Triggered line number
file = kw.pop("file", "poggers.lua") # filename
line = kw.pop("line", "") # Trigger line
count = kw.pop("count", 0) # global trigger count
target = kw.pop("target", "") # Decoded lines
logged = kw.pop("logged", {}) # dont print stuff twice

path = d.replace("\\", "/") + f"/{file}"
url = ""
Expand All @@ -166,6 +171,9 @@ def prepare_log_line(**kw) -> int:
print(to_log)

log.append(to_log + f"\nTrigger Line:\n{line!r}\n{'-'*15}\n")

del_lines.append((line, ln, path))

count += 1
logged[path] = ln
return count
Expand Down Expand Up @@ -241,11 +249,11 @@ def write_log_file(**kw) -> int:
print(
f'{kw.pop("red")}Oh no, the program found a spy in your files x.x '
f"Check the CipherLog.txt for location and trigger. "
f'{kw.pop("count")} where found!'
f'{kw.pop("count")} were found!'
f'{kw.pop("white")}\n#staysafe'
)

if kw.pop("args").no_log:
if kw.pop("args").no_log: # if the user types -n
return 0

with open(
Expand Down Expand Up @@ -367,6 +375,7 @@ def main() -> int:
get_big_model_file()

for d, _, files in os.walk(local_path):
# skip excluded directorys
if pattern and do_regex(rf"{d}", f'{"(" + pattern + ")"}'):
continue

Expand All @@ -389,7 +398,13 @@ def main() -> int:
pass

if log:
return write_log_file(white=white, red=red, count=count, args=args)
write_log_file(white=white, red=red, count=count, args=args)

if y_n_validator(input( # pylint: disable=bad-builtin
"Do you want to start the Deletion wizard? [y/N] ")):
deleter_main(del_lines)

return 0

print(f"{green}Nice! There were no Cipher's found!{white}")
return 0
Expand Down
2 changes: 2 additions & 0 deletions tests/test_deleter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_deleter_main(): # yeah, naaahhh
...