-
Notifications
You must be signed in to change notification settings - Fork 6
/
crc32_hash.py
executable file
·41 lines (36 loc) · 1.42 KB
/
crc32_hash.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
#=============================================================================#
# Example: Simply print the correct hash value for the function kernel32.dll!WinExec
# >hash.py kernel32.dll WinExec
#
# Author: Ege Balcı (ege.balci[at]pm[dot]me)
#=============================================================================#
from sys import path
import os, time, sys, crcmod
CRC32_SEED=0
def unicode( string, uppercase=True ):
result = "";
if uppercase:
string = string.upper()+"\x00"
for c in string:
result += c + "\x00"
return result
#=============================================================================#
def hash( module, function, bits=13, print_hash=True ):
crc32_func = crcmod.mkCrcFun(0x11EDC6F41, initCrc=CRC32_SEED, xorOut=0)
h = crc32_func((unicode(module)+function+"\x00").encode('utf-8'))
print("[+] 0x%08X = %s!%s" % ( h, module.lower(), function ))
return h
#=============================================================================#
def main( argv=None ):
if not argv:
argv = sys.argv
if len( argv ) == 1:
print("Usage: crc32_hash.py [<module.dll> <function>]")
else:
hash( argv[1], argv[2] )
#=============================================================================#
if __name__ == "__main__":
main()
#=============================================================================#