How to use the pypykatz.crypto.unified.common.SYMMETRIC_MODE function in pypykatz

To help you get started, we’ve selected a few pypykatz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github skelsec / pypykatz / pypykatz / dpapi / dpapi.py View on Github external
def decrypt_attr(attr, key):
			if attr.data is not None:
				if attr.iv is not None:
					cipher = AES(key, SYMMETRIC_MODE.CBC, iv=attr.iv)
				else:
					cipher = AES(key, SYMMETRIC_MODE.CBC, iv=b'\x00'*16)
				
				cleartext = cipher.decrypt(attr.data)
				return cleartext
github skelsec / pypykatz / pypykatz / crypto / unified / aes.py View on Github external
	def __init__(self, key, mode = SYMMETRIC_MODE.ECB, iv = None):
		self.key = key
		self.mode = mode
		self.iv = iv
		self.block_size = 16
		self.ctx = None
		self.setup()
github skelsec / pypykatz / pypykatz / crypto / unified / des3.py View on Github external
def setup(self):
		if self.mode == SYMMETRIC_MODE.ECB:
			self.ctx = triple_des(self.key, mode = ECB)
		elif self.mode == SYMMETRIC_MODE.CBC:
			self.ctx = triple_des(self.key, mode = CBC, IV = self.iv)
		else:
			raise Exception('Unknown mode!')
github skelsec / pypykatz / pypykatz / crypto / unified / aes.py View on Github external
def setup(self):
		if self.mode == SYMMETRIC_MODE.ECB:
			self.ctx = AESModeOfOperationECB(self.key)
		elif self.mode == SYMMETRIC_MODE.CBC:
			self.ctx = AESModeOfOperationCBC(self.key, iv = self.iv)
		else:
			raise Exception('Unknown mode!')
github skelsec / pypykatz / pypykatz / crypto / unified / aes.py View on Github external
def setup(self):
		if self.mode == SYMMETRIC_MODE.ECB:
			self.ctx = AESModeOfOperationECB(self.key)
		elif self.mode == SYMMETRIC_MODE.CBC:
			self.ctx = AESModeOfOperationCBC(self.key, iv = self.iv)
		else:
			raise Exception('Unknown mode!')
github skelsec / pypykatz / pypykatz / crypto / unified / des3.py View on Github external
def setup(self):
		if self.mode == SYMMETRIC_MODE.ECB:
			self.ctx = triple_des(self.key, mode = ECB)
		elif self.mode == SYMMETRIC_MODE.CBC:
			self.ctx = triple_des(self.key, mode = CBC, IV = self.iv)
		else:
			raise Exception('Unknown mode!')
github skelsec / pypykatz / pypykatz / dpapi / constants.py View on Github external
CALG_AES_128            = (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_128)
    CALG_AES_192            = (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_192)
    CALG_AES_256            = (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_256)
    CALG_AES                = (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES)
    CALG_SHA_256            = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256)
    CALG_SHA_384            = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384)
    CALG_SHA_512            = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512)
    CALG_ECDH               = (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_ECDH)
    CALG_ECMQV              = (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_ECMQV)
    CALG_ECDSA              = (ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_ECDSA)
	
ALGORITHMS_DATA = {
    # Algorithm: key/SaltLen, CryptHashModule, Mode, IVLen, BlockSize
    ALGORITHMS.CALG_SHA: (160//8, SHA1, None, None, 512//8),
    ALGORITHMS.CALG_HMAC: (160//8, SHA512, None, None, 512//8),
    ALGORITHMS.CALG_3DES: (192//8, DES3, SYMMETRIC_MODE.CBC, 64//8),
    ALGORITHMS.CALG_SHA_512: (128//8, SHA512, None, None, 1024//8),
    ALGORITHMS.CALG_AES_256: (256//8, AES, SYMMETRIC_MODE.CBC,128//8), #CBC is already in the object...
}
	
	
class FLAGS(enum.IntFlag):
    CRYPTPROTECT_UI_FORBIDDEN = 0x1
    CRYPTPROTECT_LOCAL_MACHINE = 0x4
    CRYPTPROTECT_CRED_SYNC = 0x8
    CRYPTPROTECT_AUDIT = 0x10
    CRYPTPROTECT_VERIFY_PROTECTION = 0x40
    CRYPTPROTECT_CRED_REGENERATE = 0x80
    CRYPTPROTECT_SYSTEM = 0x20000000
github skelsec / pypykatz / pypykatz / dpapi / constants.py View on Github external
CALG_AES_256            = (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES_256)
    CALG_AES                = (ALG_CLASS_DATA_ENCRYPT|ALG_TYPE_BLOCK|ALG_SID_AES)
    CALG_SHA_256            = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256)
    CALG_SHA_384            = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_384)
    CALG_SHA_512            = (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_512)
    CALG_ECDH               = (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_DH | ALG_SID_ECDH)
    CALG_ECMQV              = (ALG_CLASS_KEY_EXCHANGE | ALG_TYPE_ANY | ALG_SID_ECMQV)
    CALG_ECDSA              = (ALG_CLASS_SIGNATURE | ALG_TYPE_DSS | ALG_SID_ECDSA)
	
ALGORITHMS_DATA = {
    # Algorithm: key/SaltLen, CryptHashModule, Mode, IVLen, BlockSize
    ALGORITHMS.CALG_SHA: (160//8, SHA1, None, None, 512//8),
    ALGORITHMS.CALG_HMAC: (160//8, SHA512, None, None, 512//8),
    ALGORITHMS.CALG_3DES: (192//8, DES3, SYMMETRIC_MODE.CBC, 64//8),
    ALGORITHMS.CALG_SHA_512: (128//8, SHA512, None, None, 1024//8),
    ALGORITHMS.CALG_AES_256: (256//8, AES, SYMMETRIC_MODE.CBC,128//8), #CBC is already in the object...
}
	
	
class FLAGS(enum.IntFlag):
    CRYPTPROTECT_UI_FORBIDDEN = 0x1
    CRYPTPROTECT_LOCAL_MACHINE = 0x4
    CRYPTPROTECT_CRED_SYNC = 0x8
    CRYPTPROTECT_AUDIT = 0x10
    CRYPTPROTECT_VERIFY_PROTECTION = 0x40
    CRYPTPROTECT_CRED_REGENERATE = 0x80
    CRYPTPROTECT_SYSTEM = 0x20000000
github skelsec / pypykatz / pypykatz / dpapi / dpapi.py View on Github external
def decrypt_attr(attr, key):
			if attr.data is not None:
				if attr.iv is not None:
					cipher = AES(key, SYMMETRIC_MODE.CBC, iv=attr.iv)
				else:
					cipher = AES(key, SYMMETRIC_MODE.CBC, iv=b'\x00'*16)
				
				cleartext = cipher.decrypt(attr.data)
				return cleartext
github skelsec / pypykatz / pypykatz / crypto / unified / des3.py View on Github external
	def __init__(self, key, mode = SYMMETRIC_MODE.ECB, iv = None):
		self.key = key
		self.mode = mode
		self.iv = iv
		self.block_size = 8
		self.ctx = None
		self.setup()