解析exe文件

本文涉及的产品
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
全局流量管理 GTM,标准版 1个月
云解析 DNS,旗舰版 1个月
简介: 如何使用`objdump`工具解析exe文件,包括exe文件的组成、`objdump`的用法以及如何查看exe文件的节头信息和完整内容。

概述:上次用java生成exe文件。那如何解析exe文件呢?0.0

首先我们要了解exe文件里面有什么。用360压缩解压一下。

  1. .data:

    • 存储程序中的初始化的全局和静态变量。在程序运行之前,这些变量会被赋予特定的初始值。
  2. .pdata (Procedure Data):

    • 包含有关程序中函数或异常处理程序的信息。这对于调试和异常处理非常重要。
  3. .rdata (Read-Only Data):

    • 存储只读数据,如常量、字符串等。这些数据在程序运行期间不应被修改。
  4. .reloc (Relocation):

    • 包含需要在运行时进行修正的信息。当可执行文件被加载到内存中的不同地址时,这些修正会调整程序中的地址引用。
  5. .rodata (Read-Only Data):

    • 类似于.rdata,存储只读的数据。通常包含程序中的只读常量、字符串等。
  6. .svm_hea (SVM Header):

    • 这个名称不是标准的Windows PE文件节,可能是某些特定用途的自定义标记。通常,PE文件不包含此类节。可能是某些特定工具或库生成的文件才会包含这样的节。
  7. .text:

    • 存储程序的机器代码,即实际的可执行指令。这是程序的主要执行代码区域。

objdump解析exe文件

objdump --help

Usage: objdump <option(s)> <file(s)>
 Display information from object <file(s)>.
 At least one of the following switches must be given:
  -a, --archive-headers    Display archive header information
  -f, --file-headers       Display the contents of the overall file header
  -p, --private-headers    Display object format specific file header contents
  -P, --private=OPT,OPT... Display object format specific contents
  -h, --[section-]headers  Display the contents of the section headers
  -x, --all-headers        Display the contents of all headers
  -d, --disassemble        Display assembler contents of executable sections
  -D, --disassemble-all    Display assembler contents of all sections
      --disassemble=<sym>  Display assembler contents from <sym>
  -S, --source             Intermix source code with disassembly
      --source-comment[=<txt>] Prefix lines of source code with <txt>
  -s, --full-contents      Display the full contents of all sections requested
  -g, --debugging          Display debug information in object file
  -e, --debugging-tags     Display debug information using ctags style
  -G, --stabs              Display (in raw form) any STABS info in the file
  -W, --dwarf[a/=abbrev, A/=addr, r/=aranges, c/=cu_index, L/=decodedline,
              f/=frames, F/=frames-interp, g/=gdb_index, i/=info, o/=loc,
              m/=macro, p/=pubnames, t/=pubtypes, R/=Ranges, l/=rawline,
              s/=str, O/=str-offsets, u/=trace_abbrev, T/=trace_aranges,
              U/=trace_info]
                           Display the contents of DWARF debug sections
  -Wk,--dwarf=links        Display the contents of sections that link to
                            separate debuginfo files
  -WK,--dwarf=follow-links
                           Follow links to separate debug info files (default)
  -WN,--dwarf=no-follow-links
                           Do not follow links to separate debug info files
  -L, --process-links      Display the contents of non-debug sections in
                            separate debuginfo files.  (Implies -WK)
      --ctf[=SECTION]      Display CTF info from SECTION, (default `.ctf')
      --sframe[=SECTION]   Display SFrame info from SECTION, (default '.sframe')
  -t, --syms               Display the contents of the symbol table(s)
  -T, --dynamic-syms       Display the contents of the dynamic symbol table
  -r, --reloc              Display the relocation entries in the file
  -R, --dynamic-reloc      Display the dynamic relocation entries in the file
  @<file>                  Read options from <file>
  -v, --version            Display this program's version number
  -i, --info               List object formats and architectures supported
  -H, --help               Display this information

 The following switches are optional:
  -b, --target=BFDNAME           Specify the target object format as BFDNAME
  -m, --architecture=MACHINE     Specify the target architecture as MACHINE
  -j, --section=NAME             Only display information for section NAME
  -M, --disassembler-options=OPT Pass text OPT on to the disassembler
  -EB --endian=big               Assume big endian format when disassembling
  -EL --endian=little            Assume little endian format when disassembling
      --file-start-context       Include context from start of file (with -S)
  -I, --include=DIR              Add DIR to search list for source files
  -l, --line-numbers             Include line numbers and filenames in output
  -F, --file-offsets             Include file offsets when displaying information
  -C, --demangle[=STYLE]         Decode mangled/processed symbol names
                                   STYLE can be "none", "auto", "gnu-v3",
                                   "java", "gnat", "dlang", "rust"
      --recurse-limit            Enable a limit on recursion whilst demangling
                                  (default)
      --no-recurse-limit         Disable a limit on recursion whilst demangling
  -w, --wide                     Format output for more than 80 columns
  -U[d|l|i|x|e|h]                Controls the display of UTF-8 unicode characters
  --unicode=[default|locale|invalid|hex|escape|highlight]
  -z, --disassemble-zeroes       Do not skip blocks of zeroes when disassembling
      --start-address=ADDR       Only process data whose address is >= ADDR
      --stop-address=ADDR        Only process data whose address is < ADDR
      --no-addresses             Do not print address alongside disassembly
      --prefix-addresses         Print complete address alongside disassembly
      --[no-]show-raw-insn       Display hex alongside symbolic disassembly
      --insn-width=WIDTH         Display WIDTH bytes on a single line for -d
      --adjust-vma=OFFSET        Add OFFSET to all displayed section addresses
      --show-all-symbols         When disassembling, display all symbols at a given address
      --special-syms             Include special symbols in symbol dumps
      --inlines                  Print all inlines for source line (with -l)
      --prefix=PREFIX            Add PREFIX to absolute paths for -S
      --prefix-strip=LEVEL       Strip initial directory names for -S
      --dwarf-depth=N            Do not display DIEs at depth N or greater
      --dwarf-start=N            Display DIEs starting at offset N
      --dwarf-check              Make additional dwarf consistency checks.
      --ctf-parent=NAME          Use CTF archive member NAME as the CTF parent
      --visualize-jumps          Visualize jumps by drawing ASCII art lines
      --visualize-jumps=color    Use colors in the ASCII art
      --visualize-jumps=extended-color
                                 Use extended 8-bit color codes
      --visualize-jumps=off      Disable jump visualization
      --disassembler-color=off       Disable disassembler color output. (default)
      --disassembler-color=terminal  Enable disassembler color output if displaying on a terminal.
      --disassembler-color=on        Enable disassembler color output.
      --disassembler-color=extended  Use 8-bit colors in disassembler output.

objdump: supported targets: pe-x86-64 pei-x86-64 pe-bigobj-x86-64 elf64-x86-64 pe-i386 pei-i386 elf32-i386 elf32-iamcu pdb elf64-little elf64-big elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex plugin
objdump: supported architectures: i386 i386:x86-64 i386:x64-32 i8086 i386:intel i386:x86-64:intel i386:x64-32:intel iamcu iamcu:intel

The following i386/x86-64 specific disassembler options are supported for use
with the -M switch (multiple options should be separated by commas):
  x86-64      Disassemble in 64bit mode
  i386        Disassemble in 32bit mode
  i8086       Disassemble in 16bit mode
  att         Display instruction in AT&T syntax
  intel       Display instruction in Intel syntax
  att-mnemonic
              Display instruction in AT&T mnemonic
  intel-mnemonic
              Display instruction in Intel mnemonic
  addr64      Assume 64bit address size
  addr32      Assume 32bit address size
  addr16      Assume 16bit address size
  data32      Assume 32bit data size
  data16      Assume 16bit data size
  suffix      Always display instruction suffix in AT&T syntax
  amd64       Display instruction in AMD64 ISA
  intel64     Display instruction in Intel64 ISA
Report bugs to <https://sourceware.org/bugzilla/>.
AI 代码解读
  • -a:显示归档头信息
  • -f:显示整个文件头信息
  • -p:显示对象格式特定的文件头内容
  • -P:显示对象格式特定的内容
  • -h:显示节头信息
  • -x:显示所有节头信息
  • -d:显示可执行段的汇编代码
  • -D:显示所有可执行段的汇编代码
  • --disassemble=<sym>:显示指定符号的汇编代码
  • -S:将源代码与反汇编代码混合在一起
  • -s:显示完整内容
  • -g:显示调试信息
  • -e:使用ctags风格的调试信息
  • -G:显示DWARF调试信息
  • -w:格式化输出以适应80列以上宽度
  • --unicode=[default|locale|invalid|hex|escape|highlight]:控制显示UTF-8 Unicode字符的方式
  • --start-address=ADDR:只处理地址大于等于ADDR的数据
  • --stop-address=ADDR:只处理地址小于ADDR的数据
  • --no-addresses:不打印地址信息
  • --prefix-addresses:在反汇编时打印完整的地址信息
  • --insn-width=WIDTH:在反汇编时,每行显示WIDTH个字节
  • --adjust-vma=OFFSET:将所有显示的节地址加上OFFSET
  • --show-all-symbols:在反汇编时,显示给定地址的所有符号
  • --special-syms:在符号转储中包含特殊符号
  • --inlines:在源行上打印所有内联函数
  • --prefix=PREFIX:为-S选项添加前缀
  • --prefix-strip=LEVEL:为-S选项删除初始目录名
  • --dwarf-depth=N:不显示深度大于或等于N的DIEs
  • --dwarf-start=N:显示从偏移量N开始的DIEs
  • --dwarf-check:进行额外的dwarf一致性检查
  • --ctf-parent=NAME:使用CTF存档成员NAME作为CTF父级
  • --visualize-jumps:通过绘制ASCII艺术线条可视化跳转
  • --visualize-jumps=color:使用颜色在ASCII艺术中显示跳转
  • --visualize-jumps=extended-color:使用扩展的8位颜色代码显示跳转
  • --visualize-jumps=off:禁用跳转可视化
  • --disassembler-color=off:禁用反汇编器颜色输出(默认)
  • --disassembler-color=terminal:如果显示在终端上,则启用反汇编器颜色输出
  • --disassembler-color=on:启用反汇编器颜色输出
  • --disassembler-color=extended:在反汇编器输出中使用8位颜色

标准用法就是objdump <-options> 可执行文件

例如:objdump -d main.exe 显示可执行段的汇编代码

执行 objdump -h main.exe 显示节头信息

  1. Idx Name:内存段的索引名。
  2. Size:内存段的大小,以字节为单位。
  3. VMA:虚拟内存地址,这是在进程空间中分配给该内存段的地址。
  4. LMA:加载内存地址,这是在文件或磁盘上分配给该内存段的地址。
  5. File off:文件偏移量,这是在文件中相对于文件开始的位置。
  6. Algn:对齐方式,表示内存段的地址需要满足的对齐要求。例如,2**4表示地址必须是4字节对齐的。
  7. CONTENTS, ALLOC, LOAD, READONLY, CODE/DATA:这些是内存段的属性,描述了内存段的类型和用途。例如,CONTENTS表示该内存段包含数据;ALLOC表示该内存段由操作系统分配;LOAD表示该内存段可以被加载到进程的地址空间;READONLY表示该内存段的内容不能被修改;CODE表示该内存段包含可执行代码;DATA表示该内存段包含数据。

执行 objdump -s main.exe 显示完整内容

还在往下走,数量有点大。

目录
打赏
0
0
0
0
135
分享
相关文章
高级java面试---spring.factories文件的解析源码API机制
【11月更文挑战第20天】Spring Boot是一个用于快速构建基于Spring框架的应用程序的开源框架。它通过自动配置、起步依赖和内嵌服务器等特性,极大地简化了Spring应用的开发和部署过程。本文将深入探讨Spring Boot的背景历史、业务场景、功能点以及底层原理,并通过Java代码手写模拟Spring Boot的启动过程,特别是spring.factories文件的解析源码API机制。
151 2
|
5月前
|
Java“解析时到达文件末尾”解决
在Java编程中,“解析时到达文件末尾”通常指在读取或处理文件时提前遇到了文件结尾,导致程序无法继续读取所需数据。解决方法包括:确保文件路径正确,检查文件是否完整,使用正确的文件读取模式(如文本或二进制),以及确保读取位置正确。合理设置缓冲区大小和循环条件也能避免此类问题。
730 2
深潜数据海洋:Java文件读写全面解析与实战指南
通过本文的详细解析与实战示例,您可以系统地掌握Java中各种文件读写操作,从基本的读写到高效的NIO操作,再到文件复制、移动和删除。希望这些内容能够帮助您在实际项目中处理文件数据,提高开发效率和代码质量。
31 4
数据库导入SQL文件:全面解析与操作指南
在数据库管理中,将SQL文件导入数据库是一个常见且重要的操作。无论是迁移数据、恢复备份,还是测试和开发环境搭建,掌握如何正确导入SQL文件都至关重要。本文将详细介绍数据库导入SQL文件的全过程,包括准备工作、操作步骤以及常见问题解决方案,旨在为数据库管理员和开发者提供全面的操作指南。一、准备工作在导
947 0
FastExcel:开源的 JAVA 解析 Excel 工具,集成 AI 通过自然语言处理 Excel 文件,完全兼容 EasyExcel
FastExcel 是一款基于 Java 的高性能 Excel 处理工具,专注于优化大规模数据处理,提供简洁易用的 API 和流式操作能力,支持从 EasyExcel 无缝迁移。
401 9
FastExcel:开源的 JAVA 解析 Excel 工具,集成 AI 通过自然语言处理 Excel 文件,完全兼容 EasyExcel
智能文件解析:体验阿里云多模态信息提取解决方案
在当今数据驱动的时代,信息的获取和处理效率直接影响着企业决策的速度和质量。然而,面对日益多样化的文件格式(文本、图像、音频、视频),传统的处理方法显然已经无法满足需求。
120 4
智能文件解析:体验阿里云多模态信息提取解决方案
python操作和解析ppt文件 | python小知识
本文将带你从零开始,了解PPT解析的工具、工作原理以及常用的基本操作,并提供具体的代码示例和必要的说明【10月更文挑战第4天】
819 60
RocketMQ文件刷盘机制深度解析与Java模拟实现
【11月更文挑战第22天】在现代分布式系统中,消息队列(Message Queue, MQ)作为一种重要的中间件,扮演着连接不同服务、实现异步通信和消息解耦的关键角色。Apache RocketMQ作为一款高性能的分布式消息中间件,广泛应用于实时数据流处理、日志流处理等场景。为了保证消息的可靠性,RocketMQ引入了一种称为“刷盘”的机制,将消息从内存写入到磁盘中,确保消息持久化。本文将从底层原理、业务场景、概念、功能点等方面深入解析RocketMQ的文件刷盘机制,并使用Java模拟实现类似的功能。
91 3
文件太大不能拷贝到U盘怎么办?实用解决方案全解析
当我们试图将一个大文件拷贝到U盘时,却突然跳出提示“对于目标文件系统目标文件过大”。这种情况让人感到迷茫,尤其是在急需备份或传输数据的时候。那么,文件太大为什么会无法拷贝到U盘?又该如何解决?本文将详细分析这背后的原因,并提供几个实用的方法,帮助你顺利将文件传输到U盘。
python知识点100篇系列(18)-解析m3u8文件的下载视频
【10月更文挑战第6天】m3u8是苹果公司推出的一种视频播放标准,采用UTF-8编码,主要用于记录视频的网络地址。HLS(Http Live Streaming)是苹果公司提出的一种基于HTTP的流媒体传输协议,通过m3u8索引文件按序访问ts文件,实现音视频播放。本文介绍了如何通过浏览器找到m3u8文件,解析m3u8文件获取ts文件地址,下载ts文件并解密(如有必要),最后使用ffmpeg合并ts文件为mp4文件。
134 1

热门文章

最新文章

推荐镜像

更多
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等