09 November 2014

Function Address - 60

We found this program file on some systems. But we need the address of the 'find_string' function to do anything useful! Can you find it for us?
Since the program file is a binary file, we'd need a disassembler to view its contents. There are various ways to disassemble a binary file, but I decided to use Online Disassembler since I can view the File Info, Hex Dump, and I can view the Disassembly along with Sections of the code.

To upload the program file (which should be downloaded on your computer by now), I clicked on 'File', then 'Upload File...'


I named the project Function Address (since you have to give it a name, else it won't disassemble) after the problem itself, and then I uploaded the file before pressing 'Upload'


Platform Options were displayed, and after reading them I pressed 'Ok'


After waiting a few seconds, for everything to load, everything was disassembled and, conveniently, there is a column to the left where each function is listed along with its Memory Address (which is what we're trying to find for find_string)


I highlighted the find_string function along with its Memory Address for visibility.

Its Memory Address (and the flag) is 0x08048444

Toaster Control - 50

Daedalus Corp. uses a web interface to control some of their toaster bots. It looks like they removed the command 'Shutdown & Turn Off' from the control panel. Maybe the functionality is still there...
When opening the link and clicking on one of the buttons, I noticed how the page's URL looked like.

For example, clicking on 'Blink Lights', the URL would be http://web2014.picoctf.com/toaster-control-1040194/handler.php?action=Blink Lights
When clicking on 'Patrol Mode', the URL would be http://web2014.picoctf.com/toaster-control-1040194/handler.php?action=Patrol Mode
When clicking on 'Make Toast', the URL would be http://web2014.picoctf.com/toaster-control-1040194/handler.php?action=Make Toast

There is a pattern in that each of the URLs start with http://web2014.picoctf.com/toaster-control-1040194/handler.php?action=, and would end with the name of the button you were clicking.

So, since I wanted to activate the 'Shutdown & Turn Off' Command, you'd assume that the link would be http://web2014.picoctf.com/toaster-control-1040194/handler.php?action=Shutdown & Turn Off

But that would only bring me to this page:


But then how would I be able to go to the page? URL encoding, that's how. The problem actually lies in the ampersand ('&'), since it's not a URL-safe character. So by converting Shutdown & Turn Off to a URL-safe string, I'd be able to view the page.

I Google'd 'text to url' and found several text to URL converters. I used QuickEncoder, and pasted Shutdown & Turn Off into the box, then pressed 'Encode'


I copied the URL-safe string (Shutdown+%26+Turn+Off) and pasted it into the base URL (http://web2014.picoctf.com/toaster-control-1040194/handler.php?action=) so that it looked like http://web2014.picoctf.com/toaster-control-1040194/handler.php?action=Shutdown+%26+Turn+Off

I pressed 'Enter' and the following page appeared:


The shutdown code, and flag, is blatantly displayed as flag_c49bdkeekr5zqgvc20vc

Redacted - 50

You found a letter that may shed light on recent events.
Another simple question requiring no programming knowledge, when opening the .pdf letter, there are numerous censor boxes covering certain words and phrases. Since the .pdf file contains an image rather than text, one wouldn't be able to 'Select All' (CTRL + A or ⌘ + A), 'Copy' (CTRL + C or ⌘ + C), and 'Paste' (CTRL + V or ⌘ + V) the text itself into a word document.

But there's hope... something similar to that can still be done!

The black boxes aren't part of the image itself, they're simply overlaid onto the image, so it's very possible to get the image without the boxes. To do that, download the .pdf file (right-click and 'Save Page As').

When it's downloaded, open the file and either press on the document, or 'Select All' (CTRL + A or ⌘ + A).


The .pdf is tinted blue because the entire document is selected (I am using Adobe Reader, by the way).

When the entire document is selected, 'Copy' (CTRL + C or ⌘ + C) the document and open some type of text editor (e.g. TextEdit, Microsoft Word, etc.); I'm going to be using TextEdit.

When the text editor is open, 'Paste' (CTRL + V or ⌘ + V) the document you just copied, and it should look something like this:


As stated by the document, the super secret access code (and quite obviously, the flag) is one_two_three_four

Easy Overflow - 40

Is the sum of two positive integers always positive?
nc vuln2014.picoctf.com 50000
'nc' is the Linux netcat command. Try running it in the shell.
The rhetorical question in the beginning is actually a good hint by implying that, sometimes in Java, adding a number to another number will make it negative. Basic arithmetic and understanding of ints in Java are helpful in solving this problem.

Rather than running it in the shell, I decided to run it in the 'Terminal' (Mac). By opening 'Terminal' and typing in nc vuln2014.picoctf.com 50000, I was able to run the program. It looked  like this:


The number I was given was 2884043 (note that a different number is generated each time), and it is asking for a positive number that, when added, will make it negative.

I needed to know what the maximum Integer value was for Java, because if a number is added to it, it immediately becomes negative. I typed 'max int java' in Google:


I discovered that the maximum Integer value in Java is 231 - 1, or 2147483647 when expanded.

One would assume that we'd subtract the given number from the maximum Integer value, but that is not the case because we'd yield a non-negative int. So instead, we'd have to subtract the given number from maximum Integer value plus one, a.k.a. 231, or 2147483648 when expanded.

So, 2147483648 - 2884043 gave me 2144599605, which I entered into the Terminal.


The flag, which I highlighted, is That_was_easssy!

Javascrypt - 40

Tyrin Robotics Lab uses a special web site to encode their secret messages. Can you determine the value of the secret key?
This question is simple; basic knowledge of Javascript is required. Upon clicking the link, the site you are brought has an 'Input Message' and 'Output Message' box, along with an 'Encode' button. An example of the encryption done with the site is as follows:


Once again, 'View Source' is necessary. Right-click and press 'View Page Source' to, well, view the page's source. Immediately, at the bottom, is the Javascript for generating the key used to encode the message.


It should look something this:

       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 = 295;
         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);
       }

It is now clear that the key is the flag, and they're Strings starting with "flag_" and ending with the absolute value of one of the vars, x.

To find the flag, I converted the code to Java (since I am most comfortable with Java):

 public class Javascrypt {  
      public static void main(String[] args) {  
       int i = 1;  
       int x = 295;  
       int n = 5493;  
       while (i <= 25) {  
         x = (x * i) % n;  
         i++;  
       }  
       System.out.println("flag_" + Math.abs(x));  
      }  
 }  

I then ran it using Eclipse:


The flag is outputted as flag_3003

Grep is Still Your Friend - 40

The police need help decrypting one of your father's files. Fortunately you know where he wrote down all his backup decryption keys as a backup (probably not the best security practice). You are looking for the key corresponding to daedaluscorp.txt.enc. The file is stored on the shell server at /problems/grepfriend/keys.
Basic knowledge of grep commands is required. Login to your shell on picoCTF, and when that's done, simply type in the following command:
 grep "daedaluscorp" /problems/grepfriend/keys  
Press 'Enter', and the shell should look something like this


The highlighted text (b2bee8664b754d0c85c4c0303134bca6) is the flag.

RoboPhoto - 30

Another question that requires no language in programming, the question is
Your father has been known to use the titles of his favorite books as passwords. While you don't remember any of the names of the books, your father keeps a poster for one of them on his wall. Can you figure out the name of the book and unlock the CD?
Copy the image URL (https://picoctf.com/problem-static/misc/robo-photo/robophoto.jpg), and go to Google Images. Click on the camera icon:


Paste the URL into the box, then press 'Search by Image'.


Going through the page, there doesn't appear to be any book title names anywhere, so just click 'Visually similar images', since it looks as though the image is just a section of an entire book cover and there should be a match to that image somewhere.


Clicking on the first image that shows up, the entire cover of the book is shown (along with the title and author).


The flag, also known as the title of the book, is The Positronic Man.