Web exploitation problem

Learn the basics of how to exploit JavaScript.

Web exploitation problem

Post by ghostheadx2 on Mon May 18, 2015 11:02 pm
([msg=88102]see Web exploitation problem[/msg])

I'm trying to exploit based on a hackathon that goes all year called Pico CTF. I want to be able to find what the hidden key is. Could someone please explain the code a little bit?

Code: Select all
            var key; // Global variable.
           
            // Since the key is generated when the page
            // is loaded, no one will be able to steal it
            // by looking at the source! This must be secure!
            function generateKey() {
                var i = 1;
                var x = 37;
                var n = 5493;
                while (i <= 25) {
                    x = (x * i) % n;
                    i++;
                }
                key = "flag_" + Math.abs(x);
            }
           
            generateKey();
           
            // Encode the message using the 'key'
            function encode() {                                                       
                var input = $("#inputmessage").val();
                var output = CryptoJS.AES.encrypt(input, key);
                $("#outputmessage").val(output);
            }       
ghostheadx2
Contributor
Contributor
 
Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)


Re: Web exploitation problem

Post by Turn on Mon May 18, 2015 11:25 pm
([msg=88104]see Re: Web exploitation problem[/msg])

This looks like JavaScript.
You can just let the function finish up generating the key and then before encryption, print it out in whatever method you would like.
Change:
Code: Select all
key = "flag_" + Math.abs(x);


to

Code: Select all
key = "flag_" + Math.abs(x);
alert(key);


See if this does the trick.
Social Engineering:
<cen> .lua print ('Tsyn 9.47.-u 3 12 5')
* slickery has quit (User has been banned from HackThisSite (Attempting to use a SpyBot))
* cen has quit (User has been banned from HackThisSite (Attempting to use a SpyBot))
User avatar
Turn
Poster
Poster
 
Posts: 120
Joined: Tue Feb 17, 2015 5:42 am
Blog: View Blog (0)


Re: Web exploitation problem

Post by ghostheadx2 on Mon May 18, 2015 11:36 pm
([msg=88106]see Re: Web exploitation problem[/msg])

Alert sends the user an alert box and in the box, the key is printed. Sort of like an error or box normally used for telling the user something like "this page may contain a virus." I like it.
ghostheadx2
Contributor
Contributor
 
Posts: 728
Joined: Wed Nov 19, 2014 1:19 am
Blog: View Blog (0)


Re: Web exploitation problem

Post by pretentious on Wed May 20, 2015 6:15 am
([msg=88125]see Re: Web exploitation problem[/msg])

ghostheadx2 wrote:Sort of like an error or box normally used for telling the user something like "this page may contain a virus." I like it.

:P kids are already calling floppy disks save buttons.
Goatboy wrote:Oh, that's simple. All you need to do is dedicate many years of your life to studying security.

IF you feel like exchanging ASCII arrays, let me know ;)
Can you say brainwashing It's a non stop disco
User avatar
pretentious
Addict
Addict
 
Posts: 1202
Joined: Wed Mar 03, 2010 12:48 am
Blog: View Blog (0)


Re: Web exploitation problem

Post by cyberdrain on Wed May 20, 2015 5:07 pm
([msg=88131]see Re: Web exploitation problem[/msg])

pretentious wrote::P kids are already calling floppy disks save buttons.

Ah... So THAT's what those are... (joking obviously)
Free your mind / Think clearly
User avatar
cyberdrain
Expert
Expert
 
Posts: 2160
Joined: Sun Nov 27, 2011 1:58 pm
Blog: View Blog (0)



Return to Javascript

Who is online

Users browsing this forum: No registered users and 0 guests