Skip to content

Instantly share code, notes, and snippets.

@11philip22
Last active February 25, 2021 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 11philip22/d273d27796025da51cb208f248d829b9 to your computer and use it in GitHub Desktop.
Save 11philip22/d273d27796025da51cb208f248d829b9 to your computer and use it in GitHub Desktop.
Get function hash from dll ruby hash.rb kernel32.dll GetProcAddress https://haopingku.github.io/blog/2017/metasploit-windows-shellcode.html
def ror i, bits = 13
((i >> bits) | (i << (32 - bits))) & 0xFFFFFFFF
end
def hash mod, func
mod_hash = "#{mod.upcase.b}\x00"
.encode('utf-16le')
.unpack('C*')
.inject(0){|h, i| ror(h) + i}
func_hash = "#{func.b}\x00"
.unpack('C*')
.inject(0){|h, i| ror(h) + i}
(mod_hash + func_hash) & 0xFFFFFFFF
end
mod, func = *ARGV
puts('0x%08X = %s!%s' % [hash(mod, func), mod, func])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment