aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2020-02-24 17:58:00 +0000
committerGravatar jesopo2020-02-24 17:58:00 +0000
commitbb975f8e601d0f78a93d984e67b221b9c0c3c253 (patch)
tree3ec84819b9759883f4bb876039f9e8ca3ea74247
parentwe need to manually flush log files (diff)
signature
support reading from stdin in bin/bitbot-log
-rwxr-xr-xbin/bitbot-log10
1 files 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