Last active
February 25, 2021 18:32
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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