Magic Unicorn – PowerShell Downgrade Attack and Exploitation tool

Magic Unicorn is a simple tool for using a PowerShell downgrade attack and injects shellcode straight into memory. Based on Matthew Graeber’s powershell attacks and the powershell bypass technique presented by David Kennedy (TrustedSec) and Josh Kelly at Defcon 18.

Table of Content

  • Powershell Attack Instruction
  • HTA Attack Instruction
  • Macro Attack Instruction

 Download the unicorn from git repository:

Once downloaded, go in the directory and run unicorn with the following command to see all the possible methods.


Powershell Attack Instructions

First we will try the reverse_tcp payload. As we can see in the main menu all the commands are already written. We just need to replace the IP with our IP.


Now this will give us two files. One is a text file named “powershell_attack.txt” which has the powershell code that will be run in the victim’s machine using social engineering and the other is “unicorn.rc” which is a custom metasploit file that will automatically set all the parameters and start a listener.

These files will be saved in the directory where unicorn was cloned. Powershell_attack.txt holds the malicious code and when the victim will execute that code in his command prompt, the attacker will get reverse connection of his machine.

Now let’s set up a listener first. We need to run the metasploit “unicorn.rc” file using the following command:

We see a session was obtained in the meterpreter. It was because the powershell code was executed in the victim’s command shell. It would have looked something like this:

HTA Attack Instructions

For our next attack, we will be using an hta payload.

Now convert your IP in bitly URL form and send to victim and then wait for the user to click on the “launcher.hta” file which could be done using social engineering easily.

So, we set up a metasploit listener next using the RC file and wait for user to click on the hta payload.

As soon as he hit the file, we received a meterpreter session. We checked the system info using sysinfo command.


Macro Attack Instructions

Now for the third and final payload for this tutorial, we set hands on our beloved macros.


This again creates a text file and an rc file with the same name and on the same destination.

To enable developed mode there are various methods depending upon your version of MS office.

As for a generic approach, let’s say you enabled it like:

File->properties->ribbons->developer mode

You will see an extra tab labeled developer once it gets enabled.

As for the attack, go to developer->macros and create a new macro named “Auto_Open”

Simply paste the contents from “powershell_attack.txt” to this xlsx module and save it.

As soon as you click run (little green icon on the top), it will give you an error! Don’t worry! You want that error. It is supposed to happen.

Soon after the error on the user screen, we would have obtained a session successfully in meterpreter!

Use sysinfo double check our successful exploitation using unicorn!

Author: Harshit Rajpal is an InfoSec researcher and a left and right brain thinker. contact here

Comprehensive Guide to Dirb Tool

In this article, we are focusing on transient directory using Kali Linux tool DIRB and trying to find hidden files and directories within a web server.

A path traversal attack is also known as “directory traversal” aims to access files and directories that are stored outside the web root folder. By manipulating variables with reference files with “dot-dot-slash (…/)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code, configuration and critical system files.



Target- BWAPP Labs, DVWA Labs,

Attacker – Kali Linux

Table of content

  • Introduction to DIRB
  • Utilizing Multiple Wordlist for Directory Traversing
  • Default working of Dirb
  • Enumerating Directory with Specific Extension List
  • Save Output to Disk
  • Ignore Unnecessary Status-Code
  • Default Working Vs Not stop on WARNING messages Working
  • Speed delay
  • Not recursively (-r)
  • Show NOT Existence Pages
  • Extension List (-X parameter) Vs Extension Header (-H parameter)
  • Not forcing an ending ‘/’ on URLs (-t)
  • HTTP Authentication (-u username: password)

What is DIRB?

DIRB is a Web Content Scanner. It looks for existing (and/or hidden) Web Objects. It basically works by launching a dictionary-based attack against a web server and analyzing the response.

It comes with a set of preconfigured attack wordlists for easy usage but you can use your custom wordlists. Also, DIRB sometimes can be used as a classic CGI scanner, but remember is a content scanner not a vulnerability scanner.

The main purpose is to help in professional web application auditing. Especially in security related testing. It covers some holes not covered by classic web vulnerability scanners. DIRB looks for specific web objects that other generic CGI scanners can’t look for. It doesn’t search vulnerabilities nor does it look for web contents that can be vulnerable.


Tool DIRB is built in Kali Linux. Open the terminal and type the following command to get an overview of the tools included in the package:


 -a <agent_string> : Specify your custom USER_AGENT.
 -c <cookie_string> : Set a cookie for the HTTP request.
 -f : Fine tunning of NOT_FOUND (404) detection.
 -H <header_string> : Add a custom header to the HTTP request.
 -i : Use case-insensitive search.
 -l : Print “Location” header when found.
 -N <nf_code>: Ignore responses with this HTTP code.
 -o <output_file> : Save output to disk.
 -p <proxy[:port]> : Use this proxy. (Default port is 1080)
 -P <proxy_username:proxy_password> : Proxy Authentication.
 -r : Don’t search recursively.
 -R : Interactive recursion. (Asks for each directory)
 -S : Silent Mode. Don’t show tested words. (For dumb terminals)
 -t : Don’t force an ending ‘/’ on URLs.
 -u <username:password> : HTTP Authentication.
 -v : Show also NOT_FOUND pages.
 -w : Don’t stop on WARNING messages.
 -X <extensions> / -x <exts_file> : Append each word with this extensions.
 -z <milisecs> : Add a miliseconds delay to not cause excessive Flood.

Utilizing Multiple Wordlist for Directory Traversing

The above attack works by using the default wordlist_files common.txt, but we can change this word list and could select other wordlist for directory traversal. You must follow the following path to view all available wordlists.

You can see from the image below that there are so many text files as wordlist; we can use them as required.

Default working of Dirb

In this attack the common.txt is set as a default word list for directory traversal, the protester can use the following command. Open the terminal and type the following command to start the Brussels Directory attack.

Using the common.txt file, the DIRB returns the enumerated directories found within the target URL as shown in the below image.

Enumerating Directory with Specific Extension List

There are a lot of situations where we need to extract the directories of a specific extension over the target server, and then we can use the -X parameter of the dirb scan. This parameter accepts the file extension name and then searches the given extension files over the target server or machine.

The above command will extract all directory path related to php extension as shown the following image.

Save Output to Disk

For the purpose of the record maintenance, better readability and future references, we save the output of the dirb scan onto a file. To this we will use the parameter -o of the dirb scan we can save the output of the dirb scan in a text file.

The above command will generate an output.txt file at the desktop of the enumerated directories.

Now that we have successfully executed the command, now let’s traverse to the location to ensure whether the output has been saved on the file on not. In this case our location for output is /root/Desktop/output.txt.

Ignore Unnecessary Status-Code

The Status-Code element is a 3-digit integer where first digit of the Status-Code defines the class of response and the last two digits do not have any categorization role. In this attack we are using –N parameter on code 302 as shown below.

As you can grasp form the given screenshot that the dirb scan is ignoring the NOT FOUND code that is., 302.

Default Working Vs Not stop on WARNING messages Working

During the normal dirb scan as show below, some of the pages generate warnings; the dirb scan skips those directories where it encounters any warnings.

While doing a scan that is to be done very deeply and verbosely, we want that the dirb scan to not avoid these warnings and do an in-depth scan, hence we use the -w parameter of the dirb scan.

As you can observe the highlighted directory /dev/shell is enumerated even after warning message which is missing in the default scan.

Speed delay

While working in different scenarios, there are some environment we come across that cannot handle the flood created by the dirb scan, so in those environments it is important that we delay the scan for some time. This can be done easily with the -z parameter of the dirb scan. In this parameter, the time is provided on the scale of milliseconds. Like as shown in our given example, we have given 100 seconds delay to dirb.

Not recursively (-r)

The dirb scan, by default scans the directories recursively. It means it scans a directory and then traverses inside that directory to scan for more sub directories. But in some scenarios, where time is insufficient, we set the dirb to not scan recursive. This can be achieved using the -r parameter.

Show NOT Existence Pages

A 404 error is an HTTP status code that means that the page you were trying to reach on a website couldn’t be found on their server. 404 Not Found error messages are frequently customized by individual websites. In some scenarios we need to find the 404 pages too, which dirb skips by default. To find those pages we will use -v parameter.

From given below the image you can observe it has also extract all those directories are relevant to 404 errors.

Extension List (-X parameter) Vs Extension Header (-H parameter)

By using –X parameter along with target URL with a specific extension, for example .php, it enumerates all file or directory with .php extension, but by using –H parameter with specific extension, for example .php along with target URL it will enumerate all files or directories named with php as shown in the given below image.

Not forcing an ending ‘/’ on URLs (-t)

From the attacks used in the previous situations, in order to run the dirb tool we will have to add a forward slash (/) at the end of the URL to be accepted in dirb. In order to check that we need try one attack on url ending without any forward slash.

You will observe that the scan doesn’t get executed successfully because of the lack of the forward slash, the importance of which we discussed earlier in this article.

Try this attack once again with the same command with some changes so in order to run that command we have to add –t in the previous command.

As now we can observe that the even in the absence of the forward slash, we still have successfully executed the dirb scan.


HTTP AUTHORIZATION (-u username: password)

HTTP Authentication/Authentication mechanisms are all based on the use of 401-status code and WWW-Authenticate response header. The most widely used HTTP authentication mechanisms are Basic. The client sends the user name and password as unencrypted base64 encoded text.

So, in order to bypass this kind of authentication with the help of dirb we have used the command below:

As a result it is shown Status –code 200 for the test: test and authorized credential on target URL.

Author: Shubham Sharma is a Technical writer, Researcher and Penetration tester contact here

Hacking with Empire – PowerShell Post-Exploitation Agent

Hello everyone and welcome to this beginner’s guide to Empire. According to their official website:

“Empire is a pure PowerShell post-exploitation agent” built on cryptologically-secure communications and a flexible architecture.

Empire – PowerShell post-exploitation agent

Empire implements the ability to run PowerShell agents without needing powershell.exe, rapidly deployable post-exploitation modules ranging from key loggers to Mimikatz, and adaptable communications to evade network detection, all wrapped up in a usability-focused framework.”

In this tutorial we will be covering everything you need to know about this software, straight from installation to getting a shell and even getting admin access without letting the antivirus know!

Before starting with the action you need to know these four things:

Listener: listener is a process which listens for a connection from the machine we are attacking. This helps Empire send the loot back to the attacker’s computer.

Stager: A stager is a snippet of code that allows our malicious code to be run via the agent on the compromised host.

Agent: An agent is a program that maintains a connection between your computer and the compromised host.

Module: These are what execute our malicious commands, which can harvest credentials and escalate our privileges as mentioned above.


  1. Creating a listener.
  2. Starting a listener.
  3. Launching a PowerShell code using launcher.
  4. Executing code on victim’s machine.
  5. Interacting with agent.
  6. Executing various modules.
  7. Bypassing UAC to get admin access.

To get started, clone the following git repo using git clone:

Now move into the installed directory and run file.

Wait for it to complete installation. This might take a few seconds. It will prompt you for a password, enter anything.

In my case, my password was toor.

Once the installation is done, move back a directory and run empire using ./empire

Help command opens up all the essential options required initially.

As our methodology states, we will be creating a listener for our local machine first.

It will say that “no listeners are currently active” but don’t worry, we are into the listener interface now.

Creates a listener on the local port 80. If port 80 is already busy by a service like apache, please make sure you stop that service.

Note: Whenever you double click on tab, all the available options will appear, just like in all of Linux.

Hence, uselistener <tab><tab> shows me all the listenersand so on like that.

Above command will execute the listener. Then go back and use powsershell listener as shown in the below image.

All we have to do now is copy this powershell code into victim’s command prompt using social engineering. Let’s assume we have access of victim’s command prompt and we copied our code into his cmd.

As soon as you hit enter you will see an agent being active on your empire screen. After executing the malicious powershell code, go back again to the main menu with the command:

Here you will see 1 agent active.

You can also rename the agent’s name to a rather simple one using the rename command.

Now, to get an admin shell, run bypassuac command with help of following command.

List command can be used anywhere to see the list in current interface. Here it displayed a list of agents in agent’s interface.

Let’s rename the agent’s name to a rather simpler one, once again.

Now you can see that we got a new admin shell using bypassuac and we renamed it to adminraj

Let’s interact with adminraj now.

<tab><tab>helps us view all the options in the shell. There are several options which is quite helpful to for post exploitation. Such as info, job, list and etc as shown in the image.

Info: for all the basic details like IP, nonce, jitter, integrity etc.

Let’s try and run mimikatz to get the password of the user. Since, mimikatz won’t run on a normal guest user shell and will only run on admin shell; this also proves that we have to achieve admin access so that we can use mimikatz.

Hmmmm!! And the password is “123”for user raj.

Above command will dump the credentials or password of any user in both plaintext and its hash as well.

Another important command is the shell command.

To use the shell of the victim to run proper microsoft windows commands, we use this feature.

Eg: one such window’s cmd only command is netstat

As expected, it showed us all the ports in work currently on the machine!

 Now, since the default shell directory in windows is “C:/windows/system32”; let’s try and move into another directory and try to download some file from there and also we can upload something at that location, for example we can upload a backdoor.!

Above command will download an image called 6.png from the window’s desktop to the “downloads directory of Empire”

Here we can upload any backdoor, with help of above command we are uploading a php backdoor from Kali’s desktop to victim’s desktop and we can even invoke this file since we have the shell access!

This is where the downloaded files will go:

Above command proves that we indeed have uploaded revshell.php

And there it is! Revshell.php on the desktop of victim’s machine which our backdoor file.

Happy Hacking!!!

Author: Harshit Rajpal is an InfoSec researcher and a left and right brain thinker. contact here

Multiple Ways to Exploiting PUT Method

Hi Friends, today’s article is related to exploiting the HTTP PUT method vulnerability through various techniques. First we will determine if the HTTP PUT method is enabled on the target victim machine, post which we will utilize several different methods to upload a Meterpreter reverse shell on the target and compromise the same.

Table of Content 

  • Introduction to HTTP PUT Method
  • Scanning HTTP PUT Method (Nikto)
  • Exploiting PUT Method Using Cadaver
  • Exploiting PUT Method Using Nmap
  • Exploiting PUT Method Using Poster
  • Exploiting PUT Method Using Metasploit
  • Exploiting PUT Method Using Burpsuite
  • Exploiting PUT Method Using Curl

Introduction to HTTP PUT Method

PUT method was originally intended as one of the HTTP method used for file management operations. If the HTTP PUT method is enabled on the webserver it can be used to upload a malicious resource to the target server, such as a web shell , and execute it

As this method is used to change or delete the files from the target server’s file system , it often results in arise in various File upload vulnerabilities , leading the way for critical and dangerous attacks .As a best practice , the file access permissions of the organizations’ critical servers should be strictly limited with restricted access to authorized users, if in case the organization absolutely MUST have these methods enabled.

Note : In this tutorial we are using a Vulnerable target machine for Pentesting purposes and to illustrate the use of various tools . This is purely meant for educational purposes in the testing environment and should not be used in Production environment without the authorized permissions from the relevant authorities/management.


Target: Metasploitable 2

Attacker: Kali Linux machine

Let’s Begin!!!!

Boot your Kali Linux machine (IP : and in parallel, type victim IP as in the Firefox browser and click on WEBDAV. As we can see from the screenshot it is listing only the parent directory. 

First of all we need to ensure that the vulnerable target machine has the HTTP PUT method allowed for us to upload malicious backdoors.In order to confirm the same , we need to scan the target using Nikto .

Nikto is a popular Web server scanner that tests Web servers for dangerous files/CGIs, outdated server software and other issues. It also performs generic and server type specific checks.Below is the command to scan the URL:

Upon running the above command , we can observe that the highlighted part in below screenshot displays that HTTP PUT method is allowed. Now let’s hack the vulnerable target machine by uploading the PHP malicious file ,using the various techniques shown in upcoming sections.

Prepare the malicious file to be uploaded with msfvenom :

Msfvenom can be used to create PHP meterpreter payload that gives us a reverse shell. Execute the following command to perform the same

Copy the code from <?php to die() and save it in a file with .php extension as shell.php file , on the desktop .This will be utilized later in the upcoming sections , to upload the file on web server.

In parallel, load the metasploit framework by typing msfconsole on a new terminal and start multi/handler.This will be utilized in the later part of the section


Cadaver is a command line tool pre-installed in the Kali machine that enables the uploading and downloading of a file on webdav.

Type the target host URL to upload the malicious file , using the command given below.

Now once we are inside the victim’s directory, upload the file shell.php from the Desktop to the target machine’s path, by executing the below command :

To verify whether the file is uploaded or not, run the URL: on the browser. Awesome!!! As we can see , the malicious file shell.php has been uploaded on the web server.

Now, let’s launch Metasploit framework and start a handler using the exploit/multi/handler module. Assign the other values like the LHOST and LPORT values to the Kali machine’s IP and port to listen on , respectively. Once done, execute by running the command exploit to start listening for the incoming connections.

Press Enter and we will observe that the reverse TCP handler has been started on Kali IP

Now go back to the previously uploaded shell.php file and click on the same.Once run , we will get TCP reverse connection automatically on the meterpreter shell. Further run the sysinfo command on the meterpreter session to get machine OS / architecture details.



Nmap is an opensource port scanner and network exploitation tool.If PUT Method is enabled on any webserver, then we can also upload malicious file to a remote web server with the help of NMAP.Below is the command to configure the same . We must specify the filename and URL path with NSE arguments .In parallel , prepare the malicious file nmap.php to upload to target server.

As seen from the below screenshot , nmap.php file has been uploaded successfully.

Type the same URL in browser and execute the same. As evident from the screenshot , the file nmap.php has been uploaded on the web server.

Simultaneously, open metasploit MSF console and use multi/handler; then go back to previously uploaded nmap.php file and run it. As can be seen below, this will give us a meterpreter session.


Poster is a Firefox Add-on and a developer tool for interacting with web services to let the end user trigger the HTTP requests with parameters like: GET, POST, PUT and DELETE and also enables to set the entity body, and content type

Prepare the malicious file poster.php that you would like to upload to the target machine. Install the Poster plug-in from Firefox Add-on. Click on the tools from the menu bar. And then click on Poster from the dropdown menu. A following dialog box will open. Type the URL as mentioned in the screenshot and provide the path of the malicious file to be uploaded via Browse option and finally click on PUT action.

Type the same URL in browser and execute the same. As evident from the screenshot , the file poster.php has been uploaded on the web server.

Simultaneously, open metasploit MSF console and use multi/handler; then go back to previously uploaded poster.php file and run it. This will give us a meterpreter session.


Burpsuite is one of the most popular proxy interception tool whose graphical interface can be effectively utilized to analyze all kind of GET and POST requests.

Configure the manual proxy settings of end users’ browser so as to intercept the GET request Browse the URL but don’t hit ENTER yet . In parallel , let us navigate to the Burpsuite Proxy tab and click Intercept is on option under the Intercept sub-option , to capture the request. As soon we hit ENTER in the users’ browser , we will be able to fetch the data under the intercept window.

Now right click on the same window and a list of multiple options will get displayed. Further click on Send to repeater.


In the below highlighted screenshot , we will observe two panels – left and right for the HTTP Request and HTTP Response respectively . The GET method can be observed in the HTTP request and we will now replace GET with the PUT method in order to upload the file with name burp.php comprising of malicious content/code.

Type PUT /dav/burp.php HTTP/1.1 in the header and then paste the php malicious code starting from <?php to die() at the end of the request, as shown below .This will upload the burp.php file under the dav directory through PUT request.

Verify and confirm the file upload by browsing the same URL in the end users’ browser and we can see burp.php file has been uploaded in the /dav directory of the web server.

Simultaneously, open metasploit MSF console and use multi/handler; then go back to previously uploaded burp.php file and run it. This will give us a meterpreter session.


Metasploit Framework is a well known platform for developing, testing, and executing exploits. It is an open source tool for performing various exploits against the target machines. This module can abuse misconfigured web servers to upload and delete web content via PUT and DELETE HTTP requests. Set ACTION to either PUT or DELETE. PUT is the default.

Metasploit has in-built auxiliary modules dedicated to scan HTTP methods and gives us the ability to PUT a file with auxiliary/scanner/http/http_put.Below are the commands to accomplish same

Type the same URL in browser and execute the same. As evident from the screenshot , the file meter.php has been uploaded on the web server.


Simultaneously, open metasploit MSF console and use multi/handler; then go back to previously uploaded meter.php file and run it. This will give us a meterpreter session.


cURL is a well-known command line tool to send or receive the data using the URL syntax and is compatible with various well-known protocols (HTTPS, FTP, SCP, LDAP, Telnet etc.)

To exploit PUT method with cURL, the command is:

Type the same URL in browser and execute the same. As evident from the screenshot , the file curl.php has been uploaded on the web server.


Simultaneously, open metasploit MSF console and use multi/handler; then go back to previously uploaded curl.php file and run it. This will give us a meterpreter session.

Author: Ankur Sachdev is Information Security consultant and researcher in the field of Network & WebApp Penetration Testing . Contact Here

Related Posts Plugin for WordPress, Blogger...