#!/usr/bin/env python3

from strfry import *
import argparse

parser = argparse.ArgumentParser(description = 'a CTF tool for solving those annoying strfry challenges')
parser.add_argument('string', nargs = 1, default = None, help = 'the string to manipulate')
parser.add_argument('--processid', '--pid', '-p', type = int, default = None, help = 'process id which called strfry')
parser.add_argument('--timestamp', '--ts', '-t', type = int, default = None, help = 'unix timestamp when strfry happened')
parser.add_argument('--decode', '-d', action = 'store_true', default = False, help = 'switch to decode mode')
args = parser.parse_args()

if not args.string:
    print('Try with --help')
    exit(1)

string = args.string[0]
ts = args.timestamp
pid = args.processid
ret_val = None

if args.decode:
    ret_val = unstrfry(string, ts = ts, pid = pid, reset = True)
else:
    ret_val = strfry(string, ts = ts, pid = pid, reset = True)

print(ret_val)
