软件常用安全防护手段 checksec 总结

checksec 总结

一、RELRO

relro 是一种用于加强对 binary 数据段的保护的技术。relro 分为 partial relro 和 full relro

  • Partial RELRO

    • 现在gcc 默认编译就是 partial relro(很久以前可能需要加上选项 gcc -Wl,-z,relro)
    • some sections(.init_array .fini_array .jcr .dynamic .got) are marked as read-only after they have been initialized by the dynamic loader
    • non-PLT GOT is read-only (.got)
    • GOT is still writeable (.got.plt)
  • Full RELRO

    • 拥有 Partial RELRO 的所有特性

    • lazy resolution 是被禁止的,所有导入的符号都在 startup time 被解析

    • bonus: the entire GOT is also (re)mapped as read-only or the .got.plt section is completely initialized with the final addresses of the target functions (Merge .got and .got.plt to one section .got). Moreover,since lazy resolution is not enabled, the GOT[1] and GOT[2] entries are not initialized.

      GOT[0] is a the address of the module’s DYNAMIC section. GOT[1] is the virtual load address of the link_map, GOT[2] is the address for the runtime resolver function

    • 编译时需要加上选项 gcc -Wl,-z,relro,-z,now

    其中-z 参数是把-z 后面的 keyword 传给linker ld

    ld manual 中关于now 选项的解释

    When generating an executable or shared library, mark it to tell the dynamic linker to r

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值