Default encrypt algo is now AES256_CBC + Fix import_pfx default flags to be able to use it for AES256_CBC simply

This commit is contained in:
hakril
2017-12-07 15:40:47 +01:00
parent 32de3cb824
commit 3490dc987f
4 changed files with 21 additions and 4 deletions
+7 -1
View File
@@ -1,4 +1,6 @@
import argparse
import getpass
import windows.crypto as crypto
from windows import winproxy
from windows.generated_def import *
@@ -23,6 +25,8 @@ def crypt(src, dst, certs, **kwargs):
def decrypt(src, pfxfile, password, outfile=None, **kwargs):
"""Decrypt the content of 'src' with the private key in 'pfxfile'. the 'pfxfile' is open using the 'password'"""
# Open the 'pfx' with the given password
if password is None:
password = getpass.getpass()
pfx = crypto.import_pfx(pfxfile.read(), password)
# Decrypt the content of the file
decrypted = crypto.decrypt(pfx, src.read())
@@ -95,6 +99,8 @@ def genkeys(common_name, pfxpassword, outname, keysize=2048, **kwargs):
## Read pfx info !!!! PRINT PRIVATE KEY !!!!
### openssl pkcs12 -info -in {pfx} -nodes
## Read ASN1 data
### openssl asn1parse -inform DER -in {file}
parser = argparse.ArgumentParser(prog=__file__)
@@ -112,7 +118,7 @@ decryptparse = subparsers.add_parser('decrypt')
decryptparse.set_defaults(func=decrypt)
decryptparse.add_argument('src', type=argparse.FileType('rb'), help='File to decrypt')
decryptparse.add_argument('pfxfile', type=argparse.FileType('rb'), help='PFX file to use')
decryptparse.add_argument('password', help='Password of the PFX')
decryptparse.add_argument('--password', help='Password of the PFX')
decryptparse.add_argument('--outfile', default=None, help='The outputfile default is print')
genkeysparse = subparsers.add_parser('genkey')
+1 -1
View File
@@ -32,7 +32,7 @@ def search_name_in_struct(target):
def search_name_in_windef(target):
for name, windef in meta.windef_walker():
if match(target, name):
print(windef)
print(repr(windef))
def search_name_in_interface(target):
for name, interface in meta.interfaces_walker():