Misc(buuoj)

一、[GWCTF2019]math

二、[BSidesSF2020]mpfrag

[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的用法。

[BSidesSF2020]mpfrag

下载以后是一个bin文件,拖到kali里file看一下文件类型为ext2文件。

在root用户下mount挂在"disk.bin"文件,发现报错:

wrong fs type,bad option ,bad superblock on /dev/loop0,missing cod epage or helper program,or other error.

翻译一下:错误的fs类型,错误的选项,/dev/loop0上的超级块损坏,缺少代码页或帮助程序,或其他错误。

这里其实就是文件系统中的超级块损坏。

dd if=disk.bin of=sb.bin bs=1024 skip=8193 count=1

提取文件系统中的8193块超级块(约占1k大小)这里选择bs=1024。

这里解释一下命令行:

  • if=infile
  • of=outfile
  • bs=bytes:同时设置读入/输出的块大小为bytes个字节
  • skip= blocks :从输入文件开头跳过blocks个块后再开始复制
  • count:只拷贝输入的blocks块。

 

dd if=sb.bin of=disk.bin bs=1024 conv=notrunc seek=1

将备份超级块放入已损坏的超级块。

  • onv=notrunc:不截短输出文件
  • seek=blocks:从输出文件开头跳过blocks个块后再开始复制。

binwalk -e 命令分离"disk.bin"文件。

 这里有一个加密的压缩包文件,判断flag应该在这里。

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI仿生道士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值