본문 바로가기

2014/049

pydbg로 Fuzzer 만들기 퍼저 동작원리 50byte의 buffer에 인자값으로 받은 파일의 첫 번째 바이트만큼 문자열을 읽어오는 취약한 프로그램이다. 아래 프로그램으로 간단하게 퍼징 테스트 수행 ~ #include "stdio.h" #include "stdlib.h" void vuln(char *path) { FILE *fd; int size=0; char buf[50]; fd = fopen(path, "rb"); fscanf(fd, "%c", &size); fgets(buf, size, fd); printf("size : %d \n", size); printf("data : %s \n", buf); } int main(int argc, char **argv) { if(argc != 2){ printf("%s (test file.. 2014. 4. 27.
[Pwnable] code pattern 환경 : NX, Ascii Armor, ASLR(stack) [ &ret sled로 RTL 인자 구성] | buf | &ret x n번 | &execl | dummy(next ret) | argv1 | argv2 | NULL | .... [*] 원하는 값을 가진 고정된 argv를 만날 때 까지 &ret를 타고 이동 후 RTL 1회 사용. 환경 : ASLR(stack) -> shellcode [ jmp %esp로 ASLR 우회] | buf | jmp %esp(ret) | nop + shellcode | ^ ret명령어 실행시 %esp의 위치 [*] call %esp도 가능 환경 : NX, ASLR(stack, libc), Ascii Armor [ fake ebp를 이용해서 custom stack 가기 ] .. 2014. 4. 26.
[exploit-exercises] fusion level02 [ fusion level02 ] 1#include "../common/common.c" 2 3#define XORSZ 32 4 5void cipher(unsigned char *blah, size_t len) 6{ 7 static int keyed; 8 static unsigned int keybuf[XORSZ]; 9 10 int blocks; 11 unsigned int *blahi, j; 12 13 if(keyed == 0) { 14 int fd; 15 fd = open("/dev/urandom", O_RDONLY); 16 if(read(fd, &keybuf, sizeof(keybuf)) != sizeof(keybuf)) exit(EXIT_FAILURE); 17 close(fd); 18 keyed .. 2014. 4. 25.
[exploit-exercises] fusion level01 [ fusion level01 ] 1#include "../common/common.c" 2 3int fix_path(char *path) 4{ 5 char resolved[128]; 6 7 if(realpath(path, resolved) == NULL) return 1; // can't access path. will error trying to open 8 strcpy(path, resolved); 9} 10 11char *parse_http_request() 12{ 13 char buffer[1024]; 14 char *path; 15 char *q; 16 17 // printf("[debug] buffer is at 0x%08x :-)\n", buffer); :D 18 19 if(read(0, .. 2014. 4. 20.