Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hak5
GitHub Repository: hak5/usbrubberducky-payloads
Path: blob/master/payloads/examples/Lock Keys/Lock-Keys-example2.txt
2968 views
1
REM Example SAVE and RESTORE of of the Keyboard Lock State
2
3
ATTACKMODE HID STORAGE
4
DELAY 2000
5
6
SAVE_HOST_KEYBOARD_LOCK_STATE
7
8
$_RANDOM_MIN = 1
9
$_RANDOM_MAX = 3
10
VAR $TIMER = 120
11
12
WHILE ($TIMER > 0)
13
VAR $A = $_RANDOM_INT
14
IF ($A == 1) THEN
15
CAPSLOCK
16
ELSE IF ($A == 2) THEN
17
NUMLOCK
18
ELSE IF ($A == 3) THEN
19
SCROLLLOCK
20
END_IF
21
DELAY 50
22
$TIMER = ($TIMER - 1)
23
END_WHILE
24
25
RESTORE_HOST_KEYBOARD_LOCK_STATE
26
27
28
29
REM At the beginning of the payload, the currently reported keyboard lock state are saved.
30
REM For about 6 seconds, as a while loop iterates 120 times with a 50 ms delay, the caps, num or scroll lock keys will be randomly pressed.
31
REM When the "keyboard fireworks" display has concluded, the previously saved keyboard lock state will be restored.
32
REM Meaning, if the target has caps lock off, scroll lock off, and num lock on before the payload began, so too would it after its conclusion.
33
34