Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hak5
GitHub Repository: hak5/usbrubberducky-payloads
Path: blob/master/payloads/examples/Functions/Functions-example2.txt
2968 views
1
REM Example FUNCTION with RETURN
2
ATTACKMODE HID
3
DELAY 2000
4
5
BUTTON_DEF
6
STRING !
7
END_BUTTON
8
9
FUNCTION TEST_BUTTON()
10
STRING Press the button within the next 5 seconds.
11
VAR $TIMER = 5
12
WHILE ($TIMER > 0)
13
STRING .
14
DELAY 1000
15
$TIMER = ($TIMER - 1)
16
END_WHILE
17
ENTER
18
IF ($_BUTTON_PUSH_RECEIVED == TRUE) THEN
19
RETURN TRUE
20
ELSE IF ($_BUTTON_PUSH_RECEIVED == FALSE) THEN
21
RETURN FALSE
22
END_IF
23
END_FUNCTION
24
25
IF (TEST_BUTTON() == TRUE) THEN
26
STRINGLN The button was pressed!
27
ELSE
28
STRINGLN The button was not pressed!
29
END_IF
30
31
REM When the IF statement on line 26 checks the condition of the function TEST_BUTTON, the function is called and executed.
32
REM Based on whether or not the button is pressed, the RETURN value (lines 19 and 21) will be set to TRUE or FALSE.
33
REM The IF statement on line 26 evaluates the RETURN of the function TEST_BUTTON and types the result accordingly.
34
35