ror13hash

shellcode中常用的ror13hash算法,常见hash:

def ror13(target):
    # return ((target << 0x13) & 0xfff80000) | ((target >> 0xd) & 0x07ffff)
    return ((target << 0x13) & 0xffffffff) | ((target >> 0xd) & 0x07ffff)
def calc(s):
    target=0
    for c in s:
        target = ror13(target)
        target += c
    return target
print('############################################################')
LoadLibraryA=calc( b'LoadLibraryAx00')
kernel32=calc('kernel32.dllx00'.upper().encode('UTF-16-LE'))
print('kernel32:0x%08x' % kernel32)
print('LoadLibraryA:0x%08x' % LoadLibraryA)
print('kernel32+LoadLibraryA:0x%08x' % ((LoadLibraryA+kernel32)&0xffffffff))#726774Ch

print('############################################################')
wininet=calc('wininet.dllx00'.upper().encode('UTF-16-LE'))
print('wininet:0x%08x' % wininet)
InternetOpenA=calc(b'InternetOpenAx00')
print('InternetOpenA:0x%08x' % InternetOpenA)
print('wininet+InternetOpenA:0x%08x'%((wininet+InternetOpenA)&0xffffffff))#0A779563Ah
print('############################################################')
InternetConnectA=calc(b'InternetConnectAx00')
print('wininet+InternetConnectA:0x%08x'%((wininet+InternetConnectA)&0xffffffff))#0C69F8957h
print('############################################################')
HttpOpenRequestA=calc(b'HttpOpenRequestAx00')
print('wininet+HttpOpenRequestA:0x%08x'%((wininet+HttpOpenRequestA)&0xffffffff))#3B2E55EBh

print('############################################################')
HttpSendRequestA=calc(b'HttpSendRequestAx00')
print('wininet+HttpSendRequestA:0x%08x'%((wininet+HttpSendRequestA)&0xffffffff))#7B18062Dh

print('############################################################')
VirtualAlloc=calc(b'VirtualAllocx00')
print('kernel32+VirtualAlloc:0x%08x'%((kernel32+VirtualAlloc)&0xffffffff))#0E553A458h

print('############################################################')
InternetReadFile=calc(b'InternetReadFilex00')
print('wininet+InternetReadFile:0x%08x'%((wininet+InternetReadFile)&0xffffffff))#0E2899612h


print('############################################################')
GetLastError=calc(b'GetLastErrorx00')
print('kernel32+GetLastError:0x%08x'%((kernel32+GetLastError)&0xffffffff))#5DE2C5AAh

print('############################################################')
InternetErrorDlg=calc(b'InternetErrorDlgx00')
print('wininet+InternetErrorDlg:0x%08x'%((wininet+InternetErrorDlg)&0xffffffff))#0BE057B7h

print('############################################################')
user32=calc('user32.dllx00'.upper().encode('utf-16-le'))#315E2145h
GetDesktopWindow=calc(b'GetDesktopWindowx00')
print('user32+GetDesktopWindow:0x%08x'%((user32+GetDesktopWindow)&0xffffffff))

输出:

############################################################
kernel32:0x92af16da
LoadLibraryA:0x74776072
kernel32+LoadLibraryA:0x0726774c
############################################################
wininet:0x862e96f8
InternetOpenA:0x214abf42
wininet+InternetOpenA:0xa779563a
############################################################
wininet+InternetConnectA:0xc69f8957
############################################################
wininet+HttpOpenRequestA:0x3b2e55eb
############################################################
wininet+HttpSendRequestA:0x7b18062d
############################################################
kernel32+VirtualAlloc:0xe553a458
############################################################
wininet+InternetReadFile:0xe2899612
############################################################
kernel32+GetLastError:0x5de2c5aa
############################################################
wininet+InternetErrorDlg:0x0be057b7
############################################################
user32+GetDesktopWindow:0x315e2145

原文地址:https://www.cnblogs.com/DirWang/p/15030979.html