From 9e17dcd97a78371458595b122aa15d553737e215 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 7 Aug 2019 22:46:46 -0400 Subject: add a useful script --- ethy.py | 14 +++++++------- verify_batch.sh | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100755 verify_batch.sh diff --git a/ethy.py b/ethy.py index 18f2d30..113acd3 100644 --- a/ethy.py +++ b/ethy.py @@ -248,25 +248,25 @@ if __name__ == '__main__': priv_key, mac = decrypt(passwd=passwd, iv=iv, enc_pk=enc_pk, salt=salt, n=n, r=r, p=p, dklen=dklen) if c['mac'] == mac.hex(): - print("-- password is correct --") + err.write("-- password is correct --\n") else: - print("!! possibly WRONG password !!") + err.write("!! possibly WRONG password !!\n") if not args.force: sys.exit(1) if args.show_key: - print("> private key: {}".format(priv_key.hex())) + err.write("> private key: {}\n".format(priv_key.hex())) if args.verify_key: # derive public key and address from the decrypted private key sk = SigningKey.from_string(priv_key, curve=SECP256k1) pub_key = sk.get_verifying_key().to_string() - print("> public key: {}".format(pub_key.hex())) + err.write("> public key: {}\n".format(pub_key.hex())) addr = generate_addr(pub_key) - print("> address: {}".format(addr)) + err.write("> address: {}\n".format(addr)) if parsed['address'] == addr: - print("-- private key matches address --") + err.write("-- private key matches address --\n") else: - print("!! private key does NOT match the address !!") + err.write("!! private key does NOT match the address !!\n") if not args.force: sys.exit(1) # generate a new encrypted wallet diff --git a/verify_batch.sh b/verify_batch.sh new file mode 100755 index 0000000..cba359a --- /dev/null +++ b/verify_batch.sh @@ -0,0 +1,8 @@ +#!/bin/bash -e +prefix=${1:-wallet-b0b54476db350aa80aa8404d09ad2d2e} # the prefix for all wallets +n=${2:-5} # the number of wallets in the batch +passfile=${3:-all_passwords} +for i in $(seq -f "%03g" 0 $((n - 1))); do + ii=$((10#$i)) + head -n "$((ii + 1))" "$passfile" | tail -n 1 | sed 's/.* = \(.*\)$/\1/g' | ethy.py --pass-stdin $prefix-$i.json > /dev/null +done -- cgit v1.2.3