Example #1
0
                break
        val = cur ^ (cur + 1)
        List = [i ^ val for i in List]
        extra = ""
        uList = [i for i in List]
        uList.reverse()
        for item in uList:
            extra += chr(item)
        scrambled = scrambled[:len(scrambled) - 1]
    fin = [chr(ord(i) ^ 17) for i in extra]
    print fin
    Is.reverse()
    print Is
    return Intermediate


Key = randKey()
IV = randKey()
cipherText = RandEncrypt(Key, IV)

PlainText = ""
unknown = cipherText[16:32]
intermediate = decryptBlock(unknown, Key, IV)
intermediate.reverse()
print intermediate
first = cipherText[:16]
first = [i for i in first]
print first
for i, j in zip(first, intermediate):
    print chr((ord(i) ^ ord(j))),
        fPad += 1
    Padding += "0" * fPad
    Padding += "{0:064b}".format(bits)
    Binary = [Padding[i:i+8] for i in range(0,len(Padding),8)]
    first = Binary[:len(Binary) - 8]
    last = [Binary[len(Binary) - 1], Binary[len(Binary) - 2]] + Binary[len(Binary) - 8: len(Binary) - 2]
    Binary = first + last
    glueStr = ""
    for b in Binary:
        glueStr += chr(int(b,2))
    return glueStr
Str = "foo"

encoded = encodeData(Str)
dLen = len(encoded)
Key = randKey()
m = md4()
m.update(Key + encoded)
secret =  m.digest()
print secret
Segments = [secret[i:i+8] for i in range(0,32,8)]
Hex = []
for s in Segments:
    str = ""
    for i in range(0,len(s),2):
        str = s[i] + s[i+1] + str
    dec = int(str,16)
    Hex.append(dec)
h = hackedMD4(Hex)
HackedStr = ";admin=true;"
h.update(HackedStr, (dLen + 16) * 8)
Example #3
0
    ans = ""
    for i, j in zip(str1, str2):
        ans += chr(ord(i) ^ ord(j))
    return ans


def isBadString(str):
    for c in str:
        if ord(c) > 127:
            return True
    return False


file = open("SampleText", "r")
plainText = ""
for line in file:
    plainText += line
file.close()

plainText = plainText[:48]
print plainText
Key = randKey()
print Key
cipherText = CBCEncrypt(plainText, Key, Key)
C1, C2, C3 = cipherText[:16], cipherText[16:32], cipherText[32:]
print C1
print C1 + chr(0) * 16 + C1
xPlain = CBCDecrypt(C1 + chr(0) * 16 + C1, Key, Key)
print isBadString(xPlain)
Pn1, Pn2, Pn3 = xPlain[:16], xPlain[16:32], xPlain[32:]
print strXOR(Pn1, Pn3)
                Is.append(i)
                break
        val = cur ^ (cur + 1)
        List = [i ^ val for i in List]
        extra = ""
        uList = [i for i in List]
        uList.reverse()
        for item in uList:
            extra += chr(item)
        scrambled = scrambled[:len(scrambled)-1]
    fin = [chr(ord(i) ^ 17) for i in extra]
    print fin
    Is.reverse()
    print Is
    return Intermediate

Key = randKey()
IV = randKey()
cipherText = RandEncrypt(Key, IV)

PlainText = ""
unknown = cipherText[16:32]
intermediate = decryptBlock(unknown, Key, IV)
intermediate.reverse()
print intermediate
first = cipherText[:16]
first = [i for i in first]
print first
for i,j in zip(first,intermediate):
    print chr((ord(i) ^ ord(j))),