[App system] ELF x86 - Stack buffer overflow basic 5
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include #include #include #define BUFFER 512 struct Init { char username[128]; uid_t uid; pid_t pid; }; void cpstr(char *dst, const char *src) { for(; *src; src++, dst++) { *dst = *src; } *dst = 0; } void chomp(char *buff) { for(; *buff; buff++) { if(*buff == '\n' || *buff == '\r' || *buff == '\t') { *buff = 0; break; } } } struct Init ..
iofile_vtable_check
·
Wargame/Dreamhack
보호되어 있는 글입니다.
_IO_FILE_plus의 모든 것.
·
Tips & theory
자꾸 헷갈려서 간단하게 요약해본다. 추가로 확인되는 사항이 있으면 지속적으로 update 할 예정이다. _IO_FILE_plus 많은 함수들이 단독으로 존재하는 것 같지만 사실은 _IO_FILE_plus 라는 구조체의 형식으로 존재하는 것들이 많다. 파일을 열고 닫는 함수들이 대부분 해당되며, stdin, stdout, stderr 등도 이 형식을 띄고 있다. _IO_FILE_plus 는 _IO_FILE 구조체와 vtable 구조체의 집합이다. _IO_FILE_plus 구조체의 모양은 아래와 같다. struct _IO_FILE_plus { FILE file; const struct _IO_jump_t *vtable; }; _IO_FILE 구조체 _IO_FILE 구조체의 형식은 아래와 같다. struct ..
FSOP - _IO_flush_all_lockp ()
·
Tips & theory
원리 기본적인 내용은 앞선 FSOP 들과 동일하며, _IO_FILE 구조체가 아닌 vtable 구조체의 값을 사용하는 함수이다. 더보기 https://wyv3rn.tistory.com/110?category=949837 _IO_FILE Arbitrary Address Read 원리 여러개의 파일을 열지만 읽기 권한이 없는 경우, 예를 들어 관리자가 작성한 암호 파일과 유저가 작성한 파일을 열어 그 내용을 비교한다고 가정할 때 관리자 파일에 읽기 권한이 없는 경 wyv3rn.tistory.com https://wyv3rn.tistory.com/112?category=949837 _IO_FILE Arbitrary Address Write 원리 큰 틀은 _IO_FILE Arbitrary Address Read..
_IO_FILE Arbitrary Address Write
·
Wargame/Dreamhack
1. intro 2. code 및 분석 2.1 code // Name: iofile_aaw // gcc -o iofile_aaw iofile_aaw.c -no-pie #include #include #include char flag_buf[1024]; int overwrite_me; void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); } int read_flag() { FILE *fp; fp = fopen("/home/iofile_aaw/flag", "r"); fread(flag_buf, sizeof(char), sizeof(flag_buf), fp); write(1, flag_buf, sizeof(flag_buf)); fclose(fp);..
_IO_FILE Arbitrary Address Write
·
Tips & theory
원리 큰 틀은 _IO_FILE Arbitrary Address Read와 동일하다. https://wyv3rn.tistory.com/110 _IO_FILE Arbitrary Address Read 원리 여러개의 파일을 열지만 읽기 권한이 없는 경우, 예를 들어 관리자가 작성한 암호 파일과 유저가 작성한 파일을 열어 그 내용을 비교한다고 가정할 때 관리자 파일에 읽기 권한이 없는 경 wyv3rn.tistory.com 취약점 마찬가지로 read와 동일하지만, _flags 값과 구조체에 들어가는 데이터가 조금 다르다. Read 함수 함수 인자 read 함수의 구조는 아래와 같다. read(f->_fileno, _IO_buf_base, _IO_buf_end - _IO_buf_base); 각 인자의 주요점은 아래..
_IO_FILE Arbitrary Address Read
·
Wargame/Dreamhack
1. intro 2. code 및 분석 2.1 code // Name: iofile_aar // gcc -o iofile_aar iofile_aar.c -no-pie #include #include #include char flag_buf[1024]; FILE *fp; void init() { setvbuf(stdin, 0, 2, 0); setvbuf(stdout, 0, 2, 0); } int read_flag() { FILE *fp; fp = fopen("/home/iofile_aar/flag", "r"); fread(flag_buf, sizeof(char), sizeof(flag_buf), fp); fclose(fp); } int main() { const char *data = "TEST FILE!..
_IO_FILE Arbitrary Address Read
·
Tips & theory
문제와 함께 읽어야 이해가 쉽다. https://wyv3rn.tistory.com/111 _IO_FILE Arbitrary Address Read 1. intro 2. code 및 분석 2.1 code // Name: iofile_aar // gcc -o iofile_aar iofile_aar.c -no-pie #include #include #include char flag_buf[1024]; FILE *fp; void init() { setvbuf(stdin, 0, 2, 0); setv.. wyv3rn.tistory.com 원리 여러개의 파일을 열지만 읽기 권한이 없는 경우, 예를 들어 관리자가 작성한 암호 파일과 유저가 작성한 파일을 열어 그 내용을 비교한다고 가정할 때 관리자 파일에 읽기 권한이 ..