本文整理汇总了Python中pbkdf2.PBKDF2属性的典型用法代码示例。如果您正苦于以下问题:Python pbkdf2.PBKDF2属性的具体用法?Python pbkdf2.PBKDF2怎么用?Python pbkdf2.PBKDF2使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pbkdf2
的用法示例。
在下文中一共展示了pbkdf2.PBKDF2属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loop
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def loop(self):
last_pass__ = ''
for _pass in self.passes:
self.pull.up('Current Password: %s' % self.printing_pass(last_pass__, _pass)); last_pass__ = _pass
_pmk = PBKDF2(_pass, self.essid, 4096).read(32)
_ptk = self.customPRF512(_pmk, "Pairwise key expansion", self.key_data)
_mic = hmac.new(_ptk[0:16], self.payload, hashlib.md5).hexdigest()
_mic_ = hmac.new(_ptk[0:16], self.payload, hashlib.sha1).hexdigest()[:32]
if self.mic == _mic or self.mic == _mic_:
self.pull.use("CRACKED! Key Found %s[%s]%s" % (self.pull.GREEN, _pass, self.pull.END))
self.pull.right("PMK =>"); print self.hexdump(_pmk)
self.pull.right("PTK =>"); print self.hexdump(_ptk)
self.pull.right("MIC =>"); print self.hexdump(_mic if self.mic == _mic else _mic_)
return
else:
if _pass != self.passes[-1]:
self.pull.lineup()
示例2: crack
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def crack(self, _pm_, _ap_, _cl_, _ess_):
_last_pass = ''
for _pass in self.passes:
self.pull.up("Currently Checking: %s%s%s" % (self.pull.BLUE, self.printing_pass(_last_pass, _pass), self.pull.END))
_last_pass = _pass
_pmk = PBKDF2(_pass, binascii.unhexlify(_ess_), 4096).read(32)
_ap = binascii.a2b_hex(_ap_)
_cl = binascii.a2b_hex(_cl_)
_pmk_string = "PMK Name"
_hash = hmac.new(_pmk, _pmk_string+_ap+_cl, hashlib.sha1).hexdigest()[:32]
if _hash == _pm_:
return (_pass, _pmk)
else:
if _pass != self.passes[-1]:
self.pull.lineup()
return (None, None)
示例3: crack_the_pmk
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def crack_the_pmk(self, _hash):
if type(self.passwords) == str:
_pass_list = self.passwords.split(',')
else:
_file = open(self.dict, 'r')
_pass_list = self.d_passes+_file.read().splitlines()
_file.close()
_last_pass = ''
for _pass in _pass_list:
self.pull.up("Currently Checking: %s%s%s" % (self.pull.BOLD, self.printing_pass(_last_pass, _pass.rstrip('\n')), self.pull.END))
_last_pass = _pass.rstrip('\n')
_pmk = PBKDF2(_pass, self.essid, 4096).read(32)
_ap = binascii.a2b_hex(self.ap.replace(':', '').lower())
_cl = binascii.a2b_hex(self.cl.replace(':', '').lower())
_pmk_fs = "PMK Name"
_hash_ = hmac.new(_pmk, _pmk_fs+_ap+_cl, hashlib.sha1).hexdigest()[:32]
if _hash == _hash_:
return (_pass, self.hexdump(_pmk), self.hexdump(_hash_))
else:
if _pass != _pass_list[-1]:
self.pull.lineup()
return (None, '', '')
示例4: derive_key
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def derive_key(salt: str, passphrase: str, hd: bool = True) -> \
Union[int, Tuple[int, bytes]]:
key_length = 64 if hd else 32 # type: int
t1 = and_split(bytes(salt, "utf-8")) # type: Tuple[bytes, bytes]
salt1, salt2 = t1
t2 = and_split(bytes(passphrase, "utf-8")) # type: Tuple[bytes, bytes]
pass1, pass2 = t2
scrypt_key = scrypt.hash(
pass1, salt1,
N=1 << 18, buflen=key_length) # type: bytes
pbkdf2_key = pbkdf2.PBKDF2(
pass2, salt2,
iterations=1 << 16,
digestmodule=SHA256).read(key_length) # type: bytes
merged = xor_merge(scrypt_key, pbkdf2_key) # type: bytes
if hd:
secret_exp = int(merged[0:32].hex(), 16) # type: int
chain_code = merged[32:] # type: bytes
return secret_exp, chain_code
return int(merged.hex(), 16)
示例5: derive_pbkdf2
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def derive_pbkdf2(key, salt, iv_length, key_length, iterations=8):
generator = PBKDF2(key, salt, iterations)
derived_iv = generator.read(iv_length)
derived_key = generator.read(key_length)
return derived_iv, derived_key
示例6: _decode_keystore_json
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def _decode_keystore_json(jsondata, password):
# Get key derivation function (kdf) and parameters
kdfparams = jsondata["crypto"]["kdfparams"]
# Compute derived key
derivedkey = pbkdf2.PBKDF2(
password, decode_hex(kdfparams["salt"]), kdfparams["c"], SHA256
).read(kdfparams["dklen"])
assert len(derivedkey) >= 32, "Derived key must be at least 32 bytes long"
# Get cipher and parameters and decrypt using AES
cipherparams = jsondata["crypto"]["cipherparams"]
enckey = derivedkey[:16]
iv = int.from_bytes(decode_hex(cipherparams["iv"]), byteorder="big")
ctr = Counter.new(128, initial_value=iv, allow_wraparound=True)
encryptor = AES.new(enckey, AES.MODE_CTR, counter=ctr)
ctext = decode_hex(jsondata["crypto"]["ciphertext"])
o = encryptor.decrypt(ctext)
# Compare the provided MAC with a locally computed MAC
mac1 = sha3(derivedkey[16:32] + ctext)
mac2 = decode_hex(jsondata["crypto"]["mac"])
if mac1 != mac2:
raise ValueError("MAC mismatch. Password incorrect?")
return o
示例7: mnemonic_to_seed
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def mnemonic_to_seed(mnemonic, passphrase=u''):
pbkdf2_rounds = 2048
mnemonic = normalize_text(mnemonic)
passphrase = normalize_text(passphrase)
return pbkdf2.PBKDF2(
mnemonic, passphrase, iterations=pbkdf2_rounds, macmodule=hmac, digestmodule=hashlib.sha512
).read(64)
示例8: mnemonic_to_seed
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def mnemonic_to_seed(self, mnemonic, passphrase):
PBKDF2_ROUNDS = 2048
mnemonic = prepare_seed(mnemonic)
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
示例9: mnemonic_to_seed
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def mnemonic_to_seed(self, mnemonic, passphrase):
# trezor uses bip39
import pbkdf2, hashlib, hmac
PBKDF2_ROUNDS = 2048
mnemonic = unicodedata.normalize('NFKD', ' '.join(mnemonic.split()))
passphrase = unicodedata.normalize('NFKD', passphrase)
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase, iterations = PBKDF2_ROUNDS, macmodule = hmac, digestmodule = hashlib.sha512).read(64)
示例10: __init__
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def __init__(self, psk = None, essid = None, pcap = False):
self.pt = PE.pt
if psk is not None and essid is not None:
if os.path.isfile('handshakes.sqlite'):
os.remove('handshakes.sqlite')
self.con = lite.connect('handshakes.sqlite')
self.con.text_factory = str
self.db = self.con.cursor()
self.tgtInfo = {}
self.availTgts = set()
self.catchDict = {}
self.encDict = {}
self.alert = set()
self.pke = 'Pairwise key expansion'
self.pmk = PBKDF2(psk, essid, 4096).read(32)
self.db.execute('CREATE TABLE IF NOT EXISTS\
"shakes"("pkt" TEXT,\
"vmac" TEXT,\
"bmac" TEXT,\
"nonce" TEXT,\
"e_num" TEXT,\
UNIQUE(vmac, bmac, e_num));')
self.con.commit()
if pcap is True:
self.eapolTrack = PcapWriter('eapols.pcap', sync = True)
self.pcap = pcap
else:
self.eapolTrack = None
self.pcap = None
示例11: decrypt_string
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def decrypt_string(key, salt, coded):
#try:
# Derive key
generator = PBKDF2(key, salt)
aes_iv = generator.read(16)
aes_key = generator.read(32)
# Crypto
mode = AES.MODE_CBC
cipher = AES.new(aes_key, mode, IV=aes_iv)
value = cipher.decrypt(b64decode(coded)).replace('\x00', '')
return value#.encode('hex')
#except:
#return False
# Get a list of strings from a section
示例12: derive_key
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def derive_key(guid, coded_key):
try:
from pbkdf2 import PBKDF2
except:
print "[!] Unable to derive a key. requires 'sudo pip install pbkdf2'"
sys.exit()
generator = PBKDF2(guid, guid, 8)
aes_iv = generator.read(16)
aes_key = generator.read(16)
derived_key = decrypt_aes(aes_key, aes_iv, coded_key)
return derived_key
示例13: mnemonic_to_seed
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def mnemonic_to_seed(mnemonic, passphrase=''):
pbkdf2_rounds = 2048
mnemonic = normalize_text(mnemonic)
passphrase = normalize_text(passphrase)
return pbkdf2.PBKDF2(
mnemonic, passphrase, iterations=pbkdf2_rounds, macmodule=hmac, digestmodule=hashlib.sha512
).read(64)
示例14: mnemonic_to_seed
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def mnemonic_to_seed(mnemonic, passphrase):
# See BIP39
PBKDF2_ROUNDS = 2048
mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
passphrase = BIP44_Wallet.normalize_passphrase(passphrase)
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase,
iterations=PBKDF2_ROUNDS, macmodule=hmac,
digestmodule=hashlib.sha512).read(64)
示例15: mnemonic_to_seed
# 需要导入模块: import pbkdf2 [as 别名]
# 或者: from pbkdf2 import PBKDF2 [as 别名]
def mnemonic_to_seed(cls, mnemonic, passphrase):
PBKDF2_ROUNDS = 2048
mnemonic = prepare_seed(mnemonic)
return pbkdf2.PBKDF2(mnemonic, 'uwallet' + passphrase, iterations=PBKDF2_ROUNDS,
macmodule=hmac, digestmodule=hashlib.sha512).read(64)