Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hak5
GitHub Repository: hak5/usbrubberducky-payloads
Path: blob/master/payloads/extensions/self_destruct.txt
2968 views
1
EXTENSION SELF_DESTRUCT
2
REM VERSION 1.0
3
REM AUTHOR: Korben
4
5
REM_BLOCK Documentation
6
This extension is used to "SELF DESTRUCT" a payload in one of two ways
7
8
TARGET:
9
Any
10
11
USAGE:
12
Place this extension at top of your payload.
13
14
15
CONFIGURATION:
16
Set the #DESTRUCT_METHOD to one of the following methods:
17
REVERT_TO_THUMBDRIVE()
18
- delete payload and enter storage mode.
19
To return to normal usage simply add a new inject.bin
20
21
SOFT_BRICK()
22
- keeps payload in order to force OFF w/ disabled button.
23
To return to normal usage the SD card will need to be removed and
24
the inject.bin replaced.
25
26
Set #RUNS_BEFORE_DESTROY to an integer - the number of times the payload
27
must run before it self destructs
28
29
#REQUIRES_FINISH if set to TRUE will require you to call PAYLOAD_FINISHED()
30
at the end of the payload for the deployment to count towards #RUNS_BEFORE_DESTROY
31
32
Since this extension replaces "boot", #BOOT_ATTACKMODE defines the
33
the default mode to enter after this extension has run
34
END_REM
35
DEFINE #REQUIRES_FINISH FALSE
36
DEFINE #RUNS_BEFORE_DESTROY 1
37
DEFINE #DESTRUCT_METHOD REVERT_TO_THUMBDRIVE()
38
DEFINE #BOOT_ATTACKMODE ATTACKMODE HID
39
40
ATTACKMODE OFF
41
42
FUNCTION PERSIST()
43
REM_BLOCK note
44
this takes advantage of a sideaffect of hide/restore procedure and
45
_how_ we initialize the variable we want to persist.
46
END_REM
47
HIDE_PAYLOAD
48
DELAY 100
49
RESTORE_PAYLOAD
50
END_FUNCTION
51
52
FUNCTION SOFT_BRICK()
53
ATTACKMODE OFF
54
LED_OFF
55
DISABLE_BUTTON
56
STOP_PAYLOAD
57
END_FUNCTION
58
59
FUNCTION REVERT_TO_THUMBDRIVE()
60
LED_OFF
61
HIDE_PAYLOAD
62
DELAY 500
63
ATTACKMODE STORAGE
64
END_FUNCTION
65
66
FUNCTION PAYLOAD_FINISHED()
67
$TIMES_RAN = ($TIMES_RAN + 1)
68
PERSIST()
69
IF ($TIMES_RAN < #RUNS_BEFORE_DESTROY) THEN
70
#DESTRUCT_METHOD
71
END_IF
72
END_FUNCTION
73
74
IF ($TIMES_RAN < #RUNS_BEFORE_DESTROY) THEN
75
IF_NOT_DEFINED_TRUE #REQUIRES_FINISH
76
VAR $TIMES_RAN = ($TIMES_RAN + 1)
77
PERSIST()
78
END_IF_DEFINED
79
#BOOT_ATTACKMODE
80
ELSE
81
#DESTRUCT_METHOD
82
END_IF
83
END_EXTENSION
84
85