[Writeup] Secret E-Diary | Javascript patch challenge | Easy CTF Challenges

July 3, 2018 Script hunter

Recently i came through new Easy Ctf Challenge task-link and this is a Secret E-diary ctf challenge writeup which is based on Javascript patch challenges.

Secret E-Diary CTF Challenge Writeup

Full analysis of Task:
Task has given a from with username and password and we need to bypass it for looking at secret of diary so start with Looking at the source code ,you will find a index.js which is controlling entries of username and password dynamically.
Code Snippet of Index.js:
ctf challenge writeup
look at the line -> if(user != String.fromCharCode(97,100,109,105,110))
String.fromCharCode() function convert the ascii decimal value to ascii characters.
its mean ->
97 -> ‘a’
100 -> ‘d’
109 -> ‘m’
105 -> ‘i’
110 -> ‘n’
97 is ascii value of character ‘a’.
Its mean username is accepted by admin only which is already mentioned there.
so we determined Username:admin.
Now lets check for Password entry.

var pass = document.getElementById('pass').value;
        var lol = pass.split('');
        var asciisum = 0;
        for(var i =0;i<lol.length;i++)
            asciisum += lol[i].charCodeAt();
        if(asciisum == 1450)
            document.getElementById('check').style.color = 'green';
            document.getElementById('check').innerHTML = "\x43\x48\x45\x52\x52\x59\x7b\x4a\x61\x76\x61\x53\x63\x72\x69\x70\x74\x5f\x49\x73\x5f\x41\x77\x45\x53\x6f\x4d\x45\x7d";
            document.getElementById('secret').style.color = 'blue';
            document.getElementById('secret').innerHTML = '\x4e\x61\x72\x65\x6e\x64\x72\x61\x20\x4d\x6f\x64\x69\x20\x77\x69\x6c\x6c\x20\x62\x65\x20\x49\x6e\x64\x69\x61\x27\x73\x20\x6e\x65\x78\x74\x20\x50\x72\x69\x6d\x65\x20\x4d\x69\x6e\x69\x73\x74\x65\x72\x20\x69\x6e\x20\x32\x30\x31\x39\x20\x61\x67\x61\x69\x6e\x21\x21';
            document.getElementById('check').style.color ='red';
            document.getElementById('check').innerHTML = 'Invalid Password';
1: var lol = pass.split(''); is spliting every character of password into a array.
2: for(var i =0;i<lol.length;i++)
asciisum += lol[i].charCodeAt();
is adding all character’s ascii value.
3: if(asciisum == 1450) condition will accept if above sum of ascii characters of password is equal to 1450.

Final Payload

Now we got that we need to generate such strings which sum of ASCII characters is equal to 1450.
such strings are:

  1. i_hate_hackers
  2. hate_i_hackers
  3. ateh_i_hackers
  4. hckaers__ihate

so on…
you need only one string as a password.I am taking i_hate_hackers as a password ,you can choose anyone of them.
Now we have

Username: admin  Password: i_hate_hackers.

secret diary ctf writeup
Boom..We got Flag and secret of diary.
Secret:Narendra Modi will be India’s next Prime Minister in 2019 again!!.
Verify this flag at challenge page.
Thank you ,if you could not understand something please stick with comment section and ask.
For more Outpost click below ->