zoukankan      html  css  js  c++  java
  • Linux (x86) Exploit 开发系列教程之六(绕过ASLR

    (1)原理:

    地址空间布局随机化(ASLR)是随机化的利用缓解技术:堆栈地址,栈地址,共享库地址。一旦上述地址被随机化,特别是当共享库地址被随机化时,我们采取的绕过NX bit的方法不会生效,因为攻击者需要知道libc基地址。而此时我们可以采用return-to-plt技术,在这种技术中,而不是返回到libc函数(其地址是随机的)攻击者返回到一个函数的PLT(其地址不是随机的-其地址在执行之前已知)。由于'function@PLT'不是随机的,所以攻击者不再需要预测libc的基地址,而是可以简单地返回到“function@PLT”来调用“function”。

    (2)漏洞代码

    #include <stdio.h>
    #include <string.h>
    /* Eventhough shell() function isnt invoked directly, its needed here since 'system@PLT' and 'exit@PLT' stub code should be present in executable to successfully exploit it. */
    void shell() {
     system("/bin/sh");
     exit(0);
    }
    int main(int argc, char* argv[]) {
     int i=0;
     char buf[256];
     strcpy(buf,argv[1]);
     printf("%s
    ",buf);
     return 0;
    }
    

     编译文件

    (2)反汇编可执行文件'vuln',我们可以找到‘system@PLT’和 ‘exit@PLT’的地址。

    (3)用IDA查看vuln中“/bin/sh”的地址

    (3)攻击代码如下:

    (4)运行攻击代码,获得root shell权限

    由于无法解释的神圣旨意,我们徒然地到处找你;你就是孤独,你就是神秘,比恒河或者日落还要遥远。。。。。。
  • 相关阅读:
    贝壳找房魔法师顾问[并查集+DAG判断]
    Ubuntu 18.04 安装 virtualbox
    Ubuntu 编译安装 nDPI
    Ubuntu 16.04 安装WPS
    HDU 5046 Airport【DLX重复覆盖】
    Codeforces 622C Not Equal on a Segment 【线段树 Or DP】
    UVA 10635 Prince and Princess【LCS 问题转换为 LIS】
    LA 2995 Image Is Everything
    LA 3708 Graveyard
    HDU 5212 Code【莫比乌斯反演】
  • 原文地址:https://www.cnblogs.com/momoli/p/10869736.html
Copyright © 2011-2022 走看看