ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

第二章基础静态分析进阶:x86反汇编

2021-11-26 22:02:44  阅读:179  来源: 互联网

标签:code x86 instruction entrypoint 反汇编 PE address 进阶


第二章基础静态分析进阶:x86反汇编

《基于数据科学的恶意软件分析》

Malware Data Science Attack Detection and Attribution
Joshua Saxe Hillary Sanders著 何能强 严寒冰 译

代码清单2-2 反汇编ircbot.exe

#终端输入
pip install pefile
pip install capstone
#!/usr/bin/python3
#-*- coding:utf-8 -*-

import pefile
from capstone import *

# load the target PE file
#加载目标PE文件
pe = pefile.PE("/home/ubuntu20/桌面/malware_data_science/ch2/ircbot.exe")

# get the address of the program entry point from the program header
#从程序头中获取程序入口点的地址
entrypoint = pe.OPTIONAL_HEADER.AddressOfEntryPoint

# compute memory address where the entry code will be loaded into memory
#计算入口代码被加载到内存中的内存地址
entrypoint_address = entrypoint+pe.OPTIONAL_HEADER.ImageBase

# get the binary code from the PE file object
#从PE文件对象获取二进制代码
binary_code = pe.get_memory_mapped_image()[entrypoint:entrypoint+100]

# initialize disassembler to disassemble 32 bit x86 binary code
#初始化反汇编程序以反汇编32位x86二进制代码
disassembler = Cs(CS_ARCH_X86, CS_MODE_32)

# disassemble the code
#反汇编代码
for instruction in disassembler.disasm(binary_code, entrypoint_address):
    print("%s\t%s"%(instruction.mnemonic, instruction.op_str))

result:

python SyntaxError: invalid character in identifier

#disassemble the code
#反汇编代码
for instruction in disassembler.disasm(binary_code, entrypoint_address):
    print("%s\t%s"%(instruction.mnemonic, instruction.op_str))
#确保代码行内没有夹杂中文空格
#推荐学习:https://blog.csdn.net/justdoitjs/article/details/78988225

认真是一种态度更是一种责任

标签:code,x86,instruction,entrypoint,反汇编,PE,address,进阶
来源: https://blog.csdn.net/weixin_47038938/article/details/121542948

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有