포너블 5차시

ZLP042·2023년 9월 10일
post-thumbnail
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>

char name[16];

char *command[10] = { "cat",
    "ls",
    "id",
    "ps",
    "file ./oob" };
void alarm_handler()
{
    puts("TIME OUT");
    exit(-1);
}

void initialize()
{
    setvbuf(stdin, NULL, _IONBF, 0);
    setvbuf(stdout, NULL, _IONBF, 0);

    signal(SIGALRM, alarm_handler);
    alarm(30);
}

int main()
{
    int idx;

    initialize();

    printf("Admin name: ");
    read(0, name, sizeof(name));
    printf("What do you want?: ");

    scanf("%d", &idx);

    system(command[idx]);

    return 0;
}

익스플로잇은 다음과 같다.

b'' 형식으로 출력되는데, 이때는 그냥 decode 메서드 쓰면된다. name에 16만큼의 배열을 전역변수로 받아주고 있고, want? 다음에 idx를 받고있으니, 위와 같은 페이로드를 작성하면 된다

0개의 댓글