FTZ level18

2021. 3. 16. 01:35·Write-Up/해커스쿨 FTZ
반응형
#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
'Write-Up/해커스쿨 FTZ' 카테고리의 다른 글
  • FTZ level20
  • FTZ level19
  • FTZ level17
  • FTZ level16
Penguin Dev
Penguin Dev
What does the Penguin say?
    글쓰기 관리
  • Penguin Dev
    Pengha!
    Penguin Dev
  • 전체
    오늘
    어제
    • 분류 전체보기 (151)
      • Java & Spring (3)
      • System Hacking (4)
      • Algorithm (8)
        • Sorting algorithm (3)
      • Python (6)
      • DB (1)
      • Web (2)
        • Web Hacking & Security (2)
      • Write-Up (108)
        • pwnable.kr (17)
        • HackCTF (16)
        • 해커스쿨 FTZ (21)
        • LOB(lord of bufferoverflow) (19)
        • LOS (lord of sql injection) (28)
        • XSS-game (6)
        • Webhacking.kr (1)
      • SUA (19)
        • 오픈소스 보안 (19)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    Java
    MAP
    nop sled
    동시성
    spring
    ConcurrentHashMap
    computeifpresent()
    putval()
    Bubble Sort
    computeifabsent()
    LOB
    코딩테스트
    AtomicLong
    thread-safe
    enumerate #list comprehension
    코드트리
    동시성처리
    lord of bufferoverflow
    spring boot
    tabat
    selection sort
    시스템해킹
    CountDownLatch
    sqlinjection
    concurrenthashmap vs hashmap
    computeifabsent
    코드트리조별과제
    DB정리
    computeifpresent
    hashmap vs concurrenthashmap
  • 최근 댓글

  • 반응형
  • hELLO· Designed By정상우.v4.10.3
Penguin Dev
FTZ level18
상단으로

티스토리툴바