我在使用RC4/ARC4加密的字符串的密钥时遇到问题。在
这是加密字符串:
E7Ev08_MEojYBixHRKTKQnRSC4hkriZ7XPsy3p4xAHUPj41Dlzu9
该字符串也使用base64进行散列,因此完整的编码字符串为:
RTdFdjA4X01Fb2pZQml4SFJLVEtRblJTQzRoa3JpWjdYUHN5M3A0eEFIVVBqNDFEbHp1OQ==
#-*- coding: utf-8 -*-
import threading
import sys
import time
import re
import itertools
from itertools import product
from Crypto.Cipher import ARC4
import base64
def special_match(strg):
try:
strg.decode('utf-8')
except UnicodeDecodeError:
pass
else:
print('\nkey found at %s, key: %s' % (time.ctime(), rc4_key))
try:
f=open('key.txt','ab')
f.write('Key (%s): %s\n' % (time.ctime(), rc4_key))
f.write('Decrypted string: ' + strg + '\n')
f.close()
except Exception as e:
print('ERROR WRITING KEY TO FILE: ' + str(e))
chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
end_chars = chars[::-1][0:7]
encoded_string = 'RTdFdjA4X01Fb2pZQml4SFJLVEtRblJTQzRoa3JpWjdYUHN5M3A0eEFIVVBqNDFEbHp1OQ=='
spinner = itertools.cycle(['-', '/', '|', '\\'])
while 1:
try:
# Iteration processess of possibel keys
for length in range(7,8): # only do length of 7
for attempt in itertools.permutations(chars, length):
rc4_key = ''.join(attempt) # This key is unknown, we are looking for it..
Ckey = ARC4.new(rc4_key)
decoded = Ckey.decrypt(encoded_string.decode('base64'))
special_match(decoded)
sys.stdout.write(spinner.next()) # write the next character
sys.stdout.flush() # flush stdout buffer (actual character display)
sys.stdout.write('\b') # erase the last written char
# Exit the script when we have done all password-combination-iterations
if (rc4_key == end_chars):
print('iteration of combinations done! No key found.. :(\n' + time.ctime())
exit()
except KeyboardInterrupt:
print('\nKeybord interrupt, exiting gracefully anyway on %s at %s' % (rc4_key, time.ctime()))
sys.exit()
我使用http://crypo.bz.ms/secure-rc4-online加密字符串,https://www.base64encode.org用UTF-8编码。在
为什么我的脚本不能找到钥匙?在
(我没有收到任何错误消息,如果我在代码中遗漏了什么,或者问题的解决方法,这更像是一个普通问题。)
明文:This is something that I have encrypted
,密钥:ABCFMSG
好吧,看来crypo.bz公司使用了一个非常奇怪的系统。基本上,它们有一个非常奇怪的编码,如果你只是使用它们的字符,就会产生差异。在
例如,用键“a”编码“a”应该产生值为163的字符。在
十六进制A3。在crypo.bz公司我们改成“oc”。在
所以你有两种可能。要么做一些密文分析或使用其他网站。我推荐这个,因为他们告诉你他们对结果的编码是什么:
http://www.fyneworks.com/encryption/RC4-Encryption/index.asp
把十六进制转换成字符串,你应该能破译它
顺便说一下,您的代码似乎正在工作;)
如果你还有其他问题请告诉我
编辑:做了一些额外的分析,真的,真的很奇怪。 在crypo.bz公司如果算法163是正确的,则oc 163是正确的
160是nc
但是161是mc??在
如果有人知道了,请告诉我!在
编辑编辑:
这里是加密但未编码的字符串“#ÔèH§¢6pbpÊ]õIœIŒgt;Yœ5îGuæxëa…ë6°”
你的程序需要半秒钟才能找到钥匙;)
相关问题 更多 >
编程相关推荐