White Security
neverlanctf 2019 - Dirty Validate writeup 본문
자바스크립트로 유저를 인증하도록 했다 합니다.
링크가 하나 주어지네요.
링크에 접속하면
로그인 폼이 하나 보입니다.
// reference here
// https://api.jquery.com/jQuery.ajax/
// https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/atob
// For element with id='name', when a key is pressed run this function
$('#name').on('keypress',function(){
// get the value that is in element with id='name'
var that = $('#name');
// make an ajax request to get the expected username
$.ajax('webhooks/get_username.php',{})
.done(function(data)
{ // once the request has been completed, run this function
data = JSON.parse(data);
if( data.usernames.indexOf(that.val()) != -1 ){ // see if the username is in the list
that.css('border', '1px solid green'); // if it matches turn the border green
$('#output').html('Username is correct'); // state that the user was correct
}else{ // if the user typed in something incorrect
that.css('border', ''); // set input box border to default color
$('#output').html('Username is incorrect'); // say the user was incorrect
}
}
);
});
// For the password input now
// This is a BAD idea, never validate sensitive data in javascript
$('#pass').on('keypress', function(){
// get value for element with id='pass'
var that = $('#pass');
// make an ajax request to get the expected password for the given username
$.ajax('webhooks/get_password.php?user='+encodeURIComponent($('#name').val()),{})
.done(function(data)
{// once the request has completed, run this function
// remove whitespace from data
data = data.replace(/(\r\n|\n|\r)/gm,"");
// check if the data matches the given value
if(window.atob(data) == that.val()){
// if value is correct, show a green border
that.css('border', '1px solid green');
$('#output').html(window.atob(data));
}else{
// if value is false, remove border
that.css('border', '');
$('#output').html('Password is incorrect');
}
}
);
});
소스를 살펴보면
먼저 아이디를
webhooks/get_username.php 페이지에 있는지 확인하고
이후 패스워드를
webhook/get_password.php?user= 에서 점검하여
유효하다면
base64 복호화 한 후, 화면에 출력하도록 되어 있군요.
https://challenges.neverlanctf.com:1135/webhooks/get_username.php
따라서 webhooks/get_username.php 에 접속하면
모든 유저 목록을 조회할 수 있었습니다.
https://challenges.neverlanctf.com:1135/webhooks/get_password.php?user=Dr. Whom
또한 webhooks/get_password.php 페이지에서
username을 인자로 비밀번호까지 조회할 수 있는데
Dr. Whom 의 비밀번호 데이터를
복호화 하니, 플래그를 얻을 수 있었습니다.
flag{D0n't_7rus7_JS}
'CTF Writups' 카테고리의 다른 글
| neverlanctf 2019 - React to this writeup (0) | 2019.02.04 |
|---|---|
| neverlanctf 2019 - purvesta writeup (0) | 2019.02.04 |
| neverlanctf 2019 - Das Blog 2 writeup (0) | 2019.02.04 |
| neverlanctf 2019 - Das Blog writeup (0) | 2019.02.04 |
| neverlanctf 2019 - Cover the BASEs writeup (0) | 2019.02.04 |
Comments