0
点赞
收藏
分享

微信扫一扫

Misc(buuoj)

龙毓七七 2022-01-26 阅读 51
安全pwn

一、[GWCTF2019]math

开启靶机连接环境。题目给出了一个算式,但是算不了几秒就退出了。

同时还给了我们源程序:"gwctf_2019_math"。

放到IDA64里看一下,找到它的主函数。

int __cdecl main(int argc, const char **argv, const char **envp)
{
  unsigned int seed; // ST14_4
  unsigned int v4; // ST18_4
  unsigned int v5; // ST1C_4
  unsigned int v6; // ST20_4
  unsigned int v7; // ST24_4
  signed int v9; // [rsp+10h] [rbp-130h]
  char buf; // [rsp+30h] [rbp-110h]
  unsigned __int64 v11; // [rsp+138h] [rbp-8h]

  v11 = __readfsqword(0x28u);
  setvbuf(stdin, 0LL, 2, 0LL);
  setvbuf(stdout, 0LL, 2, 0LL);
  setvbuf(stderr, 0LL, 2, 0LL);
  v9 = 0;
  seed = time(0LL);
  srand(seed);
  do
  {
    alarm(5u);
    v4 = rand() % 200;
    v5 = rand() % 200;
    v6 = rand() % 200;
    v7 = rand() % 200;
    puts("Pass 150 levels and i will give you the flag~");
    puts("====================================================");
    printf("Now level %d\n", (unsigned int)v9);
    printf("Math problem: %d * %d - %d + %d = ??? ", v4, v5, v6, v7);
    puts("Give me your answer:");
    read(0, &buf, 0x80uLL);
    if ( (unsigned int)strtol(&buf, 0LL, 10) != v5 * v4 - v6 + v7 )
    {
      puts("Try again?");
      exit(0);
    }
    puts("Right! Continue~");
    ++v9;
    sleep((unsigned __int64)"Right! Continue~");
  }
  while ( v9 <= 149 );
  if ( v9 != 150 )
  {
    puts("Wrong!");
    exit(0);
  }
  puts("Congratulation!");
  system("/bin/sh");

逻辑很简单,flag应该容易拿。我们可以使用pwntools的recvuntil方法来获取算式的参数,自动计算之后反弹,实现自动的150次计算。

上脚本!

 这里我的Ubintu在安装pwntools时一直出错,所以我换了kali。

ls命令进入目录,发现"flag.txt"。

cat flag.txt 命令拿到flag。

 总的来看,这可以说是一道简单的pwn,主要就是熟悉pwntools的用法。

 

举报

相关推荐

.misc

LSB,Misc

buuoj刷题记录 - pwnable_hacknote

xctf misc 刷题

BUUctf-Misc(一)

0 条评论