2

I have some encrypted texts (encrypted with 3DES in ECB mode without salt).

My question: How can I decrypt them using a wordlist? (or without one?)

Example:

Encrypted text:

Xfi+h4Ir6l7zXCP+N4EPvQ==

The wordlist for this:

foo
bar
marketing

The original text was before encrypting was: "marketing" (just to make the example full).

I tried with the commented python script:

$ cat 3des.py 
 #!/usr/local/bin/python

from pyDes import *

data = "marketing"
k = des("DESCRYPT", CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=PAD_PKCS5)
d = k.encrypt(data)
print "Encrypted: %r" % d
print "Decrypted: %r" % k.decrypt(d)
assert k.decrypt(d, padmode=PAD_PKCS5) == data

testing it:

$ python 3des.py 
Encrypted: '\xabd\xfc\x98x\x86\x8d\xb5A\xba\x8e\x12,\x1f\x83\xb5'
Decrypted: 'marketing'
$ 

A little help please?

4

1 回答 1

1

如果要使用 pyDES,首先必须将脚本配置为使用 3DES……这是提供的 pyDES 示例,已修改为使用 3DES:

from pyDes import *

data = "marketing"
k = triple_des("DESCRYPTDESCRYPT", ECB, "\0\0\0\0\0\0\0\0", pad=None, padmode=PAD_PKCS5)
d = k.encrypt(data)
print "Encrypted: %r" % d
print "Decrypted: %r" % k.decrypt(d)
assert k.decrypt(d, padmode=PAD_PKCS5) == data

为了打破它...

以下行包含类初始化信息:

k = triple_des("DESCRYPTDESCRYPT", ECB, "\0\0\0\0\0\0\0\0", pad=None, padmode=PAD_PKCS5)

从文档中,参数如下:

(key, [mode], [IV], [pad], [padmode])

key     -> Bytes containing the encryption key. 8 bytes for DES, 16 or 24 bytes
       for Triple DES
mode    -> Optional argument for encryption type, can be either
       pyDes.ECB (Electronic Code Book) or pyDes.CBC (Cypher Block Chaining)
IV      -> Optional Initial Value bytes, must be supplied if using CBC mode.
       Length must be 8 bytes.
pad     -> Optional argument, set the pad character (PAD_NORMAL) to use during
       all encrypt/decrpt operations done with this instance.
padmode -> Optional argument, set the padding mode (PAD_NORMAL or PAD_PKCS5)
       to use during all encrypt/decrpt operations done with this instance.

所以,在我修改过的例子中,我已经配置了这样的参数......

Key: DESCRYPTDESCRYPT
Mode: ECB
IV: "\0\0\0\0\0\0\0\0"
pad: None
padmode: PAD_PKCS5

因此,从这里开始,您需要将上面的“数据”变量更改为要解密的密文,然后将单词列表加载到数组中,设置一个循环以通过“密钥”参数迭代数组中的值...

于 2014-02-27T15:50:09.043 回答