1. Description
Clam wrote a program for his school's cybersecurity club's first rev lecture! Can you get it to give you the flag? You can find it at /problems/2020/revving_up on the shell server, which you can access via the "shell" link at the top of the site.
Author: aplet123
2. Write up
# file revving_up
revving_up: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=e9a5285cc0d71320a73e27870a35a98efbe01a87, not stripped
Bash
복사
문제 파일은 ELF 64bit 파일이다.
$ ls -al
total 36
drwxr-xr-x 2 problem2020_revving_up problem2020_revving_up 4096 Mar 14 00:17 .
drwxr-xr-x 16 root root 4096 Mar 14 01:00 ..
-rw-r--r-- 1 problem2020_revving_up problem2020_revving_up 220 Aug 31 2015 .bash_logout
-rw-r--r-- 1 problem2020_revving_up problem2020_revving_up 3771 Aug 31 2015 .bashrc
-r--r----- 1 problem2020_revving_up problem2020_revving_up 39 Mar 9 23:33 flag.txt
-rw-r--r-- 1 problem2020_revving_up problem2020_revving_up 655 May 16 2017 .profile
-r-xr-sr-x 1 problem2020_revving_up problem2020_revving_up 8792 Mar 9 23:33 revving_up
$ id
uid=12270(team6332) gid=12270(team6332) groups=12270(team6332),1001(teams)
Bash
복사
문제 서버내에 있는 문제 디렉토리로 이동해서 안의 내용을 보면 위와 같다.
나의 계정은 team6332이고 flag.txt를 보기 위해서는 problem2020_revving_up의 계정 권한이나 그룹 권한이 필요하다. 같은 경로에 revving_up이라는 파일이 존재하는데 이 파일은 SetGID 권한이 걸려있다. 따라서 revving_up을 이용해서 flag.txt를 열어야 한다.
문제 파일을 IDA에서 열어본 뒤 Pseudocode 형태로 보면 위와 같다.
여기서 눈에 띄는 것은 print_flag()라는 함수이다.
print_flag() 함수의 내부를 보면 flag.txt 출력해주고 있다. 그렇다면 print_flag() 함수를 호출할 조건만 만족시켜주면 이 문제는 풀린다.
print_flag()함수가 호출되기 위해서는 두가지 조건이 필요하다. 위의 코드를 해석해보면 입력한 값이 "give flag"와 일치해야 하고 1번째 인자값(argv[1])이 "banana"와 일치하면 flag를 얻을 수 있다.
$ ./revving_up banana
Congratulations on running the binary!
Now there are a few more things to tend to.
Please type "give flag" (without the quotes).
give flag
Good job!
Well I think it's about time you got the flag!
actf{g3tting_4_h4ng_0f_l1nux_4nd_b4sh}
Bash
복사
3. FLAG
actf{g3tting_4_h4ng_0f_l1nux_4nd_b4sh}