From bb975f8e601d0f78a93d984e67b221b9c0c3c253 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 24 Feb 2020 17:58:00 +0000 Subject: [PATCH] support reading from stdin in bin/bitbot-log --- bin/bitbot-log | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/bitbot-log b/bin/bitbot-log index 959e6ca7..f067ff9f 100755 --- a/bin/bitbot-log +++ b/bin/bitbot-log @@ -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