io.smashthestack.org – Level 2

Level 2 문제를 실행하면 아래와 같다.

level2@io:/tmp/by$ /levels/level02
Append the 39th through 42nd numbers in the sequence as a string and feed it to this binary via argv[1]. 1, 2, 3, 5, 8, 13, 21...
The 4th through the 7th numbers would give you 581321
level2@io:/tmp/by$ 

위 수열에서 39번째부터 42번째를 이어서 쓴 값을 argv[1]로 넣으라고 한다...

#!/usr/bin/python
'''
Append the 39th through 42nd numbers in the sequence as a string and feed it to this binary via argv[1]. 1, 2, 3, 5, 8, 13, 21...
The 4th through the 7th numbers would give you 581321
'''
list = [1, 2, 3]
for x in range(1, 43):
    tmp =  list[x] + list[x+1]
    list.append(tmp)

ret = ''
for x in range(38, 42):
    ret += str(list[x])
print ret
level2@io:/tmp/by$ ./level2.py 
102334155165580141267914296433494437
level2@io:/tmp/by$ /levels/level02 102334155165580141267914296433494437
Win.
sh-3.2$ id
uid=1002(level2) gid=1002(level2) euid=1003(level3) groups=1002(level2),1029(nosu)
sh-3.2$ cat /home/level3/.pass 
okviql9o
sh-3.2$ 

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다