{"id":702,"date":"2019-12-14T15:46:15","date_gmt":"2019-12-14T15:46:15","guid":{"rendered":"http:\/\/zerothcode.com\/blog\/?p=702"},"modified":"2019-12-14T15:46:15","modified_gmt":"2019-12-14T15:46:15","slug":"node-1-ctf-walkthrough","status":"publish","type":"post","link":"https:\/\/zerothcode.com\/blog\/node-1-ctf-walkthrough\/","title":{"rendered":"Node 1: CTF Walkthrough"},"content":{"rendered":"<h4>Node 1: CTF Walkthrough<\/h4>\n<p>In this article, we will learn to solve a Capture the Flag (CTF) challenge which was posted on VulnHub by Rob. According to the information given in the description by the author of the challenge, this CTF is a medium-level boot-to-root challenge in which you need to capture two flags. The first flag needs to be captured as a user and the second flag needs to be captured as a root user.<\/p>\n<p>You can download the VM for Virtual Box\u00a0<a href=\"https:\/\/download.vulnhub.com\/node\/Node.ova\">here<\/a>. The torrent downloadable URL is also available for this VM, which is given in the reference section at the end of this article. Since the size of the Virtual Machine is more than 1 GB, I would recommend using the torrent for downloading the virtual machine.<\/p>\n<p>For those who are new to CTF challenges and are not aware of this platform, VulnHub is a well-known website for security researchers which provides users with a method to learn and practice their hacking skills through a series of challenges in a safe and legal environment.<\/p>\n<p><strong>Please Note:<\/strong>\u00a0For all of these machines, I have used Oracle Virtual Box to run the downloaded machine. I will be using Kali Linux as the attacker machine for solving this CTF. The techniques used are solely for educational purposes only, and I am not responsible if the listed techniques are used against any other targets.<\/p>\n<h2>The Walkthrough<\/h2>\n<p>After downloading and running this machine in Virtual Box, we started by running the Netdiscover command to obtain the IP Address of the target machine. The command and its output can be seen in the screenshot given below:<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/1-199.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48509 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48509\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/1-199.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/1-199.png 1030w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/1-199-300x75.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/1-199-768x192.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/1-199-1024x256.png 1024w\" alt=\"\" width=\"550\" height=\"138\" \/><\/a><\/p>\n<p>Command Used: netdiscover<\/p>\n<p>As shown in the highlighted area in the above screenshot, we have obtained the Virtual Machine IP address, 192.168.1.19 (the target machine IP address). We will be using 192.168.1.11 as the attacker&#8217;s IP address.<\/p>\n<p><strong>Please Note:<\/strong>\u00a0The target and the attacker machine IP address may be different depending on the network configuration.<\/p>\n<p>So, as we have the target machine IP, the first step is to find the ports and services that are available on the target machine. An Nmap full port scan is used for this purpose. This is illustrated in the screenshot given below.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/2-171.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48510 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48510\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/2-171.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/2-171.png 1093w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/2-171-300x69.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/2-171-768x176.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/2-171-1024x234.png 1024w\" alt=\"\" width=\"550\" height=\"126\" \/><\/a><\/p>\n<p>Command Used: nmap 192.168.1.19 -p- -Pn -sV<\/p>\n<ul>\n<li>-p-\u00a0(Used to complete the port scan)<\/li>\n<li>-Pn\u00a0(Used to treat all hosts as if they\u2019re online, skipping host discovery)<\/li>\n<li>-sV\u00a0(This is used to scan in verbose mode)<\/li>\n<\/ul>\n<p>After the completion of the scan, we found two open ports on the target machine. SSH service was available on port 22, and the HTTP server was available on port 3000.<\/p>\n<p>Let\u2019s start with the HTTP port. I quickly opened the target machine IP on the browser. A web application was running through this port which can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/3-135-1.jpg\" target=\"_blank\" rel=\"attachment noopener wp-att-48511 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48511\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/3-135-1.jpg\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/3-135-1.jpg 891w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/3-135-300x225.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/3-135-768x575.png 768w\" alt=\"\" width=\"550\" height=\"412\" \/><\/a><\/p>\n<p>As you can see, there is a login button on the homepage but no registration page on the application. I opened the login page and tried some default usernames and passwords but could not find any valid credentials. After that, I thought it might be possible that the login page was vulnerable for SQL Injection which could allow me to login, so I tested the login parameters for SQL Injection. Unfortunately, it was not vulnerable.<\/p>\n<p>As I could not find any further entry point from here, I decided to run Dirb on the target machine to find other files\/folders in the application. However, it could not enumerate any information which could be explored further. The Dirb screenshot can be seen in the screenshot given below.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/4-98.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48512 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48512\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/4-98.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/4-98.png 866w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/4-98-300x179.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/4-98-768x458.png 768w\" alt=\"\" width=\"550\" height=\"328\" \/><\/a><\/p>\n<p>After that, I decided to manually analyze the HTML content of the application for any clue. First, I checked the HTML content of the index page and found some JavaScripts, which can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/5-86.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48513 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48513\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/5-86.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/5-86.png 959w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/5-86-300x208.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/5-86-768x532.png 768w\" alt=\"\" width=\"550\" height=\"381\" \/><\/a><\/p>\n<p>In the highlighted area of the above screenshot, we can see some JavaScripts. Sometimes developers write the internal URL of the application in the JavaScripts for client-side validations and operations, so I checked all the JavaScripts manually and found an internal URL:<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/6-52.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48514 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48514\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/6-52.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/6-52.png 877w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/6-52-300x102.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/6-52-768x262.png 768w\" alt=\"\" width=\"550\" height=\"188\" \/><\/a><\/p>\n<p>In the above screenshot, we can see an internal URL in the \u201chome.js\u201d file. Let\u2019s open this URL in the browser.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/7-49.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48515 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48515\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/7-49.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/7-49.png 1048w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/7-49-300x183.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/7-49-768x470.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/7-49-1024x626.png 1024w\" alt=\"\" width=\"550\" height=\"336\" \/><\/a><\/p>\n<p>As you can see, we have hit the jackpot this time! We can see some username and password hashes on the identified URL, but all of them are normal users because is_admin is showing false.<\/p>\n<p>Now let\u2019s try to crack these password hashes. For that I used the online password cracker website Crack Station. It was quite easy to use: We just need to enter all the hashes on the website and click on the Crack button. If there is a weak password used by the user, it will be cracked by the website.<\/p>\n<p>We got two users\u2019 clean text passwords cracked by the website. You can see it in the screenshot given below.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/8-34.jpg\" target=\"_blank\" rel=\"attachment noopener wp-att-48516 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48516\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/8-34.jpg\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/8-34.jpg 1240w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/8-34-300x165.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/8-34-768x423.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/8-34-1024x564.png 1024w\" alt=\"\" width=\"550\" height=\"303\" \/><\/a><\/p>\n<p>In the green section, we can see the passwords cracked by the website. I have listed all the identified usernames and cracked passwords in a table below.<\/p>\n<table class=\"tableizer-table\">\n<thead>\n<tr class=\"tableizer-firstrow\">\n<th>User Name<\/th>\n<th>Password<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Tom<\/td>\n<td>spongebob<\/td>\n<\/tr>\n<tr>\n<td>Mark<\/td>\n<td>snowflake<\/td>\n<\/tr>\n<tr>\n<td>Restating<\/td>\n<td>\u2013<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As we have identified some usernames and passwords, let\u2019s give them a try. First, we\u2019ll try logging in as user \u201ctom.\u201d<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/9-31.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48517 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48517\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/9-31.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/9-31.png 1164w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/9-31-300x166.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/9-31-768x425.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/9-31-1024x567.png 1024w\" alt=\"\" width=\"550\" height=\"304\" \/><\/a><\/p>\n<p>As you can see, we have successfully logged into the application as Tom, but no functionality is available for this user. However, there is a message which states that only admin users currently have access to the control panel. And as we already know that all the identified users do not belong to admin role, it\u2019s clear that we need an admin account to access the full functionality.<\/p>\n<p>After analyzing and enumerating all of the URLs, I found another username which belongs to an admin user. It can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/10-26.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48518 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48518\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/10-26.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/10-26.png 865w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/10-26-300x218.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/10-26-768x558.png 768w\" alt=\"\" width=\"550\" height=\"400\" \/><\/a><\/p>\n<p>In the highlighted area above, we can see the newly-identified user who is actually the admin user. Let\u2019s try to crack this password to log into the application.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/11-24-1.jpg\" target=\"_blank\" rel=\"attachment noopener wp-att-48519 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48519\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/11-24-1.jpg\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/11-24-1.jpg 1227w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/11-24-300x153.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/11-24-768x392.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/11-24-1024x522.png 1024w\" alt=\"\" width=\"550\" height=\"281\" \/><\/a><\/p>\n<p>We can see the cracked password in the above screenshot. So now let\u2019s add these credentials into the table. The updated table is given below.<\/p>\n<table class=\"tableizer-table\">\n<thead>\n<tr class=\"tableizer-firstrow\">\n<th>User Name<\/th>\n<th>Password<\/th>\n<th>Admin<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>tom<\/td>\n<td>spongebob<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>mark<\/td>\n<td>snowflake<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>rastating<\/td>\n<td>\u2013<\/td>\n<td>No<\/td>\n<\/tr>\n<tr>\n<td>myP14ceAdm1nAcc0uNT<\/td>\n<td>manchester<\/td>\n<td>Yes<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>As we now have the credentials of an admin user, let\u2019s try to log in with them.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/12-22.png\" rel=\"attachment wp-att-48520\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48520\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/12-22.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/12-22.png 1035w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/12-22-300x182.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/12-22-768x465.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/12-22-1024x620.png 1024w\" alt=\"\" width=\"550\" height=\"333\" \/><\/a><\/p>\n<p>In the above screenshot, we can see that we have logged into the application with admin privileges. After authenticating into the application with the admin user, we find an option to download the \u201cbackup\u201d on the dashboard. So let\u2019s click on the \u201cdownload backup\u201d button to download the backup.<\/p>\n<p>After downloading the backup, I opened it with a text editor. It didn\u2019t make any sense to me initially, but after checking the complete file, it seemed to be a base-64 encoded file. I decoded the complete file, which can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/13-18.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48521 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48521\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/13-18.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/13-18.png 807w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/13-18-300x70.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/13-18-768x179.png 768w\" alt=\"\" width=\"550\" height=\"128\" \/><\/a><\/p>\n<p>Command Used:<\/p>\n<ul>\n<li><em>cat myplace.backup | base64 -d &gt; myplace<\/em>\u00a0(It will decode the myplace.backup file and store the decoded data into another file named myplace)<\/li>\n<li><em>file myplace<\/em>\u00a0(It will identify the format of the file)<\/li>\n<\/ul>\n<p>In the above screenshot, you can see that we first used base-64 decoding to decode the file, and then used the \u201cfile\u201d command to check the format of the file. The output of the file command tells us that the decoded file is a zip archive data. So I renamed the file with a .zip extension and used the zip utility to extract the data from the file. It can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/14-17.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48522 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48522\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/14-17.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/14-17.png 777w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/14-17-300x47.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/14-17-768x121.png 768w\" alt=\"\" width=\"550\" height=\"86\" \/><\/a><\/p>\n<p>Commands Used:<\/p>\n<ul>\n<li>mv myplace myplace.zip\u00a0(Used to rename the file)<\/li>\n<li>unzip myplace.zip\u00a0(Used to unzip the compressed file)<\/li>\n<\/ul>\n<p>Here, we faced another hurdle to pass before we can read the file: The compressed file was password-protected. We have already cracked a few password hashes, so I tried all the passwords, but none of them worked.<\/p>\n<p>Since most of the identified hashes have been cracked, it gives me some confidence that the target application users don\u2019t know about the complex passwords. So a dictionary-based brute-force attack would be a good idea to identify the password of the compressed file.<\/p>\n<p>I used the fcrackzip tool for this purpose, which is available by default in Kali Linux. It can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/15-18.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48523 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48523\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/15-18.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/15-18.png 1294w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/15-18-300x39.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/15-18-768x100.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/15-18-1024x133.png 1024w\" alt=\"\" width=\"550\" height=\"71\" \/><\/a><\/p>\n<p>Command Used: fcrackzip \u2013dictionary \u2013use-unzip \u2013init-password \/usr\/share\/wordlists\/rockyou.txt \/tmp\/myplace.zip<\/p>\n<p>As can be seen in the above screenshot, the brute-force attack was successful, and we have retrieved the password of the compressed file. Now let\u2019s extract the compressed file content by using this password. It can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/16-16.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48524 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48524\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/16-16.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/16-16.png 755w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/16-16-300x186.png 300w\" alt=\"\" width=\"550\" height=\"340\" \/><\/a><\/p>\n<p>Command Used:<\/p>\n<ul>\n<li>unzip myplace.zip\u00a0(This command is used to extract the zip files)<\/li>\n<li>Password: magicword\u00a0(This is the compressed password)<\/li>\n<\/ul>\n<p>As you can see, we are able to extract the compressed file. The extracted files can be seen below.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/17-15.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48525 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48525\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/17-15.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/17-15.png 699w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/17-15-300x89.png 300w\" alt=\"\" width=\"550\" height=\"163\" \/><\/a><\/p>\n<p>This is the complete source code of the target application! We can do code analysis on the source code for further clues.<\/p>\n<p>First, I checked the app.js file and found a MongoDB connection string which can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/18-10.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48526 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48526\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/18-10.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/18-10.png 1325w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/18-10-300x98.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/18-10-768x250.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/18-10-1024x333.png 1024w\" alt=\"\" width=\"550\" height=\"179\" \/><\/a><\/p>\n<p>In the highlighted area in the above screenshot, we can see a connection string containing a username and password to connect on port 27017. However, this port is not publicly available. Since we know by the nmap scan that port 22 was found open other than the HTTP port, let\u2019s use this username and password on the SSH port. It can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/19-10.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48527 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48527\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/19-10.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/19-10.png 881w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/19-10-300x234.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/19-10-768x600.png 768w\" alt=\"\" width=\"550\" height=\"430\" \/><\/a><\/p>\n<p><strong>Username:<\/strong>\u00a0mark<br \/>\n<strong>Password:<\/strong>\u00a05AYRft73VtFpc84k<\/p>\n<p>We are able to log into the target machine as user \u201cmark.\u201d But the challenge is to take the root access of the target machine and find the flags. So let\u2019s enumerate the kernel and operating system of the target machine to find an exploit for privilege escalation.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/20-9.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48528 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48528\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/20-9.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/20-9.png 1146w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/20-9-300x36.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/20-9-768x93.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/20-9-1024x124.png 1024w\" alt=\"\" width=\"550\" height=\"67\" \/><\/a><\/p>\n<p>Command Used:<\/p>\n<ul>\n<li>uname -a\u00a0(Used to identify the kernel version)<\/li>\n<li>cat \/etc\/issue\u00a0(Used to identify the operating system version)<\/li>\n<\/ul>\n<p>Now we have the information of the running operating system and the kernel version, so let\u2019s search for an exploit on Google.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/21-7.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48529 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48529\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/21-7.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/21-7.png 803w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/21-7-300x165.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/21-7-768x423.png 768w\" alt=\"\" width=\"550\" height=\"303\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The very first Google result was an Exploit-DB website URL which shows that a local exploit is available for this version of the operating system. So I downloaded the exploit on the target machine by using the wget utility.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/22-8.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48530 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48530\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/22-8.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/22-8.png 1172w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/22-8-300x122.png 300w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/22-8-768x311.png 768w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/22-8-1024x415.png 1024w\" alt=\"\" width=\"550\" height=\"223\" \/><\/a><\/p>\n<p><span class=\"pardot-title\">ETHICAL HACKING BOOT CAMP \u2014 EXAM PASS GUARANTEE<\/span><\/p>\n<p>Command Used:<\/p>\n<ul>\n<li>wget\u00a0<a href=\"https:\/\/www.exploit-db.com\/download\/44298.c\">https:\/\/www.exploit-db.com\/download\/44298.c<\/a>\u00a0(Used to download the exploit)<\/li>\n<li>gcc 44298.c -o exploit\u00a0(Used to compile the downloaded exploit)<\/li>\n<\/ul>\n<p>User \u201cMark\u201d did not have write permission in the home directory, so I changed the current directory to \u201ctmp\u201d and used the wget utility to download the exploit on the target machine. Once the exploit has been downloaded, I used the GCC complier to compile the exploit; after the compilation, it generated an executable which can be seen in the above screenshot.<\/p>\n<p>After that, I gave the executable permission to the compiled code and then ran it:<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/23-8.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48531 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48531\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/23-8.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/23-8.png 622w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/23-8-300x145.png 300w\" alt=\"\" width=\"550\" height=\"265\" \/><\/a><\/p>\n<p>You can see that the exploit was successfully executed, and we got the root access of the target machine! As per the description given by the author of the CTF, we also need to capture two flags to complete the challenge.<\/p>\n<p>So I started to hunt for the flags. After some time I found the \u201croot\u201d flag in the root directory. Another flag was found in the \u201ctom\u201d user\u2019s home directory. Both flags can be seen in the following screenshot.<\/p>\n<p><a href=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/24-4.png\" target=\"_blank\" rel=\"attachment noopener wp-att-48532 noreferrer\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-48532\" src=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/24-4.png\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" srcset=\"https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/24-4.png 629w, https:\/\/mk0resourcesinfm536w.kinstacdn.com\/wp-content\/uploads\/24-4-300x152.png 300w\" alt=\"\" width=\"550\" height=\"279\" \/><\/a><\/p>\n<p>We did it!<\/p>\n<p>This completes the challenge. I hope you enjoyed playing with this machine. Watch this space for more VulnHub pentesting challenges!<\/p>\n<p>&nbsp;<\/p>\n<h3>Sources<\/h3>\n<p><a href=\"https:\/\/www.exploit-db.com\/exploits\/44298\/\">Linux Kernel &lt;4.4.0-116 (Ubuntu 16.04.4) \u2013 Local Privilege Escalation<\/a>, Exploit Database<br \/>\n<a href=\"http:\/\/crackstation.net\/\">Crackstation<\/a><br \/>\n<a href=\"https:\/\/www.vulnhub.com\/entry\/node-1,252\/\">Node: 1<\/a>, VulnHub<br \/>\n<a href=\"https:\/\/download.vulnhub.com\/node\/Node.ova\">Download Node: 1<\/a>, VulnHub<br \/>\n<a href=\"https:\/\/download.vulnhub.com\/node\/Node.ova.torrent\">Download Node: 1<\/a>, VulnHub (torrent)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Node 1: CTF Walkthrough In this article, we will learn to solve a Capture the Flag (CTF) challenge which was<\/p>\n","protected":false},"author":1,"featured_media":703,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[487],"tags":[],"yst_prominent_words":[686,680,688,676,687,691,559,692,689,693,677,679,684,683,685,681,682,675,678,690],"class_list":["post-702","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ctf"],"_links":{"self":[{"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/posts\/702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/comments?post=702"}],"version-history":[{"count":0,"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/posts\/702\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/media\/703"}],"wp:attachment":[{"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/media?parent=702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/categories?post=702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/tags?post=702"},{"taxonomy":"yst_prominent_words","embeddable":true,"href":"https:\/\/zerothcode.com\/blog\/wp-json\/wp\/v2\/yst_prominent_words?post=702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}