Python hashlib.sha512() Examples

The following are code examples for showing how to use hashlib.sha512(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: VHaSH   Author: furkanonder   File: VHaSH.py    MIT License 6 votes vote down vote up
def calculate():
    md5 = hashlib.md5()
    sha1 = hashlib.sha1()
    sha256 = hashlib.sha256()
    sha512 = hashlib.sha512()

    try:
        file = open(input_file, "rb")
        data = file.read()
        sha256.update(data)
        md5.update(data)
        sha1.update(data)

        val.set(md5.hexdigest().upper())
        val2.set(sha1.hexdigest().upper())
        val3.set(sha256.hexdigest().upper())
        val4.set(sha512.hexdigest().upper())
    except:
        pass 
Example 2
Project: hacking-tools   Author: girishramnani   File: _pfish_tools.py    MIT License 6 votes vote down vote up
def parse_command_line():
    parser= argparse.ArgumentParser()
    group = parser.add_mutually_exclusive_group(required = True)
    group.add_argument('--md5',help='specifies MD5 algorithm',action='store_true')
    group.add_argument('--sha256', help='specifies SHA256 algorithm', action='store_true')
    group.add_argument('--sha512', help='specifies SHA512 algorithm', action='store_true')
    parser.add_argument('-d','--dirpath',type=ValidateDirectory,required=True,help="specify the root path for hashing")
    parser.add_argument('-r','--reportpath',type=ValidateDirectoryWritable,required=True,help="specify the path for reports and logs will be written")
    global gl_args
    global gl_hashType
    gl_args = parser.parse_args()
    if gl_args.md5:
        gl_hashType='MD5'
    elif gl_args.sha256:
        gl_hashType='SHA256'
    elif gl_args.sha512:
        gl_hashType='SHA512'
    else:
        gl_hashType='unknown' 
Example 3
Project: beowulf-python   Author: beowulf-foundation   File: memo.py    MIT License 6 votes vote down vote up
def get_shared_secret(priv, pub):
    """ Derive the share secret between ``priv`` and ``pub``

        :param `Base58` priv: Private Key
        :param `Base58` pub: Public Key
        :return: Shared secret
        :rtype: hex

        The shared secret is generated such that::

            Pub(Alice) * Priv(Bob) = Pub(Bob) * Priv(Alice)

    """
    pub_point = pub.point()
    priv_point = int(repr(priv), 16)
    res = pub_point * priv_point
    res_hex = '%032x' % res.x()
    # Zero padding
    res_hex = '0' * (64 - len(res_hex)) + res_hex
    return hashlib.sha512(unhexlify(res_hex)).hexdigest() 
Example 4
Project: pyblish-win   Author: pyblish   File: test_hmac.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def test_sha512_rfc4231(self):
        self._rfc4231_test_cases(hashlib.sha512) 
Example 5
Project: bitmm   Author: thmp   File: hitbtc.py    MIT License 5 votes vote down vote up
def sendSignedGetRequest(self, uri):
        signature = hmac.new(self.secret, msg=uri, digestmod=hashlib.sha512).digest().encode("hex")
        r = requests.get(self.endpoint + uri, headers={"X-Signature": signature})
        #print r, r.text, r.raw
        return r.json() 
Example 6
Project: bitmm   Author: thmp   File: hitbtc.py    MIT License 5 votes vote down vote up
def sendSignedMessage(self, payload):
        message = {
            "apikey": self.api_key,
            "signature": "",
            "message": {
                "nonce": self.nonce,
                "payload": payload
            }
        }

        message["signature"] = base64.b64encode(hmac.new(self.secret, msg=json.dumps(message["message"], separators=(',', ':')), digestmod=hashlib.sha512).digest())

        #print json.dumps(message, separators=(',', ':'))
        self.sendMessage(json.dumps(message, separators=(',', ':')))

        self.nonce += 1 
Example 7
Project: flasky   Author: RoseOu   File: flask_login.py    MIT License 5 votes vote down vote up
def make_secure_token(*args, **options):
    '''
    This will create a secure token that you can use as an authentication
    token for your users. It uses heavy-duty HMAC encryption to prevent people
    from guessing the information. (To make it even more effective, if you
    will never need to regenerate the token, you can  pass some random data
    as one of the arguments.)

    :param \*args: The data to include in the token.
    :type args: args
    :param \*\*options: To manually specify a secret key, pass ``key=THE_KEY``.
        Otherwise, the ``current_app`` secret key will be used.
    :type \*\*options: kwargs
    '''
    key = options.get('key')
    key = _secret_key(key)

    l = [s if isinstance(s, bytes) else s.encode('utf-8') for s in args]

    payload = b'\0'.join(l)

    token_value = hmac.new(key, payload, sha512).hexdigest()

    if hasattr(token_value, 'decode'):  # pragma: no cover
        token_value = token_value.decode('utf-8')  # ensure bytes

    return token_value 
Example 8
Project: flasky   Author: RoseOu   File: flask_login.py    MIT License 5 votes vote down vote up
def _cookie_digest(payload, key=None):
    key = _secret_key(key)

    return hmac.new(key, payload.encode('utf-8'), sha512).hexdigest() 
Example 9
Project: flasky   Author: RoseOu   File: flask_login.py    MIT License 5 votes vote down vote up
def _create_identifier():
    user_agent = request.headers.get('User-Agent')
    if user_agent is not None:
        user_agent = user_agent.encode('utf-8')
    base = '{0}|{1}'.format(_get_remote_addr(), user_agent)
    if str is bytes:
        base = unicode(base, 'utf-8', errors='replace')  # pragma: no cover
    h = sha512()
    h.update(base.encode('utf8'))
    return h.hexdigest() 
Example 10
Project: sawtooth-cookiejar   Author: danintel   File: cookiejar_tp.py    Apache License 2.0 5 votes vote down vote up
def _hash(data):
    '''Compute the SHA-512 hash and return the result as hex characters.'''
    return hashlib.sha512(data).hexdigest() 
Example 11
Project: sawtooth-cookiejar   Author: danintel   File: cookiejar_client.py    Apache License 2.0 5 votes vote down vote up
def _hash(data):
    return hashlib.sha512(data).hexdigest() 
Example 12
Project: XFLTReaT   Author: earthquake   File: auth_saltedsha512.py    MIT License 5 votes vote down vote up
def send_details(self):
		rnd = struct.pack("<I", random.randint(0, 4294967295))
		m = hashlib.sha512()
		m.update(rnd)
		m.update(self.key)
		ciphertext = m.digest()

		return rnd+ciphertext 
Example 13
Project: XFLTReaT   Author: earthquake   File: auth_saltedsha512.py    MIT License 5 votes vote down vote up
def check_details(self, msg):
		rnd = msg[0:4]
		ciphertext = msg[4:68]
		m = hashlib.sha512()
		m.update(rnd)
		m.update(self.key)
		if ciphertext == m.digest():
			return True

		return False 
Example 14
Project: sic   Author: Yanixos   File: djbec.py    GNU General Public License v3.0 5 votes vote down vote up
def H(m):
    return hashlib.sha512(m).digest() 
Example 15
Project: sic   Author: Yanixos   File: random.py    GNU General Public License v3.0 5 votes vote down vote up
def seed(self, a=None, version=2):
        """Initialize internal state from hashable object.

        None or no argument seeds from current time or from an operating
        system specific randomness source if available.

        If *a* is an int, all bits are used.

        For version 2 (the default), all of the bits are used if *a* is a str,
        bytes, or bytearray.  For version 1 (provided for reproducing random
        sequences from older versions of Python), the algorithm for str and
        bytes generates a narrower range of seeds.

        """

        if version == 1 and isinstance(a, (str, bytes)):
            a = a.decode('latin-1') if isinstance(a, bytes) else a
            x = ord(a[0]) << 7 if a else 0
            for c in map(ord, a):
                x = ((1000003 * x) ^ c) & 0xFFFFFFFFFFFFFFFF
            x ^= len(a)
            a = -2 if x == -1 else x

        if version == 2 and isinstance(a, (str, bytes, bytearray)):
            if isinstance(a, str):
                a = a.encode()
            a += _sha512(a).digest()
            a = int.from_bytes(a, 'big')

        super().seed(a)
        self.gauss_next = None 
Example 16
Project: smbprotocol   Author: jborean93   File: test_connection.py    MIT License 5 votes vote down vote up
def test_valid_hash_algorithm():
    expected = hashlib.sha512
    actual = HashAlgorithms.get_algorithm(0x1)
    assert actual == expected 
Example 17
Project: smbprotocol   Author: jborean93   File: connection.py    MIT License 5 votes vote down vote up
def get_algorithm(hash):
        return {
            HashAlgorithms.SHA_512: hashlib.sha512
        }[hash] 
Example 18
Project: kurisu-bot   Author: RIP95   File: general.py    MIT License 5 votes vote down vote up
def hash_sha512(self, *, txt: str):
        """Hash input with SHA512"""
        output = hashlib.sha512(txt.encode()).hexdigest()
        await self.send('SHA512: {}'.format(output)) 
Example 19
Project: MyDotfiles   Author: Sup3r-Us3r   File: hashcodegui.py    GNU General Public License v3.0 5 votes vote down vote up
def Sha512():
	mystring = (bloco1.get())
	hash_object = hashlib.sha512(mystring.encode())
	janela.geometry("1010x550")
	lb["text"] = hash_object.hexdigest()
	resultado = open("resultado.txt", "w")
	resultado.write("SUA SENHA ENCRIPTADA EM 512 É: " + hash_object.hexdigest()) 
Example 20
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco1():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #1: Descriptografia
 ____________________________________________
|                                            |
|      23a37c7340995c9192471ce06ae4c3e8      |
|____________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "5950c237124755f423d01812a1dbe8281513adc0cfe3fa0a0bc984cefb381f7e13f91e8360716ffe78d77aa447c17c98ee77e23e495c496b0c8b8167cb177b9b" #spyquiz
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco1()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco2()
	elif opcao1 == "2":
		Bloco2()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco1() 
Example 21
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco4():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #4: QrCode
 _________________________________________________________________________
|                                                                         |
|        QrCode = https://sup3r-us3r.github.io/spyquiz/level4.png         |
|_________________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "0ceeb7a66858efeb21bfb43f5b44d79420d443c28b8cc48c522c981e5ac98d47202add62649719d1307c5baa44a6de4c4b6bcaeb1875a7bd94854b1810125502" #metasploit.php
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco4()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco5()
	elif opcao1 == "2":
		Bloco5()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco4() 
Example 22
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco7():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #7: Esteganografia
 _________________________________________________________________
|                                                                 |
|           A senha está dentro da imagem "spypass.png"           |
|                                                                 |
|        https://sup3r-us3r.github.io/spyquiz/level7.jpg          |
|_________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "2c0f3ada9e5d314d9c5a37dc638a6df186882c492c179ea746b63d053a7cef558b2ae3876eff556c82fe2c0ce232c8b576b52b4efcd6209c1f35ff49c2825e58" #spyquizesteganografia
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco7()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco8()
	elif opcao1 == "2":
		Bloco8()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco7() 
Example 23
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco8():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #8: ASCII - Dec
 ______________________________________________________________________________
|                                                                              |
|                           Ache a senha...                                    |
|                                                                              |
|      | (35) | (83) | (112) | (121) | (65) | (83) | (67) | (73) | (73) |      |
|______________________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "cd0eca5dbd9e4d6534854807b48aa1a3acb254031756ce281194228d3c6d892058f150d24b2e4cd643248ca3bb41a136da2109245dae985bd126016759c065db" # #SpyASCII
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco8()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco9()
	elif opcao1 == "2":
		Bloco9()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco8() 
Example 24
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco9():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #9: Base64
 ____________________________________________
|                                            |
|      YmFzZTY0LWRlY29kZS1zdWNjZXNzZnVs      |
|____________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "1d427a35aedcdc4fcf5bb729d46a00c3ce5d7832640fcfe70d97a84dc22fc2d53e35571a8fbf6085941e73b5fbd7af06d7c289a35fac59f1d62374cc442e3358" #base64-decode-successful
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco9()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco10()
	elif opcao1 == "2":
		Bloco10()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco9() 
Example 25
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco11():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #11: Espectograma
 __________________________________________________________________________
|                                                                          |
|      Faça um espectograma no arquivo "hex.wav" para achar a resposta     |
|                                                                          |
|       Para ouvir: https://sup3r-us3r.github.io/spyquiz/level11.wav       |
|__________________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "211824f7f2736ce7e4acfa07649561188fbd0c39de4f5fd20483c6bb15f327146086b62edefb8e7213b2a2eda07720786b4587e97856c22904f7f175b1e40fbe" #AO44F
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco11()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco12()
	elif opcao1 == "2":
		Bloco12()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco11() 
Example 26
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco13():
	p = True
	q1 = False
	q2 = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #13: Leia o enunciado
 ____________________________________________________
|                                                    |
|      A senha para o próximo nível é: embinario     |
|____________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q1 and p != q2:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q1 = "e59d0329d6c9e23abc8b287107ddc9281defff1af776133ed618859da59b63c943b019f7603d8344d8eb2d36851234a59c75afa70c1d317fd7676c22e3f5c71f" #01100101 01101101 01100010 01101001 01101110 01100001 01110010 01101001 01101111
			q2 = "452f7d4966a7815f665b4f97204331e114063251ef90ac4c19732fbd54977a5c1a159b04c903e918c755bbc475ab4acf239f9e1ee8ce801329b878c53229bd41" #011001010110110101100010011010010110111001100001011100100110100101101111
			if p != q1 and p != q2:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco13()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco14()
	elif opcao1 == "2":
		Bloco14()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco13() 
Example 27
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco14():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #14: Octal
 _______________________________________________________
|                                                       |
|      A senha para o próximo nível é: octaleumadlç     |
|_______________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "73229a1024cec29476fd179cb89b1abf74d0b6cc028976a1a62cd9477f8bcdb6fca37fa428c5558ecf5218f112cb7ff2b05833c88f4a736a3f8a531a640753ad" #157 143 164 141 154 145 165 155 141 144 154 303 247
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco14()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco15()
	elif opcao1 == "2":
		Bloco15()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco14() 
Example 28
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco15():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #15: Hexa
 ______________________________________________________________________
|                                                                      |
|      A senha para o próximo nível é: ta_achando_facil_ne_moleque     |
|______________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "a5614ff46a800ce96fe21c00173a12006a92653088fc0d354df738da404ddacda51d73d20a135194fafdfa7c9f2e119b0dffe68337733b0bf54838558302dd7e" #74 61 5f 61 63 68 61 6e 64 6f 5f 66 61 63 69 6c 5f 6e 65 5f 6d 6f 6c 65 71 75 65
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco15()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco16()
	elif opcao1 == "2":
		Bloco16()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco15() 
Example 29
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco18():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #18: X da questão
 ________________________________________
|                                        |
|      A*5 - B^7 + C%2 + D sin 3214      |
|                                        |
|      A=15  B=12  C=7   D=13            |
|________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "84b214c42250dbcb999167a5aa9f240d805655a8fca7574d7c7e18682e85b0ad0e643ca5a7c3e18871259b69a85519a2d62b9a7d9edc2105139b296bcbe9effe" #-35831733.9519
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco18()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco19()
	elif opcao1 == "2":
		Bloco19()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco18() 
Example 30
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco19():
	p = True
	q1 = False
	q2 = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #19: Se vire
 ______________________________________________________________________________________________________________
|                                                                                                              |
|      ... ..- .- / ... . -. .... .- / . / -- --- .-. ... . -.-. --- -.. . -. . -..- - .-.. . ...- . .-..      |
|                                                                                                              |
|      Para ouvir: https://sup3r-us3r.github.io/spyquiz/level19.wav                                            |
|______________________________________________________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q1 and p != q2:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q1 = "f30c7b68f3b8624dc10080a80f1dde2e68643bf7d47dc75ec71e5980178b91ffa74ba53e1c0b26bbacc8130ca594787a697ba2eb33d748db89df78aa941d1d79" #MORSECODENEXTLEVEL
			q2 = "b437f52e979bb57f95f5a67b68d604e6b83d972ba476f95ea0a483c0631ccfa535ca3761cb88f427b5cbcae902401c33d3f68f27b1c8d80523f0fd57fcc30302" #morsecodenextlevel
			if p != q1 and p != q2:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco19()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco20()
	elif opcao1 == "2":
		Bloco20()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco19() 
Example 31
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco21():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #21: Arabica2rs
 _______________________________________________________________________
|                                                                       |
|                             Ache a senha...                           |
|                                                                       |
|      ىﺿ أﺹ طبنرغﺿ أﺹ ﺿ ی ا ﺿىة ﺿ اىﺿأﺹحغ كز بن ح ب ﻑحغكزب ن ح بش      |
|_______________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "3ff7b5f3519791e03cbfde2c667189e32b5a1de1df7781dc6a99110621b311f94a0b4fa6c3456e5e60af911fc1d6da18a7e09cf6606a7e4f6ffb8b80c39eae63" #taquente-taquente
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco21()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco22()
	elif opcao1 == "2":
		Bloco22()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco21() 
Example 32
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco23():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #23: Atom128
 ___________________________________________________________________
|                                                                   |
|      A senha para o próximo nível é 15 vezes a desencriptação     |
|___________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		print("")
		os.system("curl https://raw.githubusercontent.com/Sup3r-Us3r/sup3r-us3r.github.io/master/spyquiz/level23.txt | lolcat")
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "b3efba35d9f9249c2d9bd51311ac60a7d1c9cd46c6aef60b03798f250ae708dfea06ab31d323e274380f5fe7138d01dc651a7bc95cf8d0599fb188e872c88c70" #sup3r-us3r
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco23()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco24()
	elif opcao1 == "2":
		Bloco24()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco23() 
Example 33
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco24():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #24: Escuro
 _____________________________________________________________
|                                                             |
|                         Está escuro!                        |
|                                                             |
|      https://sup3r-us3r.github.io/spyquiz/level24.html      |
|_____________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "96f4aab59ec41e6ccf0f7900110605e1a862ee88cdfe6b15e12f2279802e74825eee87185a2f171eadde5af71edfbcc2bc05de8d307030970ac69496343b27c0" #milleniumfalcon
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco24()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco25()
	elif opcao1 == "2":
		Bloco25()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco24() 
Example 34
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco25():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #25: Trabalhando e desencriptando
 _____________________________________________________________
|                                                             |
|      https://sup3r-us3r.github.io/spyquiz/level25.html      |
|_____________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "8c865996b232749856eaaa84beca73f7f7899c0f5b156c1937e5fbe00da2fdc622189f668e55bdced8ed0776e8e2a67635199caabaef9f079c050d617f04ff07" #neverland
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco25()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco26()
	elif opcao1 == "2":
		Bloco26()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco25() 
Example 35
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco26():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #26: <i>
 ______________________________________________________________
|                                                              |
|      https://sup3r-us3r.github.io/spyquiz/level26.html       |
|______________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "b2f94334d36dc26df98176c80a9a91678fbf094d8062008625e86f351feac9de953f5c56c54a208ae7c24856846a090ec00eb3b3c44eaad9edd2d54a8c860ac1" #LIPF!
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco26()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco27()
	elif opcao1 == "2":
		Bloco27()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco26() 
Example 36
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco27():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #27: Nazca Lines
 _____________________________________________________________
|                                                             |
|      https://sup3r-us3r.github.io/spyquiz/level27.html      |
|_____________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "3aa3c49aa5bd035ced20abdc76c69115d650bb79bed7310ebdc4a5af75910bfa5fd2f687118821b533b39d3c680530ef77d0c1aea1c9ea3d1e0c74c67b0d8f4b" #thething
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco27()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco28()
	elif opcao1 == "2":
		Bloco28()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco27() 
Example 37
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco29():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #29: Adam Smith
 _____________________________________________________________
|                                                             |
|      https://sup3r-us3r.github.io/spyquiz/level29.html      |
|_____________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "cebfea666f6685057dedccfaa31238068ae56c7e465fec31835d8e320a17caf268f0a303f6d109b7484cbe2522c4806106d589c6b252f4e46a219e5318afaa40" #sdasdasddas
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco29()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco30()
	elif opcao1 == "2":
		Bloco30()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco29() 
Example 38
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 5 votes vote down vote up
def Bloco30():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #30: The End
 _____________________________________________________________
|                                                             |
|      https://sup3r-us3r.github.io/spyquiz/level30.html      |
|_____________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "30161ddbc5c1a80f90e37350b3e0f937902330ed9a4431143dd02690ddfe343eac7abd7066be22959bfeed91870d5ac85f3fe5f89f2d5b87c939f71ae4bbc121" #superuserfim
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco30()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		os.system(Limpar)
		FimDoDesafio()
	elif opcao1 == "2":
		os.system(Limpar)
		FimDoDesafio()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco30() 
Example 39
Project: crypto-trader   Author: sgiy   File: Poloniex.py    GNU General Public License v3.0 5 votes vote down vote up
def private_sign_request(self, string_to_sign):
        return hmac.new(self._API_SECRET.encode(), string_to_sign.encode(), hashlib.sha512).hexdigest() 
Example 40
Project: crypto-trader   Author: sgiy   File: Bittrex.py    GNU General Public License v3.0 5 votes vote down vote up
def private_request(self, command, extra=''):
        try:
            nonce = str(int(time.time()*1000))
            request_url = self._BASE_URL + command + '?' + 'apikey=' + self._API_KEY + "&nonce=" + nonce + extra
            result = requests.get(
                request_url,
                headers={"apisign": hmac.new(self._API_SECRET.encode(),
                                             request_url.encode(),
                                             hashlib.sha512
                                             ).hexdigest()
                         }
            ).json()
            if result.get('success', None):
                self.log_request_success()
                return result['result']
            else:
                self.log_request_error(result['message'])
                if self.retry_count_not_exceeded():
                    return self.private_request(command, extra)
                else:
                    return {}

        except Exception as e:
            self.log_request_error(str(e))
            if self.retry_count_not_exceeded():
                return self.private_request(command, extra)
            else:
                return {}

    # ############################################
    # ##### Exchange specific public methods #####
    # ############################################ 
Example 41
Project: certidude   Author: laurivosandi   File: request.py    MIT License 5 votes vote down vote up
def on_get(self, req, resp, cn):
        """
        Fetch certificate signing request as PEM
        """

        try:
            path, buf, _, submitted = self.authority.get_request(cn)
        except errors.RequestDoesNotExist:
            logger.warning("Failed to serve non-existant request %s to %s",
                cn, req.context.get("remote_addr"))
            raise falcon.HTTPNotFound()

        resp.set_header("Content-Type", "application/pkcs10")
        logger.debug("Signing request %s was downloaded by %s",
            cn, req.context.get("remote_addr"))

        preferred_type = req.client_prefers(("application/json", "application/x-pem-file"))

        if preferred_type == "application/x-pem-file":
            # For certidude client, curl scripts etc
            resp.set_header("Content-Type", "application/x-pem-file")
            resp.set_header("Content-Disposition", ("attachment; filename=%s.pem" % cn))
            resp.body = buf
        elif preferred_type == "application/json":
            # For web interface events
            resp.set_header("Content-Type", "application/json")
            resp.set_header("Content-Disposition", ("attachment; filename=%s.json" % cn))
            resp.body = json.dumps(dict(
                submitted = submitted,
                common_name = cn,
                address = getxattr(path, "user.request.address").decode("ascii"), # TODO: move to authority.py
                md5sum = hashlib.md5(buf).hexdigest(),
                sha1sum = hashlib.sha1(buf).hexdigest(),
                sha256sum = hashlib.sha256(buf).hexdigest(),
                sha512sum = hashlib.sha512(buf).hexdigest()), cls=MyEncoder)
        else:
            raise falcon.HTTPUnsupportedMediaType(
                "Client did not accept application/json or application/x-pem-file") 
Example 42
Project: crackdb   Author: kryc   File: crackdb.py    GNU General Public License v3.0 5 votes vote down vote up
def algoSha512(word):
    return hashlib.sha512(word).digest() 
Example 43
Project: jawfish   Author: war-and-code   File: random.py    MIT License 5 votes vote down vote up
def seed(self, a=None, version=2):
        """Initialize internal state from hashable object.

        None or no argument seeds from current time or from an operating
        system specific randomness source if available.

        For version 2 (the default), all of the bits are used if *a* is a str,
        bytes, or bytearray.  For version 1, the hash() of *a* is used instead.

        If *a* is an int, all bits are used.

        """

        if a is None:
            try:
                a = int.from_bytes(_urandom(32), 'big')
            except NotImplementedError:
                import time
                a = int(time.time() * 256) # use fractional seconds

        if version == 2:
            if isinstance(a, (str, bytes, bytearray)):
                if isinstance(a, str):
                    a = a.encode()
                a += _sha512(a).digest()
                a = int.from_bytes(a, 'big')

        super().seed(a)
        self.gauss_next = None 
Example 44
Project: blockhash   Author: Spockuto   File: mains.py    MIT License 5 votes vote down vote up
def hashing(piece):
    if args.sha1:
        return str(hashlib.sha1(piece).hexdigest())
    elif args.sha224:
        return str(hashlib.sha224(piece).hexdigest())
    elif args.sha256:
        return str(hashlib.sha256(piece).hexdigest())
    elif args.sha384:
        return str(hashlib.sha384(piece).hexdigest())
    elif args.sha512:
        return str(hashlib.sha512(piece).hexdigest())
    else:
        raise ValueError('Specify a Hash function') 
Example 45
Project: blockhash   Author: Spockuto   File: mains.py    MIT License 5 votes vote down vote up
def main():

    parser = ArgumentParser(description="Speed up your SHA. A different hash style.")
    parser.add_argument('-1', '--sha1', action='store_true')
    parser.add_argument('-2', '--sha224', action='store_true')
    parser.add_argument('-3', '--sha256', action='store_true')
    parser.add_argument('-4', '--sha384', action='store_true')
    parser.add_argument('-5', '--sha512', action='store_true')
    parser.add_argument('-f', '--file', type=str, help="The path to the file")
    parser.add_argument('-s', '--size', type=int, help="The size of the chunks")

    if len(sys.argv) == 1:
        parser.print_help()
        return

    global args
    args = parser.parse_args()

    if not args.size:
        args.size =  20971520
        
    hashtree = ''

    big_file = open(args.file, 'rb')
    pool = Pool(multiprocessing.cpu_count())

    for chunk_hash in pool.imap(hashing, chunks(big_file, args.size)):
        hashtree += chunk_hash + ":hash"
    pool.terminate()

    print(str(hashing(hashtree.encode('ascii')))) 
Example 46
Project: Repobot   Author: Desgard   File: test_pyecdsa.py    MIT License 5 votes vote down vote up
def test_4(self):
        self._do(
            generator=NIST192p.generator,
            secexp = int("6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4", 16),
            hsh = sha512(b("sample")).digest(),
            hash_func = sha512,
            expected = int("A2AC7AB055E4F20692D49209544C203A7D1F2C0BFBC75DB1", 16)) 
Example 47
Project: Repobot   Author: Desgard   File: test_pyecdsa.py    MIT License 5 votes vote down vote up
def test_7(self):
        self._do(
            generator=NIST192p.generator,
            secexp = int("6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4", 16),
            hsh = sha512(b("test")).digest(),
            hash_func = sha512,
            expected = int("0758753A5254759C7CFBAD2E2D9B0792EEE44136C9480527", 16)) 
Example 48
Project: Repobot   Author: Desgard   File: test_pyecdsa.py    MIT License 5 votes vote down vote up
def test_10(self):
        self._do(
            generator=NIST521p.generator,
            secexp = int("0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538", 16),
            hsh = sha512(b("test")).digest(),
            hash_func = sha512,
            expected = int("16200813020EC986863BEDFC1B121F605C1215645018AEA1A7B215A564DE9EB1B38A67AA1128B80CE391C4FB71187654AAA3431027BFC7F395766CA988C964DC56D", 16)) 
Example 49
Project: Repobot   Author: Desgard   File: djbec.py    MIT License 5 votes vote down vote up
def H(m):
    return hashlib.sha512(m).digest() 
Example 50
Project: cottontail   Author: QKaiser   File: utils.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def crack(hashed, candidate, method="rabbit_password_hashing_md5"):
    """
    You can dump password hashes if you have administrator privileges. This
    is a simple attempt at writing a cracking function :)

    Documentation on rabbitmq hashes https://www.rabbitmq.com/passwords.html

    Args:
        hashed (str): password hash
        candidate (str): plaintext to compare hash to
        method (str): rabbitmq hashing method

    Returns:
        boolean. True if valid candidate, False otherwise.
    """
    decoded = base64.b64decode(hashed).encode('hex')
    hex_salt = decoded[0:8]
    hex_hash = decoded[8:]
    if method == "rabbit_password_hashing_md5":
        hex_hash_candidate = hashlib.md5(
            hex_salt.decode('hex') + candidate
        ).hexdigest()
    elif method == "rabbit_password_hashing_sha256":
        hex_hash_candidate = hashlib.sha256(
            hex_salt.decode('hex') + candidate
        ).hexdigest()
    elif method == "rabbit_password_hashing_sha512":
        hex_hash_candidate = hashlib.sha512(
            hex_salt.decode('hex') + candidate
        ).hexdigest()
    else:
        raise Exception("Hashing method '{}' not supported".format(method))
    return hex_hash == hex_hash_candidate 
Example 51
Project: code-base-investigator   Author: intel   File: preprocessor.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __compute_file_hash(self):
        chunk_size = 4096
        hasher = hashlib.sha512()
        with open(self.filename, 'rb') as in_file:
            for chunk in iter(lambda: in_file.read(chunk_size), b""):
                hasher.update(chunk)

        return hasher.hexdigest() 
Example 52
Project: hsds   Author: HDFGroup   File: authUtil.py    Apache License 2.0 5 votes vote down vote up
def validatePasswordSHA512(app, username, password):
    user_db = app["user_db"]
    if username not in user_db:
        log.info("SHA512 check for username: {}".format(username))
        salt = config.get("PASSWORD_SALT")
        hex_hash = hashlib.sha512(username.encode('utf-8') + salt.encode('utf-8')).hexdigest()
        if hex_hash[:32] != password:
            log.warn("user password is not valid (didn't equal sha512 hash) for user: {}".format(username))
            raise HTTPUnauthorized()  # 401
        log.info("Saving user/password to user_db for: {}".format(username))
        user_data = {"pwd": password}
        user_db[username] = user_data 
Example 53
Project: stoq   Author: PUNCH-Cyber   File: __init__.py    Apache License 2.0 5 votes vote down vote up
def get_sha512(content: bytes) -> str:
    """
    Return SHA512 hash of bytes

    """
    return hashlib.sha512(content).hexdigest() 
Example 54
Project: beowulf-python   Author: beowulf-foundation   File: wallet_file.py    MIT License 5 votes vote down vote up
def derive_checksum(s):
        checksum = hashlib.sha512(compat_bytes(s, "ascii")).hexdigest()
        return checksum 
Example 55
Project: beowulf-python   Author: beowulf-foundation   File: account.py    MIT License 5 votes vote down vote up
def get_private(self):
        """ Derive private key from the brain key and the current sequence
            number
        """
        encoded = "%s %d" % (self.brainkey, self.sequence)
        a = compat_bytes(encoded, 'ascii')

        s = hashlib.sha256(hashlib.sha512(a).digest()).digest()
        return PrivateKey(hexlify(s).decode('ascii')) 
Example 56
Project: beowulf-python   Author: beowulf-foundation   File: account.py    MIT License 5 votes vote down vote up
def derivesha512address(self):
        """ Derive address using ``RIPEMD160(SHA512(x))`` """
        pkbin = unhexlify(repr(self._pubkey))
        addressbin = ripemd160(hexlify(hashlib.sha512(pkbin).digest()))
        return Base58(hexlify(addressbin).decode('ascii')) 
Example 57
Project: beowulf-python   Author: beowulf-foundation   File: memo.py    MIT License 5 votes vote down vote up
def init_aes(shared_secret, nonce):
    """ Initialize AES instance

        :param hex shared_secret: Shared Secret to use as encryption key
        :param int nonce: Random nonce
        :return: AES instance and checksum of the encryption key
        :rtype: length 2 tuple

    """
    " Seed "
    ss = unhexlify(shared_secret)
    n = struct.pack("<Q", int(nonce))
    encryption_key = hashlib.sha512(n + ss).hexdigest()
    " Check'sum' "
    check = hashlib.sha256(unhexlify(encryption_key)).digest()
    check = struct.unpack_from("<I", check[:4])[0]
    " AES "
    key = unhexlify(encryption_key[0:64])
    iv = unhexlify(encryption_key[64:96])
    return AES.new(key, AES.MODE_CBC, iv), check 
Example 58
Project: orionx-api-client   Author: itolosa   File: transport.py    MIT License 5 votes vote down vote up
def hmac_sha512(secret_key, timestamp, body):
  key = bytearray(secret_key, 'utf-8')
  msg = str(timestamp) + str(body)
  msg = msg.encode('utf-8')
  return hmac.HMAC(key, msg, sha512).hexdigest() 
Example 59
Project: TornadoWeb   Author: VxCoder   File: util.py    Apache License 2.0 5 votes vote down vote up
def sha512(val):
        
        val = utf8(val)
        
        return hashlib.sha512(val).hexdigest() 
Example 60
Project: KumasCookbook   Author: ChocolaKuma   File: HashingStrings.py    MIT License 5 votes vote down vote up
def hashIt(key_string,HashAlgr="md5"):    
    key_string = key_string.encode('utf-8')
    if(HashAlgr == "md5"):
        e_pass = hashlib.md5(key_string).hexdigest()       
    elif(HashAlgr == "sha1"):
        e_pass = hashlib.sha1(key_string).hexdigest()        
    elif(HashAlgr == "sha224"):
        e_pass = hashlib.sha224(key_string).hexdigest()
    elif(HashAlgr == "sha256"):
        e_pass = hashlib.sha256(key_string).hexdigest()
    elif(HashAlgr == "sha512"):
        e_pass = hashlib.sha512(key_string).hexdigest()     
    return e_pass 
Example 61
Project: Flask_Blog   Author: sugarguo   File: flask_login.py    GNU General Public License v3.0 5 votes vote down vote up
def make_secure_token(*args, **options):
    '''
    This will create a secure token that you can use as an authentication
    token for your users. It uses heavy-duty HMAC encryption to prevent people
    from guessing the information. (To make it even more effective, if you
    will never need to regenerate the token, you can  pass some random data
    as one of the arguments.)

    :param \*args: The data to include in the token.
    :type args: args
    :param \*\*options: To manually specify a secret key, pass ``key=THE_KEY``.
        Otherwise, the ``current_app`` secret key will be used.
    :type \*\*options: kwargs
    '''
    key = options.get('key')
    key = _secret_key(key)

    l = [s if isinstance(s, bytes) else s.encode('utf-8') for s in args]

    payload = b'\0'.join(l)

    token_value = hmac.new(key, payload, sha512).hexdigest()

    if hasattr(token_value, 'decode'):  # pragma: no cover
        token_value = token_value.decode('utf-8')  # ensure bytes

    return token_value 
Example 62
Project: Flask_Blog   Author: sugarguo   File: flask_login.py    GNU General Public License v3.0 5 votes vote down vote up
def _cookie_digest(payload, key=None):
    key = _secret_key(key)

    return hmac.new(key, payload.encode('utf-8'), sha512).hexdigest() 
Example 63
Project: Flask_Blog   Author: sugarguo   File: flask_login.py    GNU General Public License v3.0 5 votes vote down vote up
def _create_identifier():
    user_agent = request.headers.get('User-Agent')
    if user_agent is not None:
        user_agent = user_agent.encode('utf-8')
    base = '{0}|{1}'.format(_get_remote_addr(), user_agent)
    if str is bytes:
        base = unicode(base, 'utf-8', errors='replace')  # pragma: no cover
    h = sha512()
    h.update(base.encode('utf8'))
    return h.hexdigest() 
Example 64
Project: Quiver-alfred   Author: danielecook   File: sqlite_udf.py    MIT License 5 votes vote down vote up
def sha512(*vals):
    return _hash(hashlib.sha512) 
Example 65
Project: NiujiaoDebugger   Author: MrSrc   File: random.py    GNU General Public License v3.0 5 votes vote down vote up
def seed(self, a=None, version=2):
        """Initialize internal state from hashable object.

        None or no argument seeds from current time or from an operating
        system specific randomness source if available.

        If *a* is an int, all bits are used.

        For version 2 (the default), all of the bits are used if *a* is a str,
        bytes, or bytearray.  For version 1 (provided for reproducing random
        sequences from older versions of Python), the algorithm for str and
        bytes generates a narrower range of seeds.

        """

        if version == 1 and isinstance(a, (str, bytes)):
            a = a.decode('latin-1') if isinstance(a, bytes) else a
            x = ord(a[0]) << 7 if a else 0
            for c in map(ord, a):
                x = ((1000003 * x) ^ c) & 0xFFFFFFFFFFFFFFFF
            x ^= len(a)
            a = -2 if x == -1 else x

        if version == 2 and isinstance(a, (str, bytes, bytearray)):
            if isinstance(a, str):
                a = a.encode()
            a += _sha512(a).digest()
            a = int.from_bytes(a, 'big')

        super().seed(a)
        self.gauss_next = None 
Example 66
Project: NiujiaoDebugger   Author: MrSrc   File: test_hmac.py    GNU General Public License v3.0 5 votes vote down vote up
def test_sha512_rfc4231(self):
        self._rfc4231_test_cases(hashlib.sha512, 'sha512', 64, 128) 
Example 67
Project: org_attach   Author: Ezibenroc   File: org_attach.py    MIT License 5 votes vote down vote up
def crypto_hash(cls, filename):
        # https://stackoverflow.com/a/3431838/4110059
        h = hashlib.sha512()
        with open(filename, "rb") as f:
            for chunk in iter(lambda: f.read(4096), b""):
                h.update(chunk)
        return h.hexdigest() 
Example 68
Project: NordVPN-NetworkManager-Gui   Author: vfosterm   File: nord_nm_gui.py    GNU General Public License v3.0 4 votes vote down vote up
def verify_credentials(self):
        """
        Requests a token, salt and key from Nord api
        Sends a final hash of (salt+password)+key and token to Nord api
        Verifies responses and updates GUI
        """
        if self.user_input.text() and self.password_input.text():
            self.statusbar.showMessage('Login Success', 2000)
            self.username = self.user_input.text()
            self.password = self.password_input.text()
            self.repaint()
            time.sleep(0.5)
            self.hide()
            self.main_ui()
        else:
            self.statusbar.showMessage('Username or password field cannot be empty, 2000')
        # try:
        #     resp = requests.get('https://apself.statusbar.showMessage('Login Success', 2000)
    #                         self.username = self.user_input.text()
    #                         self.password = self.password_input.text()
    #                         self.repaint()
    #                         time.sleep(0.5)
    #                         self.hide()
    #                         self.main_ui()i.nordvpn.com/token/token/' + self.user_input.text(), timeout=5)
        #
        #     if resp.status_code == requests.codes.ok:
        #         token_json = json.loads(resp.text)
        #         token = token_json['token']
        #         salt = token_json['salt']
        #         key = token_json['key']
        #
        #         password_hash = hashlib.sha512(salt.encode() + self.password_input.text().encode())
        #         final_hash = hashlib.sha512(password_hash.hexdigest().encode() + key.encode())
        #
        #         try:
        #             resp = requests.get('https://api.nordvpn.com/token/verify/' + token + '/' + final_hash.hexdigest(), timeout=5)
        #             if resp.status_code == requests.codes.ok:
        #                 self.statusbar.showMessage('Login Success', 2000)
        #                 self.username = self.user_input.text()
        #                 self.password = self.password_input.text()
        #                 self.repaint()
        #                 time.sleep(0.5)
        #                 self.hide()
        #                 self.main_ui()
        #             else:
        #                 self.statusbar.showMessage('Invalid Credentials', 2000)
        #                 self.user_input.clear()
        #                 self.password_input.clear()
        #                 self.user_input.setFocus()
        #         except Exception as ex:
        #             self.statusbar.showMessage('Invalid Credentials', 2000)
        #             self.user_input.clear()
        #             self.password_input.clear()
        #             self.user_input.setFocus()
        #     else:
        #         self.statusbar.showMessage("API Error: could not fetch token", 2000)
        # except Exception as ex:
        #     self.statusbar.showMessage("API Error: could not fetch token", 2000)
        #     self.get_api_data() 
Example 69
Project: bitmm   Author: thmp   File: hitbtc.py    MIT License 4 votes vote down vote up
def sendSignedPostRequest(self, uri, postData):
        signature = hmac.new(self.secret, msg=uri+postData, digestmod=hashlib.sha512).digest().encode("hex")
        r = requests.post(self.endpoint + uri, headers={"X-Signature": signature}, data=postData)
        #print r, r.text, r.json()
        return r.json() 
Example 70
Project: AshsSDK   Author: thehappydinoa   File: djbec.py    MIT License 4 votes vote down vote up
def H(m):
    return hashlib.sha512(m).digest() 
Example 71
Project: joeecc   Author: johndoe31415   File: PrivKeyOps.py    GNU General Public License v3.0 4 votes vote down vote up
def __eddsa_hash(data):
		return hashlib.sha512(data).digest() 
Example 72
Project: joeecc   Author: johndoe31415   File: Tools.py    GNU General Public License v3.0 4 votes vote down vote up
def eddsa_hash(data):
	"""Returns the message digest over the data which is used for EdDSA
	(SHA-512)."""
	return hashlib.sha512(data).digest() 
Example 73
Project: MyDotfiles   Author: Sup3r-Us3r   File: hashcodeenglish.py    GNU General Public License v3.0 4 votes vote down vote up
def Sha512():
	Apresentacao()
	mystring = input("\033[32mPLACE THE TEXT YOU WANT TO ENCRYPT IN SHA512\033[1;m: ")
	hash_object = hashlib.sha512(mystring.encode())
	print("")
	print(hash_object.hexdigest())
	print("")
	Again("\n\033[1;36mDESIRE TO DO ANOTHER ENCODE IN SHA512 (y/n) ?:\033[1;m ", Sha512) 
Example 74
Project: MyDotfiles   Author: Sup3r-Us3r   File: hashcode.py    GNU General Public License v3.0 4 votes vote down vote up
def Sha512():
	Apresentacao()
	mystring = input("\033[32mCOLOQUE O TEXTO QUE QUEIRA ENCRIPTAR EM SHA512\033[1;m: ")
	hash_object = hashlib.sha512(mystring.encode())
	print("")
	print(hash_object.hexdigest())
	print("")
	Again("\n\033[1;36mDESEJA FAZER OUTRO ENCODE EM SHA512 (s/n) ?:\033[1;m ", Sha512) 
Example 75
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 4 votes vote down vote up
def Bloco2():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #2: Leitura de codigo fonte (Programação)
 ______________________________________________________________________________________________
|                                                                                              |
|      Iremos apresentar um código fonte, de uma página web específica dentro do meu site      |
|                                                                                              |
|             Você terá que encontra a senha para passar, e ir pro nível seguinte.             |
|______________________________________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		print("""\033[35m

 █    ██  ██▀███   ██▓          ██▓███ ▓██   ██▓
 ██  ▓██▒▓██ ▒ ██▒▓██▒         ▓██░  ██▒▒██  ██▒
▓██  ▒██░▓██ ░▄█ ▒▒██░         ▓██░ ██▓▒ ▒██ ██░
▓▓█  ░██░▒██▀▀█▄  ▒██░         ▒██▄█▓▒ ▒ ░ ▐██▓░
▒▒█████▓ ░██▓ ▒██▒░██████▒ ██▓ ▒██▒ ░  ░ ░ ██▒▓░
░▒▓▒ ▒ ▒ ░ ▒▓ ░▒▓░░ ▒░▓  ░ ▒▓▒ ▒▓▒░ ░  ░  ██▒▒▒ 
░░▒░ ░ ░   ░▒ ░ ▒░░ ░ ▒  ░ ░▒  ░▒ ░     ▓██ ░▒░ 
 ░░░ ░ ░   ░░   ░   ░ ░    ░   ░░       ▒ ▒ ░░  
   ░        ░         ░  ░  ░           ░ ░     
                            ░           ░ ░\033[1;m

""")
		print("\033[31mAguarde\033[1;m\033[32m...\033[1;m")
		sleep(2)
		os.system("curl https://sup3r-us3r.github.io/spyquiz/level2.txt")
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "3250d88f8bd55e62ae3f769b9bdce1854bac2f645da0a982e6c68e2884c87b2b7d0bf62da7c3b21aa4d426d6d5223c111646f05f4fbdc7a4b6fafe1b6ad25823" #Penetration Tester's
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco2()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco3()
	elif opcao1 == "2":
		Bloco3()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco2() 
Example 76
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 4 votes vote down vote up
def Bloco6():
	login = True
	senha = True
	q1 = False
	q2 = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #6: Usando camadas
 _____________________________________________________________
|                                                             |
|         O login e senha está no arquivo "level6.psd"        |
|                                                             |
|        http://sup3r-us3r.github.io/spyquiz/level6.psd       |
|_____________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while login != q1 and senha != q2:
			login = input("\n\033[1;32m[*] Login: \033[1;m")
			login = hashlib.sha512(login.encode('utf-8'))
			login = login.hexdigest()
			senha = input("\033[1;32m[*] Senha: \033[1;m")
			senha = hashlib.sha512(senha.encode('utf-8'))
			senha = senha.hexdigest()
			q1 = "5667ae23cdbefe166f2e06d442375516cfaaad6aa1363f941309ec1aa1d130bfb33a32a5419a9093ab037881016f66c6796f16f4a2d5be6fb647aa9a56dec303" #tecnologia
			q2 = "985aa195c09fb7d64a4bb24cfe51fb1f13ebc444c494e765ee99d6c3ef46557c757787f8f5a6e0260d2e0e846d263fbfbe1311c884bb0bf9792f8778a4434327" #hacker
			if login != q1 or senha != q2:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco6()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco7()

	elif opcao1 == "2":
		Bloco7()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco6() 
Example 77
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 4 votes vote down vote up
def Bloco12():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #12: Matemática
 _________________________________________________________________________
|                            |                                            |
|      M + M + M = 1080      |      E + 3º Termo da PG (2,4,...) = I      |
|                            |                                            |
|      M + A + A = 1314      |      I + Log4 64=x                         |
|                            |____________________________________________|
|      A + T + T = 511       |                                            |
|                            | Dica:                                      |
|      A + T x M = E         |      print("Ache a resposta final :D")     |
|____________________________|____________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "a81af4e6fada061924e905358091bca96af72705a2177b78dda9032b75b1668aa1dd09ae0d986c33bd594102a2241933a9594268717869d3d1b0730c52866faf" #6608
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco12()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco13()
	elif opcao1 == "2":
		Bloco13()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco12() 
Example 78
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 4 votes vote down vote up
def Bloco17():
	p = True
	q = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #17: Japa
 _________________________________________________________________________________
|                                                                                 |
|      É dessa vez as coisas vão mudar, ache a senha que esta criptografada       |
|_________________________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		print("")
		print("\033[31mAguarde até a senha criptografada aparecer\033[1;m\033[32m...\033[1;m")
		sleep(3)
		print("")
		os.system("curl https://raw.githubusercontent.com/Sup3r-Us3r/sup3r-us3r.github.io/master/spyquiz/level17.txt")
		while p != q:
			p = input("\n\033[1;36mResposta: \033[1;m")
			p = hashlib.sha512(p.encode('utf-8'))
			p = p.hexdigest()
			q = "4df1510bbaab42cccd08bed15a439bd1baf1aee48dbd5b7165bf4de3e90636778fef155a078cf9b3885c84d0cd2d51a274476f47a2d97017467ee4eca6167c76" #Elliot
			if p != q:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco17()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco18()
	elif opcao1 == "2":
		Bloco18()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco17() 
Example 79
Project: MyDotfiles   Author: Sup3r-Us3r   File: spyquiz.py    GNU General Public License v3.0 4 votes vote down vote up
def Bloco20():
	login = True
	senha = True
	q1 = False
	q2 = False
	Apresentacao()
	print('''
[\033[1;32m*\033[1;m] Nível - #20: Vasculhando

[\033[1;91m!\033[1;m] OBS: O jogo está virando não é mesmo, começamos de baixo e estamos subindo.
 _______________________________________________________________________
|                                                                       |
|      Ache o login e senha que está em algum lugar do meu site ;)      |
|                                                                       |
|      https://sup3r-us3r.github.io/spyquiz/level20.html                |
|_______________________________________________________________________|

\033[31m1\033[1;m) Responder
\033[31m2\033[1;m) Pular
\033[31m3\033[1;m) Sair
''')
	opcao1 = input("\033[1;36mOpção:\033[1;m ")
	if opcao1 == "1":
		while login != q1 and senha != q2:
			login = input("\n\033[1;32m[*] Login: \033[1;m")
			login = hashlib.sha512(login.encode('utf-8'))
			login = login.hexdigest()
			senha = input("\033[1;32m[*] Senha: \033[1;m")
			senha = hashlib.sha512(senha.encode('utf-8'))
			senha = senha.hexdigest()
			q1 = "c7809fd363e6dc44fb735fd086ea623fae16762c79d4c810e5d9fc1d7514b5d1ed1f646c042f3cd131fe90cd774b029e7a64904a969cd77c0dcb9e58e4134630" #Spy:D
			q2 = "497fe595951961337b77f1188333992ea20fe1c0faf1fdfe484613e0462b343fdea3d3752489b1392cff0e38310aa9133c4de9c2651bef731fec59a8a2f0a107" #Quiz!
			if login != q1 or senha != q2:
				print("\n[\033[1;91m!\033[1;m] Resposta incorreta.")
				input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
				Bloco20()
		print("\n\033[1;32m[*] Resposta correta!\033[1;m\n")
		input("\n\033[1;36mPressione ENTER para continuar...\033[1;m ")
		Bloco21()
	elif opcao1 == "2":
		Bloco21()
	elif opcao1 == "3":
		exit(1)
	else:
		ComandoNaoEncontrado()
		input("\n\033[1;36mPressione ENTER para tentar novamente...\033[1;m ")
		Bloco20() 
Example 80
Project: hacking-tools   Author: girishramnani   File: _pfish_tools.py    MIT License 4 votes vote down vote up
def HashFile(theFile,simplename,o_result):
    if os.path.exists(theFile):
        if os.path.isfile(theFile):
            try:
                f=open(theFile,'rb')
            except IOError:
                log.warning("open failed :"+theFile)
                return
            else:
                try:
                    rd = f.read()
                except IOError:
                    f.close()
                    log.warning("read failed:"+theFile)
                    return

                else:
                    theFileStats=os.stat(theFile)
                    (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)=os.stat(theFile)
                    log.info("Processing File: "+theFile)
                    fileSize = str(size)
                    modifiedTIme= time.ctime(mtime)
                    accessTime = time.ctime(atime)
                    createdTime = time.ctime(ctime)
                    ownerID = str(uid)
                    groupID = str(gid)
                    fileMode = bin(mode)

                    if gl_args.md5:
                        hashout = hashlib.md5()
                        hashout.update(rd)
                        hexmd5 = hashout.hexdigest()
                        hashValue = hexmd5.upper()
                    elif gl_args.sha256:
                        hashout = hashlib.sha256()
                        hashout.update(rd)
                        hexsha256 = hashout.hexdigest()
                        hashValue = hexsha256.upper()
                    elif gl_args.sha512:
                        hashout = hashlib.sha512()
                        hashout.update(rd)
                        hexsha512 = hashout.hexdigest()
                        hashValue = hexsha512.upper()
                    else:
                        log.error("hash not Selected")

                    f.close()
                    o_result.writeCSVrow(simplename,theFile,fileSize,modifiedTIme,accessTime,createdTime,hashValue,ownerID,groupID,mode)
                    return True

        else:
            log.warning("cannot read the file :"+theFile)
            return False
    else:
        log.warning("not a file"+theFile)
        return False