# -*- coding: utf-8 -*-# crucial opcode in WeChatWin.dll crucial_opcode = b"\x8B\x06\x8B\xCE\xFF\x50\x18\x85\xC0\x0F\x84\x31\xFF\xFF\xFF\x68" patch_opcode = b"\x83\xC4\x04\x90\x90\x90\x90"# main if __name__ == "__main__":with open("WeChatWin.dll", "rb") as fs:byte_buf = bytes(fs.read())position = byte_buf.find(crucial_opcode)if position == -1:print "[-] can not find crucial code in WeChatWin.dll"else:print "[+] find the crucial code offset at {}".format(hex(position))precise_pos = position + len(crucial_opcode) + 4print "[+] after adjusting offset of crucial code {}".format(hex(precise_pos))print "[+] modifying crucial code with {} NOP's".format(len(patch_opcode))print "[+] generating patched file named WeChatWin_patched.dll"with open("WeChatWin_patched.dll", "wb") as wfs:wfs.write(byte_buf[0:precise_pos])wfs.write(patch_opcode)wfs.write(byte_buf[precise_pos + len(patch_opcode):])wfs.close()print "[+] Please rename the patched file according to WeChatWin.dll in WeChat installation directory"fs.close()