python 모듈 pefile/ pydasm 질문입니다.
글쓴이: jaewonm / 작성시간: 월, 2012/01/16 - 11:26오후
kernel32.dll 파일을 pefile 모듈로 파싱하여
.text 섹션을 pydasm으로 disassemble 하고 싶은데요
import pefile
import pydasm
pe=pefile.PE('C:\Windows\System32\kernel32.dll')
for section in pe.sections:
print (section.Name, hex(section.VirtualAddress),
hex(section.Misc_VirtualSize), section.SizeOfRawData )
if section.Name==".text\x00\x00\x00":
print hex(pe.OPTIONAL_HEADER.ImageBase);
text_section_rva=section.VirtualAddress+pe.OPTIONAL_HEADER.ImageBase;
text_section_size=section.SizeOfRawData
data = pe.get_memory_mapped_image()[text_section_rva:text_section_rva+text_section_size]
offset = 0
while offset < len(data):
i = pydasm.get_instruction(data[offset:], pydasm.MODE_32)
print pydasm.get_instruction_string(i, pydasm.FORMAT_INTEL,text_section_rva+offset)
offset += i.lengthpefile 사이트에 예제를 조금 변형한건데 실행하면 어셈 몇줄 나오다가
None type이 나오면서 프로그램이 멈추네요 ..
.text섹션에 코드가 그렇게 적게 나올리는 없고.. 뭐가 문제인지 잘 모르겠네요 .. ㅠㅠ
Forums:


댓글 달기