분류 전체보기(35)
-
[Dreamhack] baby-bof
#include #include #include #include #include #include #include void proc_init () { setvbuf (stdin, 0, 2, 0); setvbuf (stdout, 0, 2, 0); setvbuf (stderr, 0, 2, 0); } void win () { char flag[100] = {0,}; int fd; puts ("You mustn't be here! It's a vulnerability!"); fd = open ("./flag", O_RDONLY); read(fd, flag, 0x60); puts(flag); exit(0); } long count; long value; long idx = 0; int main () { char n..
2023.12.10 -
c언어 입력 버퍼
#include int main() { char a; char b; scanf("%c", &a); scanf("%c", &b); printf("a: %c\nb: %c\n", a, b); } 위와 같은 코드가 있을 때 a에 입력값으로 asdf을 주게 되면 입력버퍼에는 asdf가 들어가게 되고 변수 a에는 서식지정자 %c와 매칭되는 a가 들어가게 된다. 그리고 %c로 b를 입력을 받을 땐 이미 입력버퍼에 값(sdf)가 들어있기 때문에 scanf에서는 입력을 받지 않고 입력버퍼에서 서식지정자 %c와 매칭되는 s를 가져오게 된다. 즉 scanf는 입력 버퍼에 값이 없을 때는 입력을 받지만 입력 버퍼에 값이 존재한다면 서식지정자와 매칭되는 값을 입력버퍼에서 가져온다는 것을 알 수 있다. 그 이유 때문에 scanf..
2023.09.10 -
[ codegate - pwn] librarian
main __int64 __fastcall main(__int64 a1, char **a2, char **a3) { unsigned int v3; // eax int v5; // [rsp+8h] [rbp-798h] BYREF int v6; // [rsp+Ch] [rbp-794h] char book_list[1928]; // [rsp+10h] [rbp-790h] BYREF unsigned __int64 v8; // [rsp+798h] [rbp-8h] v8 = __readfsqword(0x28u); sub_184C(); v3 = time(0LL); srand(v3); memset(book_list, 0, 0x780uLL); while ( book_num 14 ) { puts("The book list is ..
2023.06.18 -
[ CCE 사이버공격방어대회 ] n0t rand0m
우리 팀이 예선 7등으로 본선을 가게 되었다. 그런데 좀 아쉬운 점은 내가 개인사정으로 인해 본선날에 시간이 안 돼서 못 간다 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ 전체 코드 void __fastcall __noreturn main(int a1, char **a2, char **a3) { unsigned int v3; // eax unsigned int nbytes; // [rsp+0h] [rbp-30h] unsigned int case_1; // [rsp+4h] [rbp-2Ch] char name[8]; // [rsp+8h] [rbp-28h] BYREF char comment[24]; // [rsp+10h] [rbp-20h] BYREF unsigned __int64 v8; // [rsp+28h] [rbp-8..
2023.06.12 -
[ Dreamhack ] __environ
이 문제도 바로 이전에 올린 블로그 내용과 같이 environ ptr을 사용해서 푸는 문제이다. #include #include #include #include #include void sig_handle() { exit(0); } void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); signal(SIGALRM, sig_handle); alarm(5); } void read_file() { char file_buf[4096]; int fd = open("./flag", O_RDONLY); read(fd, file_buf, sizeof(file_buf) - 1); close(fd); } int main() { char buf[1024]; lon..
2023.06.09 -
[ Dreamhack ] environ
#include #include #include #include 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(60); } int main() { char buf[16]; size_t size; long value; void (*jump)(); initialize(); printf("stdout: %p\n", stdout); printf("Size: "); scanf("%ld", &size); printf("Data: "); read(0..
2023.06.09