SpyNote-Keylogger-Parser/SpyNote_parser.py
2023-06-30 14:55:55 +00:00

60 lines
1.7 KiB
Python

import re
from argparse import ArgumentParser, BooleanOptionalAction
def split_text(text):
pattern = r'10250-110251|-110251'
return re.split(pattern, text)
def parse_splittet(text):
if VERBOSE:
print(text)
pattern = r'10250-110251|10251'
out = re.split(pattern, text)
return {"text": out[0], "app": out[1], "time": out[2]}
def write_file(f, out, ignore=False):
if PRINT_CMD:
print(FORMAT_PATTERN.format(**out))
if not ignore:
f.write(FORMAT_PATTERN.format(**out)+"\n")
else:
f.write(out+"\n")
def setup_settings(args):
global VERBOSE
global PRINT_CMD
global FORMAT_PATTERN
VERBOSE = args.v
PRINT_CMD = args.p
FORMAT_PATTERN = args.f
def setup_cmd_args():
parser = ArgumentParser(description="SpyNote 6.4 keylogger log parser")
parser.add_argument('file', type=str, help='Keylogger file on SpyNote')
parser.add_argument('output', type=str, help='Parsed and formated file output')
parser.add_argument('-p', type=bool, action=BooleanOptionalAction, help="Print text on command line")
parser.add_argument('-f', type=str, help="Set format pattern", default="{app} - {time} --- {text}")
parser.add_argument('-v', type=bool, action=BooleanOptionalAction, help="Verbose")
return parser.parse_args()
def worker(input_file: str, output_file: str) -> None:
f = open(output_file, "w")
text = open(input_file, 'r').read()
for i in split_text(text):
if i == "":
continue
write_file(f, parse_splittet(i), ignore=False)
f.close()
def main():
args = setup_cmd_args()
setup_settings(args)
worker(args.file, args.output)
if __name__ == "__main__":
main()