pwnable.kr

pwnable.kr

  • 一个pwn平台.别问我为什么换方向了.刷题记录.
    雄关漫道真如铁,而今迈步从头越.

    fd

  • 我们首先看到这道题的C源码:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    char buf[32];
    int main(int argc, char* argv[], char* envp[]){
    if(argc<2){
    printf("pass argv[1] a number\n");
    return 0;
    }
    int fd = atoi( argv[1] ) - 0x1234;
    int len = 0;
    len = read(fd, buf, 32);
    if(!strcmp("LETMEWIN\n", buf)){
    printf("good job :)\n");
    system("/bin/cat flag");
    exit(0);
    }
    printf("learn about Linux file IO\n");
    return 0;

    }

需要得到flag,则需要执行:system("/bin/cat flag");
则 必须 buf = “LETMEWIN”。
read(fd, buf, 32)函数中的三个参数中:

  • fd == 0时:则表示标准输入;
  • fd == 1时:则表示 标准输出;
  • fd == 2时,则表示标准输出错误。
    buf 表示读入的缓冲区;
    32表示读入32字节;
    所以我们 只需要 使 fd == 0 ,则我们就能自己输入 LETMEWIN 到 buf中。这样最终得到flag。
    那么我们就要令argv[1] = 0x1234argv[1] = 4660.
0%