USB Rubber Ducky — a device which resembles a regular USB flash drive. When connected to a computer, it claims to be a keyboard and quickly enters all its commands. It’s a pretty cool thing and very useful for Pentests, but why pay 40 dollars or more if a regular USB flash drive can be taught the same tricks?
WARNING
Introduction
Last year’s Black Hat was full of many interesting reports. One of the most discussed was a report on the fatal vulnerability of USB devices, which allows regular USB flash drives to be turned into a tool for spreading malware. The attack was called BadUSB, but later jokes appeared on the Internet referring to USBola, comparing this attack to the well-known virus.
Similar ideas for using HID devices for malicious purposes have been around for a while. It’s a sin not to use the fact that the OS trusts devices connected to a USB interface. If we search the magazine’s archives, we can find an article on a similar topic describing the technique of using a special Teensy device to control a PC running Windows 7 (actually, with any OS). The device disguised itself as a regular USB flash drive. All this suggested that the same trick could also be played with flash drives.
Essentials
A USB is a truly all inclusive connection point. Simply think the number of gadgets we interface it to and the number of gadgets it works with! Mouses, consoles, printers, scanners, gamepads, modems, passages, web cameras, phones, and so forth. Automatically, we plug the USB into the attachment and the OS consequently decides the kind of gadget and load the necessary drivers.
However, how can it make it happen?
How flash drives work
In fact, the OS knows nothing about the connected device. It has to wait until the device tells it what kind it is. Let’s consider a simple example. When we plug a USB flash drive into a USB socket, the flash drive informs the operating system of its type and volume. It is worth remembering our shrewd Chinese colleagues, who learned how to produce higher capacity flash drives (some almost 2 TB). To figure out how this is possible, let’s remember (or learn) how the OS recognizes USB devices.
Bad USB or some history
At the last year’s Black Hat conference, two researchers (Karsten Nohl and Jakob Lell) shared their experience on how to install a personal upgrade to the firmware of the USB flash drive controller. After a while, this USB flash drive was registered as a keyboard and entered the selected commands. Due to the serious nature of the problem, the guys decided not to make the code for this available. However, soon after, two other researchers (Adam Caudill and Brandon Wilson) presented to the whole world at Derbycon conference an operable PoC tailored to Phison 2251-03 microcontroller The code is available at GitHub.
Transformation
As you might have guessed, today we will try to turn a regular USB flash drive into a pentester’s secret weapon!
First of all, we will need a suitable device. As the code has been uploaded for the specific microcontroller only, we have two options — either find a USB flash drive managed by this controller, or perform some very challenging work researching and upgrading the firmware of another microcontroller. This time, we will select an easier way and try to find a suitable USB flash drive (here is the list of vulnerable equipment). The controller is quite popular, so, miraculously, I found a suitable USB flash drive among the dozen I have at home.
Starting the magic
Having found the suitable device (which we won’t miss if it fails), we can start its transformation. First of all, we need to download the sources which the guys made available. Actually, the content is described in detail on their official wiki page, but, just in case, I will remind you what they have uploaded to GitHub:
- DriveCom — an app for communicating with Phison USB flash drives;
- EmbedPayload — an app for embedding Rubber Ducky inject.bin key scripts into custom firmware for subsequent execution when the USB flash drive is connected;
- Injector — an app that extracts addresses from the firmware and embeds the patching code in the firmware;
- firmware — custom 8051 firmware written in C;
- patch — collection of 8051 patches written in C.
INFO
Preparing the system
Getting the burner image
- 2KM — for 2K NAND chips;
- 4KM — for 4K NAND chips;
- M — for 8K NAND chips.
Dumping the original firmware
Preparing the payload
- you can write the required script yourself, as the used syntax is easy to master (see the project’s official website);
- use finished ones uploaded to GitHub. As they have a reverse shell and other goodies — you will only have to make minor corrections and convert them into binary form;
- or use the above-mentioned website, which will lead you step-by-step through all the settings and will let you download the finished script in the form of a Ducky script (or already in converted binary form).
- To convert the script into binary, execute the following command:
No comments:
Post a Comment