• iOS安全攻防(十七)看懂mach-o(2)


    个人原创,转帖请注明来源:cnblogs.com/jailbreaker

    接上一篇看懂mach-o(1),本文继续讲紧随mach-o的header文件的load command加载命令,看下面2张图,分别是hopper中显示的第一个load command区域和segment_command的定义:

    NewImage

    NewImage

    第一张图截取的是第一个load command,从第一张图所知道,cmd类型是segment_command,就是截图的第2张图,依次分析:

    1.cmd 是load command的类型,本文中值=1就是LC_SEGMENT,,LC_SEGMENT的含义是(将文件中的段映射到进程地址空间)

    2.cmdsize 代表load command的大小(0x38个字节,从0x401C-0x4053)。

    3.segname 16字节的段名字,当前是__PAGEZERO,有以下几种段:

    #defineSEG_PAGEZERO"__PAGEZERO"/* the pagezero segment which has no */

    /* protections and catches NULL */

    /* references for MH_EXECUTE files */

    #defineSEG_TEXT"__TEXT"/* the tradition UNIX text segment */

    #defineSEG_DATA"__DATA"/* the tradition UNIX data segment */

    #defineSEG_OBJC"__OBJC"/* objective-C runtime segment */

    #defineSEG_ICON "__ICON"/* the icon segment */

    #defineSEG_LINKEDIT"__LINKEDIT"/* the segment containing all structs */

    /* created and maintained by the link */

    /* editor.  Created with -seglinkedit */

    /* option to ld(1) for MH_EXECUTE and */

    /* FVMLIB file types only */

    #define SEG_IMPORT"__IMPORT"/* the segment for the self (dyld) */

    /* modifing code stubs that has read, */

    /* write and execute permissions */

     

    4.vmaddr 段的虚拟内存启始地址

    5.vmsize 段的虚拟内存大小

    6.fileoff 段在文件中的偏移量

    7.filesize 段在文件中的大小

    8.maxprot 段页面所需要的最高内存保护(4=r,2=w,1=x)

    9.initprot 段页面初始的内存保护

    10.nsects 段中包含section的数量

    11.flags 其他杂项标志位

    本文中主要讲了segment的种类和其结构,下一篇讲__DATA和__TEXT下面的sections。

  • 相关阅读:
    复变函数
    abc136
    点集
    一些数学题
    牛客多校第六场
    牛客多校第五场G
    复数
    generator 1
    digits 2
    Winner
  • 原文地址:https://www.cnblogs.com/jailbreaker/p/4185565.html
Copyright © 2020-2023  润新知