Month: June 2020

Home / Month: June 2020

Hi everyone,

In this post, we will be deploying a PyKMIP server that stores its keys in a database. Unlike the docker container, the keys will be saved so on a reboot your keys are not lost.

So what exactly is this for? Well, in my use-case, I will be using this server to encrypted virtual machine files and drives.

For this tutorial, we will be using self-signed certs and this keys will be stored in a sqlite database. This is not secure at all! However, it will allow you to evaluate and learn the KMS functions within vCenter.

What we will need:

  • Ubuntu Server 18.04 or 20.04 LTS installation ISO.
  • One virtual machine to install Ubuntu Server 18.04 or 20.04 LTS on.
  • A network connection to install some packages.

First what we do is we create a virtual machine. This is just how it’s always done. You create a Ubuntu VM and install Ubuntu on it, this should be straightforward.

Now comes the fun part. the green commands should be executed as a user, the red commands as root. Re-place <$username> with your regular account’s username.

sudo -i
apt-get update
apt-get upgrade
mkdir /usr/local/PyKMIP
mkdir /etc/pykmip
mkdir /var/log/pykmip
chown <$username>: -R /usr/local/PyKMIP
chown <$username>: -R /etc/pykmip
chown <$username>: -R /var/log/pykmip
apt -get install python2-dev libffi-dev libssl-dev libsqlite3-dev python2-setuptools python2-requests
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/selfsigned.key -out /etc/ssl/certs/selfsigned.crt

Then fill out the form for the SSL certificate. The above certificate will be valid for 10 years. (3650 days)

chown <$username>: -R /etc/ssl/private
chown <$username>: /etc/ssl/certs/selfsigned.crt
exit


cd /usr/local
git clone https://github.com/OpenKMIP/PyKMIP

nano /etc/pykmip/server.conf

Paste the following into the file: (replace x.x.x.x with your VM’s IP)

[server]
database_path=/etc/pykmip/pykmip.database
hostname=x.X.X.X
port=5696
certificate_path=/etc/ssl/certs/selfsigned.crt
key_path=/etc/ssl/private/selfsigned.key
ca_path=/etc/ssl/certs/selfsigned.crt
auth_suite=TLS1.2
policy_path=/usr/local/PyKMIP/examples/
enable_tls_client_auth=False
tls_cipher_suites=
TLS_RSA_WITH_AES_128_CBC_SHA256
TLS_RSA_WITH_AES_256_CBC_SHA256
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
logging_level=DEBUG

Almost done! Now we need to edit our crontab to start the service at startup.

crontab -e

Paste the following in on a new line:

@reboot ( sleep 30s; python2 /usr/local/PyKMIP/bin/run_server.py & )

This will make sure that it starts automatically on startup. Reboot your VM or type this in to start it as a background process:

python2 /usr/local/PyKMIP/bin/run_server.py &

Now we need to go to our vCenter. We click on the vCenter and go to configure. Then under Key Providers, we click “Add Standard Key Provider”.

Give it a name under “Name” and “KMS”. Type in the IP address under “Address” and the port number, which by default is 5696 under “Port”. Then click on “Add Key Provider”.

Once you have done that we need establish trust. Click on the Key Provider, then at the bottom click on the KMS server. Click on “Establish Trust” followed by “Make KMS trust vCenter”. Click on “KMS certificate and private key” and then on “Next”.

Now, we need to fill in the KMS certificate and private key. On the VM, run:

cat /etc/ssl/certs/selfsigned.crt

Paste the output (with the dashes!) under KMS certificate.

cat /etc/ssl/private/selfsigned.key

Paste the output (with the dashes!) under “KMS Private Key”.

Now click on “Establish Trust” and we’re done! Now you should be able to use your new KMS server in your lab!

If you want to somewhat tighten security, don’t use the self-signed certificate but use your own certificates and lock down access to the VM, since the database with all your VM keys sits as a file on the filesystem of the VM.

If you have any questions, feel free to contact me through email or Twitter.

Have a great day!

Hilltop CTF – Writeups

June 4, 2020 | CTF, Hilltop CTF, Security | No Comments

Hi everyone,

A blog post on a different topic this time. I was a Content Engineer for the Hilltop CTF event.

Write-up for the Fuzz challenge.

Challenge name: Fuzz

Creator: MasterWayZ

Category: Analysis/Fuzzing


Summary:

The user is given a URL to look at: http://shellserver1.hilltopctf.masterwayz.nl:5876/

How-To:

  1. Using a program like gobuster, we can try to see what directories exist: gobuster dir -u http://shellserver1.hilltopctf.masterwayz.nl:5876/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt.
  2. We get a /301 redirect of /penguins. From here, it’s a matter of running gobuster dir -u http://shellserver1.hilltopctf.masterwayz.nl:5876/penguins/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x txt. The txt extension comes from the .txt file part in the README.md file.

Explanation:

  • We use gobuster to try to see what folder it is hidden in. dir specifies directory mode, -u specifies the URL and -w specifies the wordlist.
  • a 301 redirect of /penguins means that we’ve found something. Now we need to find the file in that directory. The new flag, -x specifies the extension used by gobuster to try to find files.

Write-up for the Fuzzy challenge.

Challenge name: Fuzzy

Creator: MasterWayZ

Category: Analysis/Fuzzing, Attacks/Cracking


Summary:

For this challenge, you need to fuzz a Flask webserver to start with. Followed by brute-forcing a password and then automating or guessing the missing character in the flag.

How-To:

  1. First we try to fuzz a directory. We can use gobuster with this. gobuster dir -u http://shellserver1.hilltopctf.masterwayz.nl:39345/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
  2. We will find that we get a 401 error with /email. Looking at it in the webbrowser, we see that we are given a clue that the username is admin, so we just need to brute-force the password. We can do this with hydra. hydra -l admin -P /usr/share/wordlists/rockyou.txt -s 39354 -f shellserver1.hilltopctf.masterwayz.nl http-get /email. We find the the password is ‘michelle’.
  3. We see the flag, sort of. The ‘!’ in the flag has to be some kind of ASCII character. You can try all of them by hand or automate it. Once you’ve done that, you find that it is 5, making the flag HilltopCTF{FuzzyFuzzyFuzzyFuzzyFuzzy5_08b353dc330dcad5734172ff5009f5e6b3826d49fa7243f3e598effb85bef982}.

Explanation:

  • We first use gobuster to try to find out if there’s a hidden directory. dir specifies directory mode and -w specifies the wordlist.
  • We get a 401 for /email. Which means that it is most likely asking for some kind of authentication. Visiting it with a browser shows that the username is ‘admin’.
  • We use hydra to try to crack the password. -l specifies the login, in this case ‘admin’. -P specifies a password file, in this case rockyou.txt, -s is for the port number and -f specifies the hostname, http-get means that we want to use an HTTP GET request and /email is the path that you want to crack.
  • We get access to a partial flag. the ‘!’ in the flag is not valid. We need to try to see what ASCII or Extended ASCII character we can put in there. You can try this yourself, or automate it.

Write-up for the Injection challenge.

Challenge name: Injection

Creator: MasterWayZ

Category: Attacks/SQL Injection


Summary:

For this you need to perform a SQL injection on a webform in order to dump the database.

How-To:

  1. Go to the website. Look at the site and you will see a form. Proxy this form through something like burp, and save the request made.
  2. Use sqlmap with the request. For example, sqlmap -r injection.req.
  3. After running, it will find some ways to perform a SQL injection. After this, the easiest thing to do is to dump everything with sqlmap. Run: sqlmap -r injection.req --dump.
  4. Piece the flag together. It’s spread across three tables. It’s clear what the start and end is, because of the start of the flag and the } at the end of the flag. The piece with no bracket in it at all is the middle one.

Explanation:

  • We visit the website and only see search related things and a web form. This form submits ID to index.php, which is trying to indicate to the user at some kind of SQL is being performed. We proxy the request through burp and save it to a file. (Proxying through Burp is an easy way to get a request. We need the POST request.)
  • We use sqlmap to test the form for SQL Injection. The -r flag specifies the request and we give it the saved request.
  • When it runs for a while, we specify that we want to do MySQL tests only, as it successfully identified it as a MySQL based SQL server. After a while, it will find multiple vulnerabilities.
  • We use sqlmap again with -r to specify the request file and --dump to dump all contents.
  • From here it’s a case of finding the three flag pieces. It’s easy to see the start and end piece (from the { and }) and there is only one middle piece.

Flag locations:

  • The first part is located in the federal table.
  • The second part is located in the taskforce table.
  • The third part is located in the Guests table.

Write-up for the Backstab challenge.

Challenge name: Backstab

Creator: MasterWayZ

Category: Analysis/Fuzzing, Cryptography/Cracking


Summary:

For this challenge, you had to fuzz the initial webserver to see a passwd file and a secured area. You crack the hash and gain access to the secured area, where you fuzz for the flag.

How-To:

  1. Use a program like gobuster to do the inital scan. gobuster dir -u http://shellserver1.hilltopctf.masterwayz.nl:5843/ -w /usr/share/wordlists/directory-list-2.3-medium.txt
  2. After a while, you will see /secure and /passwd. Download the passwd file and use a program like hashcat with rockyou.txt to crack it: hashcat -m 3700 encrypted.hash /usr/share/wordlists/rockyou.txt.
  3. The password will be found and you can log into /secure with the username and password. The username is given in the challenge description.
  4. Fuzz the /secure/ area and you will find /flag. This contains the flag. We can do that with gobuster dir -u http://shellserver1.hilltopctf.masterwayz.nl:5843/secure/ -w /usr/share/wordlists/directory-list-2.3-medium.txt. (note the /secure/ at the end, especially the last /!)

Explanation:

  • First we run gobuster in directory mode to fuzz some directories and files on the webserver. -u specifies the URL and -w specifies the wordlist.
  • Once we download the hash file, we use hashcat to crack this. -m 3700 is equal to setting mode 3700 which is bcrypt. Finally with -w we specifiy the wordlist, in this case rockyou.
  • Once we have the password, we use that to log into the /secure area.
  • Once in the /secure area, we use gobuster on /secure/ to check for hidden files, and it will find /secure/flag which contains the flag.

Write-up for the Johnny challenge.

Challenge name: Johnny

Creator: MasterWayZ

Category: Cryptography/Cracking


Summary:

For this challenge, the user is given an encrypted .zip file with the flag inside.

The user has to crack the password, which is in rockyou.txt

There are many ways to do this, here is one way:

How-To:

  1. Install john
  2. Download the .zip file
  3. Run zip2john flag.zip > encrypted-zip.john
  4. Run john --format=zip encrypted-zip.john --wordlist=/usr/share/wordlists/rockyou.txt
  5. Once it finishes, run john encrypted-zip.john --show
  6. Use the password, which in this case is ‘patricia’.
  7. Unzip the ZIP file, run unzip flag.zip.

Explanation:

  • What we just did above was use the power of John the Ripper to crack the password.
  • zip2john converts the zip file into a format that john can read.
  • The command after that forces the ZIP format on the encrypted john file and cracks it using the rockyou wordlist.
  • Finally, the --show is used to let john show the password.
  • Then you can extract the file and obtain the flag.

Write-up for the Julius challenge.

Challenge name: Julius

Creator: MasterWayZ

Category: Cryptography/Cracking


Summary:

The best way would be to think of the ROT cipher and then identity to use ROT47 as this is the only one that fits. ROT13 and ROT18 lack some of the characters used.

The rotation is a method of brute-force, in this case it’s 13.

The title of this challenge was chosen to make the user think of the the Caesar chipher and hint towards ROT ciphers. However, it’s also a bit misleading as the user will see that the characters used in the encrypted message cannot exist in a Caesar encoded textfile.


Write-up for the OhSINT challenge.

Challenge name: OhSINT

Creator: MasterWayZ

Category: OSINT/Forensics


Summary:

For this challenge you had to perform some OSINT.

We start with looking at the EXIF data of the jpg file, which leaks a URL to a website. From there, you can to find the pieces of the flag that are spread over the website.

How-To:

  1. Run exiftool image.jpg and look at the comments.
  2. Access the website and look for the clues, you will find them here: one is located on the index page, if you press CTRL and A you will find it, or if you view the source. The second one is located in the view source of the index page as well, but can also be found by clicking the Maps button. The third is one found under the blog button and then view source.

Explanation:

  • We download the file and then run exiftool to look at the EXIF data of the fail, which contains a comment with an URL to visit.
  • We visit the url and are presented with a web page. Here it’s a sign to view sources, use CTRL A and visit every page and click everything to find the three hidden flags.

Flag locations:

  • The first part of the flag is hidden as a near-white text on the index.html page.
  • The second part is under the Blog button at blog.html, view the source and see the flag in an HTML comment.
  • The third part is back on the index.html page, under the Location Maps button.

Write-up for the Fuzzy challenge.

Challenge name: Fuzzy

Creator: MasterWayZ

Category: Steganography


Summary:

The user downloads the image.jpg file, opens it in a text editor, finds the ascii85 flag and decodes it.

How-To:

  1. We download the file using wget.
  2. Running strings image.jpg is one of the ways to get the flag.
  3. Identify that the flag is ascii85 encrypted and decrypt it.

Explanation:

  • wget followed by the URL is used to download a file.
  • cat, or strings (and many more tools) are used to display the contents of a file. In this case, both work as the flag is hidden at the bottom of the image.
  • One of the ways to identify that it is ascii85 is because of the characters used in the encoding. You can use a local tool or online tool to decode it and get the flag.

If you have any questions, please let me know. I’ll be seeing if I can release the files and/or containers somehow.

Have a great day!

Hi everyone,

Time for a new blog post about the adventure I’ve been having for the past two days.

On June 2nd, my server, a DL380G6 started to suddenly take-off. The fans were roaring at 70%, and the temperature sensor near the PCI Riser was showing 110 C. Of course this is not supposed to happen, in this blog post, I will take you through my experience of troubleshooting this and hopefully this can help you.

Okay, so we know that the temperature sensor is showing a very high temperature. Let’s remove the PCI riser and see if the sensor is defective or not. I removed it, and it was showing a normal 60 C. Okay, so there is some PCI card that is getting very hot.

Step two: we put the riser back in. However, since my has two cards in it, I leave one out. I left the Smart Array P420 RAID controller in, and took the quad gigabit NIC out. I turn it back on, and once the sensor initializes, I check it. It was once again showing 110 C. Very odd.

Next I swap the cards around, having the NIC in the bottom slot, and I take out the RAID controller. I once again turn it back on, and now it seems to be fine. Temperature shows 64 C. Well, it seems to be the controller then.

Next step: let’s put the RAID controller back in, and leave its backup capacitor disconnected. I saw that in the IML that the controller says that it is defective. Maybe this causes it. I disconnect the backup capacitor, and now all seems okay. So maybe it was the backup capacitor.

I put the network card back in, start the server once again and all seems well. I boot the ESXi host and let VMs slowly start back up. However, we’re not done yet!

VMware suddenly gives a purple screen of death, as you can see in this screenshot:

I thought it was a one-time thing. (in a production environment, you should not do this! Immediately investigate why the crash occurred!). I restart the server and try agan. This time, it crashes, once again. When I look at the logs through the debugger, I see that nothing really is showing, other than slow response times.

I shut the server back down and take out the controller. The heatsink feels quite warm. I press on it a little bit to make sure that it’s still secured in place, and check the SAS connectors to make sure that they are seated in properly with no dust in them. I turn the server back on, however, now it’s taking off again. Showing 113 C on the sensor.

By accident while taking out the riser card, I touch the heatsink of my RAID controller and burn my hand. So the problem is definitely not fixed yet, and properly the controller crashed because of overheating.

I removed the controller and put the SAS cables in the on-board P410i controller. Temperatures are normal and the server has been running for a bit over a day without crashing.

Ultimately, it looks like my P420 controller has died. I should still have warranty on it from the company I bought it from, so I’m going to try to RMA it. Hopefully that will be possible.

Thank you for reading, if you have any questions feel free to contact me on my website or Twitter and I hope you learned something.

Have a great day