support reading from stdin in bin/bitbot-log
This commit is contained in:
parent
36fd91f009
commit
bb975f8e60
1 changed files with 7 additions and 3 deletions
|
@ -11,7 +11,7 @@ arg_parser.add_argument("log", help="Location of the log file to decrypt")
|
||||||
|
|
||||||
args = arg_parser.parse_args()
|
args = arg_parser.parse_args()
|
||||||
|
|
||||||
import base64
|
import base64, sys
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
|
@ -38,9 +38,13 @@ def aes_decrypt(key: bytes, data_str: str):
|
||||||
|
|
||||||
with open(args.key, "rb") as key_file:
|
with open(args.key, "rb") as key_file:
|
||||||
key_content = key_file.read()
|
key_content = key_file.read()
|
||||||
|
|
||||||
key = serialization.load_pem_private_key(
|
key = serialization.load_pem_private_key(
|
||||||
key_content, password=None, backend=default_backend())
|
key_content, password=None, backend=default_backend())
|
||||||
|
|
||||||
|
if args.log == "-":
|
||||||
|
lines = sys.stdin.read().split("\n")
|
||||||
|
else:
|
||||||
with open(args.log) as log_file:
|
with open(args.log) as log_file:
|
||||||
lines = log_file.read().split("\n")
|
lines = log_file.read().split("\n")
|
||||||
lines = filter(None, lines)
|
lines = filter(None, lines)
|
||||||
|
|
Loading…
Reference in a new issue