-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtarlist_decrypt.py
32 lines (26 loc) · 926 Bytes
/
tarlist_decrypt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import argparse
from pathlib import Path
def decrypt_tarlist(enc_file, dest):
if not dest.parent.exists():
dest.parent.mkdir(parents=True)
with open(enc_file, "rb") as f:
data = f.read()
with open(dest, "wb") as f:
for i in range(len(data)):
f.write(bytes([data[i] ^ 0x11]))
if __name__ == "__main__":
ap = argparse.ArgumentParser()
ap.add_argument("filepath", help="input file", type=Path)
ap.add_argument("-o", "--out", help="output file", type=Path, default=None)
args = ap.parse_args()
filepath: Path = args.filepath.resolve()
dest: Path = (
args.out.resolve()
if args.out is not None
else filepath.with_suffix(filepath.suffix + ".decrypted")
)
if args.filepath.exists():
filepath: Path = args.filepath
decrypt_tarlist(filepath, dest)
else:
raise FileNotFoundError("File not found.")