未加星标

Vulnhub Machines Walkthrough Series ― PwnLab-Init

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二03 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

Continuing with our series on Vulnhub machines, in this article we will see a walkthrough of another interesting Vulnhub machine called PwnLab-Init.

Note: For all these machines, I have used a VMware workstation to provision VMs. Kali linux VM will be my attacking box. Also, the techniques used are solely for educational purposes; I am not responsible if the listed techniques are used against any other targets.

PwnLab-Init Walkthrough

Download

VM Details

Description: Wellcome to “PwnLab: init”, my first Boot2Root virtual machine. Meant to be easy, I hope you enjoy it and maybe learn something. The purpose of this CTF is to get root and read de flag.

About: Difficulty: Low Flag: /root/flag.txt Format: Virtual Machine (Virtualbox OVA) Operating System: Debian DHCP service: Enabled IP address: Automatically assign Walkthrough
Download the VM from above link and provision it as a VM.

Let’s start with enumeration. First, we need to identify the IP of this machine. Let’s use netdiscover to identify it. Below, we can see netdiscover in action. The IP of the victim machine is 192.168.213.135.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Now that we know the IP, let’ start with enumeration. We will use nmap to enumerate the host.


Vulnhub Machines Walkthrough Series ― PwnLab-Init
We can see that port 80, 111 and 3306,34579 came after initial enumeration. As done earlier in this series, as soon as we found port 80 we will start exploring what is there and start looking for quick wins before enumerating the service more.

Browsing the machine at port 80 gives us the following page.


Vulnhub Machines Walkthrough Series ― PwnLab-Init
We can see Home, Login and Upload. What more can we expect to see on the home page? Links to login and upload. Without even opening any links, techniques such as SQL injection and shell upload start hovering in my brain. However, my joy was short-lived: I tried several vectors for sql injection on the login page, but to no avail. Also, the upload page is protected by login.

This point of time, I usually start nikto, and I did the same in this case as well. Below we can see some interesting findings from nikto.


Vulnhub Machines Walkthrough Series ― PwnLab-Init
Nikto reveals login.php and more importantly config.php, which may contain database IDs and passwords.

I tried to exploit ?page= with some basic LFIs but failed. After some more research, came across this gem , which talks about using aphp wrapper like php:input, which will supply all the data right after the header in a post request. In this case, the wrapper used in php:filter retrieved the contents of a file stored on server.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

As we can see that the output is base64-encoded, decoding it gives us following credentials.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Remotely connecting with the obtained creds gives us the following login info from the users table.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Logging with one of the base64 decoded password for the users, we able to successfully log into the application.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Directly uploading the file (shell) results in an error like below:


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Looking into the code for upload.php reveals following restrictions:


Vulnhub Machines Walkthrough Series ― PwnLab-Init
There is a whitelist defined for files with the extensions jpg, jpeg, gif and png. Following the whitelist defined above, the code also defines the accepted mime types. If no match, we will get Error 2 (which we got above). Also, the file cannot have multiple extensions. The above restrictions look like enough, but there is a simple bypass. Rename the PHP shell to an image type defined above and add keywords or magic bytes that correspond to an image, so that server accepts and uploads it.

Uploading the file like above results in a successfully-disguised PHP shell uploaded.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

And in this location:


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Now that we have the code uploaded, we need a way to execute the code. While looking into the code of the index, it can be seen that the LANG parameter can be used for this purpose.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Intercepting the request via Burp, let’s insert the uploaded path inside the LANG parameter as shown below:


Vulnhub Machines Walkthrough Series ― PwnLab-Init

On the other side, we have our beloved listener waiting for a shell. As soon as the request is released from burp, we got a shell back. BOOOOM!


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Quickly looking to www-data directory does not reveal anything interesting, and utilizing the creds of different users to explore.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Ethical Hacking Training Resources (InfoSec)

Nothing interesting in kent, so moving onto the next user kane as shown below


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Look at that there is some message for mike in the kane directory.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Executing it, it looks like it just displays the contents using cat, which does not have a fully-qualified. We’re modifying its contents with /bin/shand, altering the PATH to find ‘cat’ in the current PATH first. As soon as we ran it … BOOM! We are mike now.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Hovering into the mike directory, we can see that there is a message for root.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

Executing msg2root, it looks like it needs input from user. Thinking of command injection … Yeah. Let’s add ;/bin/sh and then Root Dance.


Vulnhub Machines Walkthrough Series ― PwnLab-Init

We’ve got the flag!

So that was PwnLab-Init. Some interesting techniques, like finding a way to execute our uploaded shell, altering PATH of known binaries and then command injection. We will continue this series with other interesting Vulnhub VMs.

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: PHPSQLDebianLinuxDHCDHCP
tags: see
分页:12
转载请注明
本文标题:Vulnhub Machines Walkthrough Series ― PwnLab-Init
本站链接:https://www.codesec.net/view/578915.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(43)