반응형
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
void shellout(void);
int main()
{
char string[100];
int check;
int x = 0;
int count = 0;
fd_set fds;
printf("Enter your command: ");
fflush(stdout);
while(1)
{
if(count >= 100)
printf("what are you trying to do?\n");
if(check == 0xdeadbeef)
shellout();
else
{
FD_ZERO(&fds);
FD_SET(STDIN_FILENO,&fds);
if(select(FD_SETSIZE, &fds, NULL, NULL, NULL) >= 1)
{
if(FD_ISSET(fileno(stdin),&fds))
{
read(fileno(stdin),&x,1);
switch(x)
{
case '\r':
case '\n':
printf("\a");
break;
case 0x08:
count--;
printf("\b \b");
break;
default:
string[count] = x;
count++;
break;
}
}
}
}
}
}
void shellout(void)
{
setreuid(3099,3099);
execl("/bin/sh","sh",NULL);
}
check가 0xdeadbeef면 shellout이 실행된다
main + 499 가 string이고
main+91 이 check이다
둘 사이에 거리는 4이다
string 위에 check가 있으므로 -4후에 deadbeef를 넣어주면된다.
\x08을 넣어서 count--해주자
반응형
'Write-Up > 해커스쿨 FTZ' 카테고리의 다른 글
FTZ level20 (0) | 2021.03.17 |
---|---|
FTZ level19 (0) | 2021.03.16 |
FTZ level17 (0) | 2021.03.16 |
FTZ level16 (0) | 2021.03.16 |
FTZ level15 (0) | 2021.03.16 |