當前位置: 首頁>>代碼示例>>Python>>正文


Python pbkdf2.PBKDF2屬性代碼示例

本文整理匯總了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() 
開發者ID:hash3liZer,項目名稱:WiFiBroot,代碼行數:19,代碼來源:captures.py

示例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) 
開發者ID:hash3liZer,項目名稱:WiFiBroot,代碼行數:18,代碼來源:captures.py

示例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, '', '') 
開發者ID:hash3liZer,項目名稱:WiFiBroot,代碼行數:27,代碼來源:pmkid.py

示例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) 
開發者ID:metamarcdw,項目名稱:nowallet,代碼行數:26,代碼來源:keys.py

示例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 
開發者ID:kevthehermit,項目名稱:RATDecoders,代碼行數:7,代碼來源:crypto.py

示例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 
開發者ID:QuarkChain,項目名稱:pyquarkchain,代碼行數:28,代碼來源:accounts.py

示例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) 
開發者ID:lbryio,項目名稱:torba,代碼行數:9,代碼來源:mnemonic.py

示例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) 
開發者ID:mazaclub,項目名稱:encompass,代碼行數:6,代碼來源:mnemonic.py

示例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) 
開發者ID:mazaclub,項目名稱:encompass,代碼行數:9,代碼來源:trezor.py

示例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 
開發者ID:ICSec,項目名稱:pyDot11,代碼行數:31,代碼來源:handshake.py

示例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 
開發者ID:opensourcesec,項目名稱:CIRTKit,代碼行數:17,代碼來源:hawkeye.py

示例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 
開發者ID:opensourcesec,項目名稱:CIRTKit,代碼行數:13,代碼來源:nanocore.py

示例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) 
開發者ID:lbryio,項目名稱:lbry-sdk,代碼行數:9,代碼來源:mnemonic.py

示例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) 
開發者ID:UlordChain,項目名稱:Uwallet,代碼行數:10,代碼來源:wallet.py

示例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) 
開發者ID:UlordChain,項目名稱:Uwallet,代碼行數:7,代碼來源:mnemonic.py


注:本文中的pbkdf2.PBKDF2屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。