#/usr/bin/python from pydbg import * from pydbg.defines import * import os.path import pefile import re import struct import sys def GetSection(pe, section_name): for section in pe.sections: # Section names are \0-padded on the right if section.Name.rstrip("\x00") == section_name: return section raise Exception("No %s section" % section_name) # Find RenderProcessHost::run_renderer_in_process_ by # BrowserRenderProcessHost::BrowserRenderProcessHost # (chrome/browser/renderer_host/browser_render_process_host.cc:146) def FindRripByBrph(pe): section = GetSection(pe, ".text") data = section.get_data(section.VirtualAddress) # chrome.dll 2.0.172.33 10,031,088 bytes # .text:01DB921E 80 3D 2E 60 4C 02 00 cmp RenderProcessHost__run_renderer_in_process_, 0 # .text:01DB9225 74 14 jz short loc_1DB923B # .text:01DB9227 83 05 0C 5D 4B 02 03 add dword_24B5D0C, 3 RE_BRPH = re.compile(r"\x80\x3d(....)\x00..\x83\x05....\x03", re.S) matches = list(RE_BRPH.finditer(data)) if len(matches) != 1: raise Exception("Wrong number of instruction pattern matches") return struct.unpack("