support reading from stdin in bin/bitbot-log

This commit is contained in:
jesopo 2020-02-24 17:58:00 +00:00
parent 36fd91f009
commit bb975f8e60

View file

@ -11,7 +11,7 @@ arg_parser.add_argument("log", help="Location of the log file to decrypt")
args = arg_parser.parse_args()
import base64
import base64, sys
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes
@ -38,11 +38,15 @@ def aes_decrypt(key: bytes, data_str: str):
with open(args.key, "rb") as key_file:
key_content = key_file.read()
key = serialization.load_pem_private_key(
key_content, password=None, backend=default_backend())
with open(args.log) as log_file:
lines = log_file.read().split("\n")
if args.log == "-":
lines = sys.stdin.read().split("\n")
else:
with open(args.log) as log_file:
lines = log_file.read().split("\n")
lines = filter(None, lines)
symm_key = None