Example #1
0
 def run_rotl(self, opcodeint, immediates):
     val2 = self.machinestate.Stack_Omni.pop()
     val1 = self.machinestate.Stack_Omni.pop()
     if opcodeint == 119:
         self.machinestate.Stack_Omni.append(rol(val1, 32, val2))
     elif opcodeint == 137:
         self.machinestate.Stack_Omni.append(rol(val1, 64, val2))
     else:
         raise Exception(Colors.red + "invalid rotl instruction" +
                         Colors.ENDC)
def test_rol():
    print('----------------------------')
    failed = False
    print(bin(123456789))
    res = rol(123456789, 32, 10)
    print(bin(res))
    pass
    print('----------------------------')
Example #3
0
def hash_and_xor_module_name(string, xor_key=0xe4289257):
    hsh = 0
    for c in string:
        x = 0
        if ord(c) < 0x5b:
            x += 1
        if ord(c) < 0x41:
            x -= 1
        x = x << 5
        hsh = utils.rol(hsh, 7)
        hsh = hsh ^ (ord(c) + x)
    return hex(hsh ^ xor_key)
Example #4
0
def hash_and_xor_module_name(string, xor_key=0xe4289257):
    hsh = 0
    for c in string:
        x = 0
        if ord(c) < 0x5b:
            x += 1
        if ord(c) < 0x41:
            x -= 1
        x = x << 5
        hsh = utils.rol(hsh, 7)
        hsh = hsh ^ (ord(c) + x)
    return hex(hsh ^ xor_key)
Example #5
0
def hash_and_xor_func_name(name, xor_key=0xe4289257):
    hsh = 0
    for c in name:
        hsh = utils.rol(hsh, 7)
        hsh ^= ord(c)
    return hex(hsh ^ xor_key)
Example #6
0
def hash_and_xor_func_name(name, xor_key=0xe4289257):
    hsh = 0
    for c in name:
        hsh = utils.rol(hsh, 7)
        hsh ^= ord(c)
    return hex(hsh ^ xor_key)
Example #7
0
def sha1(data):
    """
    
    
    
    """
    bytes = ""

    h0 = 0x67452301
    h1 = 0xEFCDAB89
    h2 = 0x98BADCFE
    h3 = 0x10325476
    h4 = 0xC3D2E1F0
    
    for n in range(len(data)):
        bytes+='{0:08b}'.format(ord(data[n]))
    bits = bytes+"1"
    pBits = bits
    #pad until length equals 448 mod 512
    while len(pBits)%512 != 448:
        pBits+="0"
    #append the original length
    pBits+='{0:064b}'.format(len(bits)-1)

    def chunks(l, n):
        return [l[i:i+n] for i in range(0, len(l), n)]

    def rol(n, b):
        return ((n << b) | (n >> (32 - b))) & 0xffffffff

    for c in chunks(pBits, 512): 
        words = chunks(c, 32)
        w = [0]*80
        for n in range(0, 16):
            w[n] = int(words[n], 2)
        for i in range(16, 80):
            w[i] = rol((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1)  

        a = h0
        b = h1
        c = h2
        d = h3
        e = h4

        for i in range(0, 80):
            # round 1
            if 0 <= i <= 19:
                f = (b & c) | ((~b) & d)
                k = 0x5A827999
            # round 2
            elif 20 <= i <= 39:
                f = b ^ c ^ d
                k = 0x6ED9EBA1
            # round 3
            elif 40 <= i <= 59:
                f = (b & c) | (b & d) | (c & d) 
                k = 0x8F1BBCDC
            # round 4
            elif 60 <= i <= 79:
                f = b ^ c ^ d
                k = 0xCA62C1D6

                temp = rol(a, 5) + f + e + k + w[i] & 0xffffffff
                e = d
                d = c
                c = rol(b, 30)
                b = a
                a = temp

        h0 = h0 + a & 0xffffffff
        h1 = h1 + b & 0xffffffff
        h2 = h2 + c & 0xffffffff
        h3 = h3 + d & 0xffffffff
        h4 = h4 + e & 0xffffffff

    return '%08x%08x%08x%08x%08x' % (h0, h1, h2, h3, h4)