banner
soapffz

soapffz

github
steam
bilibili
douban

Introduction to HID Attacks - Creating Teensy ++ 2.0 BadUSB using Arduino

Introduction to Basic Knowledge#

  • BadUSB: Stealing your information, damaging your computer, basically being very bad;
  • HID: Human Interface Devices, such as keyboards and mice, are HID devices.
  • Benefits of HID attacks: Can disguise as a peripheral device to evade antivirus software detection, and can be pre-made for automation.
  • Teensy++ 2.0: A very small and fully functional single-chip development system.
  • Arduino: A convenient, flexible, and easy-to-use open-source electronic prototyping platform (allows you to write code for operations executed after USB insertion).

Material Preparation#

A Teensy ++ 2.0 board:#

Search for "teensy" on Taobao, make sure to buy one with the "++2.0" label, I bought it for 32.1RMB.

  • There seem to be better boards, why not buy a Rubber Ducky or Teensy 3.6? Because I'm poor Of course, it's best to start with something cheap for beginners.

Real-life photo:

image

Arduino#

Download link: https://www.arduino.cc/en/Main/Software?setlang=cn

I downloaded the Windows zip version here:

image

Extract it to the D drive, rename it to "arduino", open arduino.exe, and the initial state is an empty template:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

These two functions need to be added to all programs written later, even if one of the functions is empty. Let's take a look at the toolbar first:

image

Teensyduino Plugin#

If not installed, it does not support Teensy development boards. Download link: http://www.pjrc.com/teensy/td_download.html

After downloading, install it by clicking "Next" all the way until you reach the directory selection. Choose the directory where Arduino was installed previously, I put it in D:\arduino:

image

Click "Next" directly:

image

Then click "Install". After installation, let's take a look at the toolbar:

image

At this point, Teensy development boards are already supported, and a few more options such as "USB Type" are available. Choose our development board as "Teensy++ 2.0":

image

Choose the only available port:

image

Then click "Get Board Info":

image

Before compiling the program, you should check if the configuration is like this:

image

Introduction to Arduino Basic Syntax and Functions#

Common keyboard functions:

#include //Include the header file for the keyboard module

Keyboard.begin(); //Start keyboard communication

Keyboard.press(); //Press a key

Keyboard.release(); //Release a key

Keyboard.println(); //Input characters

Keyboard.end(); //End keyboard communication

Always release after pressing.

Common statements:

delay(500); //Delay for 500ms

Keyboard.press(KEY_CAPS_LOCK); //Press the Caps Lock key

Keyboard.press(KEY_LEFT_GUI); //Press the left Windows key

Keyboard.press(KEY_RETURN); //Press Enter

First Program#

The first program is, of course, "Hello World!"

Plug in the Teensy, open Arduino, develop a good habit, save it on the desktop with Ctrl+S, let's call it "demo", and then write the following code:

void setup() {
  delay(500);
  Keyboard.begin();
  delay(1000);
  Keyboard.press(KEY_LEFT_GUI);
  delay(500);
  Keyboard.press('r');
  delay(500);
  Keyboard.release(KEY_LEFT_GUI);
  Keyboard.release('r');
  delay(500);
  Keyboard.println("cmd");
  Keyboard.press(KEY_RETURN);
  Keyboard.release(KEY_RETURN);
  delay(500);
  Keyboard.print("you are hacked by soapffz");
  delay(500);
}
void loop() {}

After confirming that the toolbar is set up as shown above, click the checkmark in the upper left corner. After the compilation is completed, it will prompt "Compilation successful" and output storage space information below, and a Teensy default debug program will pop up:

image

We don't need this little program that pops up, click the right arrow next to the checkmark to upload the program to the development board. After the upload is successful, the development board will automatically reconnect and output the effect you designed in advance:

https://img.soapffz.com/archives_video/2018/12/18/archives_20181219_122003.mp4

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.