시스템해킹 13

[DreamHack] Return To Library

NX로 공격자가 직접 쉘 코드를 실행하는 것은 어려워졌지만, 스택 버퍼 오버플로우 취약점으로 반환주소를 덮는건 가능했다. // Name: rtl.c // Compile: gcc -o rtl rtl.c -fno-PIE -no-pie #include #include const char* binsh = "/bin/sh"; int main() { char buf[0x30]; setvbuf(stdin, 0, _IONBF, 0); setvbuf(stdout, 0, _IONBF, 0); // Add system function to plt's entry system("echo 'system@plt"); // Leak canary printf("[1] Leak Canary\n"); printf("Buf: "); rea..

[DreamHack] Return Address Overwrite

1번 문제 입니다ㅏㅏㅏ 처음에 엄청 헤멨던 기억이... 문제 이름에서 추측이 가능하듯이 리턴 주소에 get_shell의 주소를 덮어주면 되는 문제이다. c코드에서 추측해보길 scanf에 BOF 가능성이 있으므로 buf에 return address 전까지 더미 문자열을 넣는다. 하지만 문자열의 길이는 얼만큼 넣어야 할까? buf의 사이즈인 0x28 만큼?? 이건 gdb를 돌려서 확인해본다. 에 rsp를 0x30만큼 빼는걸 확인하면 스택이 0x30만큼 빠지니까 0x30 + rbp 만큼 dummy 문자열을 만든다. 그다음 바로 get_shell 함수 주소를 return 주소에 넣어서 쉘을 획득한다. get_shell 함수의 주소는 disas or print 둘 중에 더 편한걸로 알아내면 된다. 이제 explo..

[DreamHack] System Hacking introduction (solve_me)

https://dreamhack.io/lecture/courses/35 Welcome Hackers👨‍💻 시스템 해킹에 입문하려는 분들을 위한 강의 dreamhack.io 기본적인 시스템 공부를 시작하려면 C언어와 파이썬에 대한 기초 지식이 필요하다ㅏㅏ!! 지금 밑에 있는 코드를 보고 "Welcome Hackers :)"가 출력 되는 입력값은 찾는다면 당신은 컴퓨터의 깊고 깊은 심연을 들여다 볼 준비가 되었다는 뜻이다! ㅎㅎ (과연!?!?) 관문은 총 2개로 준비되어 있다!! #include #include #include int main() { int sz = 0x30; char *buf = (char *)malloc(sizeof(char) * sz); puts("Hello World!"); print..

[pwnable] 시스템 해킹 ProtoStar - Stack7

https://github.com/z3tta/Exploit-Exercises-Protostar/blob/master/07-Stack7.md GitHub - z3tta/Exploit-Exercises-Protostar: Solutions for Exploit-Exercises Protostar Solutions for Exploit-Exercises Protostar. Contribute to z3tta/Exploit-Exercises-Protostar development by creating an account on GitHub. github.com gcc -z execstack -w -no-pie -o stack7 stack7.c 오오오 벌써 7번이네요 ㅎ Stack6번 문제와 비슷한데 6번에 대해 ..

[pwnable] 시스템 해킹 ProtoStar - Stack6 (PLT, GO)

https://github.com/z3tta/Exploit-Exercises-Protostar/blob/master/06-Stack6.md GitHub - z3tta/Exploit-Exercises-Protostar: Solutions for Exploit-Exercises Protostar Solutions for Exploit-Exercises Protostar. Contribute to z3tta/Exploit-Exercises-Protostar development by creating an account on GitHub. github.com gcc -z exexstack -w -no-pie -o stack6 stack6.c IF문을 보면 ret & 0xbf000000 과 and 연산을 하는데 ..

[pwnable] 시스템 해킹 ProtoStar - Stack5 (PLT, GOT)

이전에 풀었던 5번을 다른 방식으로 푼다. 바로 PLT, GOT를 이용한 풀이이다. PLT와 GOT란? PLT(procedure Linkage Table) : 외부 프로시저를 연결해주는 테이블, PLT를 통해 다른 라이브러리에 있는 프로시저를 호출 할 수 있다. GOT(Global Offset Table) : PLT가 참조하는 테이블, 프로시저들의 주소가 들어있다. 함수 호출(PLT) -> GOT (실제 함수의 주소가 저장) -> 처음일 때 -> 어떤 과정으로 주소를 가져옴 (생략) 함수 호출(PLT) -> GOT (실제 함수의 주소가 저장) -> 두 번째 -> 첫 번째 호출에서 알아낸 주소 참고) https://bpsecblog.wordpress.com/2016/03/07/about_got_plt_1/..

[pwnable] 시스템 해킹 ProtoStar - Stack5 (msfvenom, 어태치)

https://github.com/z3tta/Exploit-Exercises-Protostar/blob/master/05-Stack5.md GitHub - z3tta/Exploit-Exercises-Protostar: Solutions for Exploit-Exercises Protostar Solutions for Exploit-Exercises Protostar. Contribute to z3tta/Exploit-Exercises-Protostar development by creating an account on GitHub. github.com gcc -z execstack -w -no-pie -o stack5 stack5.c https://github.com/rapid7/metasploit-fr..

[pwnable] 시스템 해킹 ProtoStar - Stack4 (Return Address)

gcc -z execstack -w -no-pie -o stack4 stack4.c https://github.com/z3tta/Exploit-Exercises-Protostar/blob/master/04-Stack4.md GitHub - z3tta/Exploit-Exercises-Protostar: Solutions for Exploit-Exercises Protostar Solutions for Exploit-Exercises Protostar. Contribute to z3tta/Exploit-Exercises-Protostar development by creating an account on GitHub. github.com gets에서 BOF가 가능함!! return address를 win()..