def hackAffine(message):
    print('[+] Starting the Hack...')
    print('[!] (Press Ctrl-C or Ctrl-D to quit at any time.)')

    for key in range(len(affine_cipher.SYMBOLS)**2):
        keyA = affine_cipher.getKeyParts(key)[0]
        if math.gcd(keyA, len(affine_cipher.SYMBOLS)) != 1:
            continue

        decryptedText = affine_cipher.decryptMessage(key, message)
        if not SILENT_MODE:
            print('[-] Tried Key %s... (%s)' % (key, decryptedText[:40]))

        if detect_english.isEnglish(decryptedText):
            print("\n")
            print('[+] Possible encryption hack:')
            print('[+] Key: %s' % (key))
            print('[!] Decrypted message: ' + decryptedText[:200])
            print("\n")
            print(
                '[!] Enter D for done, or just press Enter to continue hacking:'
            )
            response = input('> ')

            if response.strip().upper().startswith('D'):
                return decryptedText
    return None
Beispiel #2
0
	def tryDecrypting(self, possible_key):
		decrypted_text = self.cipher.decrypt(self.ciphertext.upper(), possible_key)

		if isEnglish(decrypted_text):
			decrypted_text = ''.join([decrypted_text[i].upper() if getSymbol(self.ciphertext[i]).isupper() else decrypted_text[i].lower() 
				for i in range(len(self.ciphertext))])
		
			return decrypted_text
Beispiel #3
0
	def tryDecrypting(self, possible_key):
		decrypted_text = self.cipher.decrypt(self.ciphertext, possible_key)

		if isEnglish(decrypted_text) and self.userAcceptance(possible_key, decrypted_text):
			return decrypted_text