SWLUG/์›น ํ•ดํ‚น

[Root Me] Javascript - Authentication 2

waterproof 2023. 9. 23. 20:39

https://www.root-me.org/en/Challenges/Web-Client/Javascript-Authentication-2

 

Challenges/Web - Client : Javascript - Authentication 2 [Root Me : Hacking and Information Security learning platform]

TCP - Back to school just blocks when i try to read the flag after i have sent the calculation. Not sure if my calculation is wrong or what is is?

www.root-me.org

 

 


 

Start the challenge ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ๋ฌธ์ œ๋ฅผ ํ‘ธ๋Š” ์›นํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜์ž.

 

 

 

 

 

๊ฐ€์žฅ ์ฒ˜์Œ์˜ ํ™”๋ฉด์ด๋‹ค.

 

"Authentication" ๋ผ๋Š” ๋ฌธ๊ตฌ,

๊ทธ ์•„๋ž˜์— login ๋ฒ„ํŠผ,

Close Window ๋ผ๋Š” ๋ฌธ๊ตฌ์— ๋งํฌ๊ฐ€ ๊ฑธ๋ ค์žˆ๋‹ค.

 

 

 

 

login ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋‹ˆ Username์„ ์ž…๋ ฅํ•˜๋ผ๋Š” ํŒ์—…์ฐฝ์ด ๋œฌ๋‹ค.

 

์•„์ง์€ ์•„๋Š” ๊ฒŒ ์—†์œผ๋‹ˆ

Username์— admin์„ ์ž…๋ ฅํ•œ ๋’ค ํ™•์ธ ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ฃผ์—ˆ๊ณ ,

๋ฐ”๋กœ ๋‹ค์Œ์— ๋‚˜์˜ค๋Š” Password๋„ admin์„ ์ž…๋ ฅํ•ด์คฌ๋‹ค.

 

 

 

 

 

"Nope, you're a naughty hacker." ๋ผ๊ณ  ์จ์žˆ๋Š” ํŒ์—…์ฐฝ์ด ๋œฌ๋‹ค.

 

 

 

 

๊ทธ๋ฆฌ๊ณ  Close Window ๋ฅผ ๋ˆŒ๋Ÿฌ์คฌ๋”๋‹ˆ ๋ฌธ์ œ๋ฅผ ํ’€๋˜ ์ฐฝ์ด ๋ง ๊ทธ๋Œ€๋กœ ๋‹ซํžŒ๋‹ค.

 

 

 

F12 ๋ฅผ ๋ˆŒ๋Ÿฌ ํŽ˜์ด์ง€์˜ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด์ž.

login ๋ฒ„ํŠผ์— ๋Œ€ํ•œ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ์ฝ๋‹ค๊ฐ€ ๊ถ๊ธˆํ•œ ์ ์ด ์ƒ๊ฒผ๋‹ค.

 

 

 

 

connexion();  ์€ ์–ด๋–ค ๋™์ž‘์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๊ฒƒ์ผ๊นŒ?

 

 

 

 

 

 

๋” ์ฐพ์•„๋ณด๋‹ˆ connexion ํ•จ์ˆ˜์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค.

F12 ๋ฅผ ๋ˆŒ๋Ÿฌ ํŽ˜์ด์ง€์˜ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด์ž.

 

 

 

 

function connexion(){
    var username = prompt("Username :", "");
    var password = prompt("Password :", "");
    var TheLists = ["GOD:HIDDEN"];
    for (i = 0; i < TheLists.length; i++)
    {
        if (TheLists[i].indexOf(username) == 0)
        {
            var TheSplit = TheLists[i].split(":");
            var TheUsername = TheSplit[0];
            var ThePassword = TheSplit[1];
            if (username == TheUsername && password == ThePassword)
            {
                alert("Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)");
            }
        }
        else
        {
            alert("Nope, you're a naughty hacker.")
        }
    }
}

 

์บก์ณํ™”๋ฉด์€ ๊ธ€์”จ๊ฐ€ ์ž˜ ์•ˆ ๋ณด์—ฌ์„œ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•ด ์ฝ”๋“œ๋ธ”๋Ÿญ์— ์˜ฎ๊ฒจ๋ณด์•˜๋‹ค.

 

 

 

์œ„์˜ ์†Œ์Šค์ฝ”๋“œ ์ „์ฒด ์ค‘์— 

 

if (username == TheUsername && password == ThePassword)
            {
                alert("Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)");
            }

 

์ด ๋ถ€๋ถ„์ด ๋ˆˆ์— ๋ˆ๋‹ค.

 

Username๊ณผ Password ์— ๋Œ€ํ•œ ์ •๋ณด๊ฐ€ ๋‚˜์™€์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

username์นธ์—๋Š” "TheUsername"์„, password์นธ์—๋Š” "ThePassword" ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๋ฌธ์ œ์˜ ์ •๋‹ต์„ ์•Œ ์ˆ˜ ์žˆ์„ ๊ฑฐ๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๋‹ค.

 

 

 

 

 

๊ทธ๋ž˜์„œ username์นธ์—๋Š” "TheUsername"์„, password์นธ์—๋Š” "ThePassword" ๋ฅผ ์ž…๋ ฅํ•ด๋ณด์•˜๋‹ค.

๊ทธ๋Ÿฐ๋ฐ ๋˜ "Nope, you're a naughty hacker." ๋ผ๊ณ  ์จ์žˆ๋Š” ํŒ์—…์ฐฝ์ด ๋–ด๋‹ค.

 

 

 

 

๋‹ค์‹œ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ์‚ดํŽด๋ณด์ž.

 

function connexion(){
    var username = prompt("Username :", "");
    var password = prompt("Password :", "");
    var TheLists = ["GOD:HIDDEN"];
    for (i = 0; i < TheLists.length; i++)
    {
        if (TheLists[i].indexOf(username) == 0)
        {
            var TheSplit = TheLists[i].split(":");
            var TheUsername = TheSplit[0];
            var ThePassword = TheSplit[1];
            if (username == TheUsername && password == ThePassword)
            {
                alert("Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)");
            }
        }
        else
        {
            alert("Nope, you're a naughty hacker.")
        }
    }
}

 

์‚ฌ์‹ค TheUsername ๊ณผ ThePassword ์ด ์˜๋ฏธํ•˜๋Š” ๊ฒƒ์€ ๋”ฐ๋กœ ์žˆ์—ˆ๋‹ค.

 

๋‹ค์‹œ ์ƒ๊ฐํ•ด๋ณด๋‹ˆ TheUsername ๊ณผ ThePassword์ด "" ์•ˆ์— ๋“ค์–ด๊ฐ€์žˆ๋˜ ๊ฒƒ๋„ ์•„๋‹ˆ๋‹ˆ

๋ฌธ์ž์—ด์„ ์˜๋ฏธํ•˜๋Š” ๊ฒƒ๋„ ์•„๋‹ˆ์—ˆ๋‹ค.... ใ…Žใ…Ž;;

 

 

 

 

 

๋‹ค์‹œ ํ•ด์„ํ•ด๋ณด๋ฉด,

 

var TheSplit = TheLists[i].split(":");๋ถ€๋ถ„์€

TheLists[i]์˜ ๊ฐ’์„ : ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆ„์–ด ๋ฐฐ์—ด๋กœ ์ €์žฅํ•œ๋‹ค.

์ฆ‰, ์‚ฌ์šฉ์ž๋ช…๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๊ฐ๊ฐ TheSplit[0]๊ณผ TheSplit[1]์— ์ €์žฅ๋œ๋‹ค.

var TheUsername = TheSplit[0];๋ถ€๋ถ„์€

์‚ฌ์šฉ์ž๋ช…์„ TheUsername ๋ณ€์ˆ˜์— ์ €์žฅํ•œ๋‹ค.

var ThePassword = TheSplit[1]; ๋ถ€๋ถ„์€

๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ThePassword ๋ณ€์ˆ˜์— ์ €์žฅํ•œ๋‹ค.

if (username == TheUsername && password == ThePassword) ๋ถ€๋ถ„์€

์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์‚ฌ์šฉ์ž๋ช…๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ TheLists ๋ฐฐ์—ด์—์„œ ๋ฐœ๊ฒฌ๋œ ์‚ฌ์šฉ์ž๋ช…๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ์ผ์น˜ํ•˜๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

alert("Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)"); ๋ถ€๋ถ„์€

์กฐ๊ฑด์ด ์ถฉ์กฑ๋˜๋ฉด, ์‚ฌ์šฉ์ž์—๊ฒŒ ํ•ด๋‹น ๋ฉ”์‹œ์ง€๋ฅผ ๋„์šด๋‹ค๋Š” ์˜๋ฏธ์ด๋‹ค. ์ฆ‰, ์˜ฌ๋ฐ”๋ฅธ ์‚ฌ์šฉ์ž๋ช…๊ณผ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•œ ๊ฒฝ์šฐ์ด๋‹ค.

 

 

 

 

๊ทธ๋Ÿฌ๋‹ˆ๊นŒ ๊ฒฐ๋ก ์ ์œผ๋กœ

 

":" ์ด์ „์˜ "GOD"๋ฅผ username์— ์ž…๋ ฅํ•˜๊ณ ,

"HIDDEN"์„ password์— ์ž…๋ ฅํ•˜๋ฉด

"Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)" ๋ผ๊ณ  ์ ํžŒ ๋ฉ”์‹œ์ง€๋ฅผ ๋„์šด๋‹ค๋Š” ๊ฒƒ์ด๋‹ค.

 

 

 

 

 

 

 

 

 

 

 

 

์‹ค์ œ๋กœ ํ•ด๋ดค๋”๋‹ˆ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ํ•ด์„ํ•œ๋Œ€๋กœ ๋œ๋‹ค.

"Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)"์—์„œ ์ด password๋ฅผ ์ด์šฉํ•ด validate this challenge ํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ–ˆ์œผ๋‹ˆ...

 

password ์˜€๋˜ "HIDDEN"์„ ์ •๋‹ต์œผ๋กœ ์ž…๋ ฅํ•ด๋ณด์ž.

 

 

 

 

์ •๋‹ต!

 

 

 

 

 

 

 

 

 

 

'SWLUG > ์›น ํ•ดํ‚น' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[webhacking.kr] old-12๋ฒˆ  (0) 2023.09.27
[Root Me] Javascript - Webpack  (0) 2023.09.26
[Root Me] HTTP - COOKIES  (0) 2023.09.23
[webhacking.kr] old-19๋ฒˆ  (0) 2023.09.19
[webhacking.kr] old-42๋ฒˆ  (0) 2023.09.18