R136A1

[xcz.kr] PROB.18 ::js 본문

WEB SECURITY/html | javascript | php

[xcz.kr] PROB.18 ::js

r136a1x27 2021. 4. 17. 23:31

xcz.kr의 모든 소스는 본 페이지임

<html>
<head>
<link rel="shortcut icon" href="../images/favicon.ico" type="image/x-icon">
<title>Prob18</title>
</head>
<body style="background-image:url('../images/content-tail.gif');">
<b>Title</b></br>
<i>Comming Soon</i></br></br>
<b>Description</b></br>
<font size="2px">
View source</br>
<?
$key = "Congratulations!</br>Key is ??????????????????";
$liillillilliliili = @$_COOKIE['c'];
$liillillliiiliili = @$_GET['g'];
$lilllillliiiliili = @$_POST['p'];
if(empty($liillillilliliili) || empty($liillillliiiliili) || empty($lilllillliiiliili)){exit ('wrong T.T');}
$lililillliiiliili = $liillillliiiliili . $liillillilliliili;
$lilililliiiiliill = $lilllillliiiliili;

function test($a){
$b = '';
    for($i=0; $i < strlen($a); $i++){
        $b = $b . ' - ' . ord(substr($a,$i,1));
    }
    return $b;
}
if(test($lililillliiiliili)==" - 103 - 105 - 118 - 101 - 109 - 101 - 112 - 97 - 115 - 115 - 119 - 111 - 114 - 100" || test($lilililliiiiliill) == " - 107 - 101 - 121 - 112 - 108 - 122 - 33"){
    echo $key;
}
else{
    echo 'wrong T.T';
}
?>
</font>
</body>
</html>

메모장에서 난독화된 liil....이런거 다 바꾸기 cookie get post로

원본 저장

liillillilliliili  = cookie[c]
liillillliiiliili = get[g]

lilllillliiiliili = post[p]

 

 

<?
$key = "Congratulations!</br>Key is ??????????????????";
$cookie = @$_COOKIE['c'];
$get = @$_GET['g'];
$post = @$_POST['p'];
if(empty($cookie) || empty($get) || empty($post)){exit ('wrong T.T');}
$getcookie = $get . $cookie;
$post2 = $post;

function test($a){
$b = '';
    for($i=0; $i < strlen($a); $i++){
        $b = $b . ' - ' . ord(substr($a,$i,1));
    }
    return $b;
}
if(test($getcookie)==" - 103 - 105 - 118 - 101 - 109 - 101 - 112 - 97 - 115 - 115 - 119 - 111 - 114 - 100" 
			|| test($post2) == " - 107 - 101 - 121 - 112 - 108 - 122 - 33"){
    echo $key;
}
else{
    echo 'wrong T.T';
}
?>

 

일단 getcookie 합쳐서 - 103 -105..넣으면 되고

요건은 test($post2)인데, 해당 함수를 살펴보면

한글자씩 떼서 ASCII 코드로 변환한 값이다.

107 101 121 112 108 122 33 을 ord의 역함수인 chr(),

console에서 사용하기 위해 javascript에서는 String.fromCharCode(int)

keyplz!

 

getcookie - 103 - 105도 복사해서 103,105로 바꿔준다

<form action="prob18.php?g=giveme" method="POST">

<input type="text" name="p" value="keyplz!">

<input type="submit" value="submit">

</form>

 

liillillilliliili  = cookie[c]  password
liillillliiiliili = get[g] giveme

lilllillliiiliili = post[p] keyplz!

이므로 g, p 로 저장해주고 쿠키도 생성해줘서 넣어야 한다(빈 곳 있으면 escape 되므로

chrome 확장 프로그램 Cookie Manager

*주의. 위처럼 쿠키를 설정했는데도 EditThisCookie(이중확인용 확장프로그램)에 보이지 않는다면

Path가 잘못된 것으로, 구체적인 주소 대신 / 만 넣어주자. 대신 문제를 풀고 바로 삭제해야 한다.

 

 

해당 유형은 POST와 GET COOKIE의 사용을 한 번에 묻는 문제로

r136a1x27.tistory.com/53 에도 한 번 다룬 적 있었다.

Comments