-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrap.ino
189 lines (145 loc) · 3.35 KB
/
trap.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#include <phukdlib.h>
/* Simple USB Keyboard Example
Teensy becomes a USB keyboard and types characters
You must select Keyboard from the "Tools > USB Type" menu
*/
const int ledPin = 13;
const int payloadDelay = 60000;
bool prepared = false;
bool activation1 = false;
bool activation2 = false;
unsigned long lastActivationButtonTime = 0;
bool capsLockTrapSet = false;
bool numLockOn;
void setup() {
pinMode(ledPin, OUTPUT);
Keyboard.begin();
Serial.begin(9600);
delay(1000);
ledOn();
Serial.println("Start");
numLockOn = IsNumbOn();
//scrollLockOn = IsScrlOn();
}
void loop() {
delay(100);
if (!activation1) {
if (IsNumbOn() == numLockOn)
return;
lastActivationButtonTime = millis();
Serial.println("activation 1");
activation1 = true;
return;
}
if (!activation2) {
if (IsNumbOn() != numLockOn)
return;
activation2 = true;
Serial.println("Activated");
ledOff();
}
if (!capsLockTrapSet && !IsCapsOn()){
Keyboard.press(KEY_CAPS_LOCK);
Keyboard.releaseAll();
delay(500);
capsLockTrapSet = true;
}
if (capsLockTrapSet && !IsCapsOn()) {
delay(payloadDelay);
runPayload();
ledOn();
activation1 = false;
activation2 = false;
capsLockTrapSet = false;
}
}
void runPayload() {
//browser();
wander();
//lightShow();
}
void browser() {
CommandAtRunBarMSWIN("cmd /c start http://irongeek.com");
}
int jiggleIntervalSecs = 10;
void jiggle() {
bool scrollLockOn = IsScrlOn();
while (IsScrlOn() == scrollLockOn) {
int i;
for (i=0; i<40; i++) {
Mouse.move(0, -6);
delay(10);
Mouse.move(0, 6);
delay(10);
}
int j;
for (j=0; j<jiggleIntervalSecs; j++) {
if (IsScrlOn() != scrollLockOn){
Serial.println("End Jiggling");
Keyboard.press(KEY_SCROLL_LOCK);
Keyboard.releaseAll();
return;
}
delay(1000);
}
}
}
int wanderIntervalSecs = 30;
void wander() {
bool scrollLockOn = IsScrlOn();
while (IsScrlOn() == scrollLockOn) {
Mouse.move(2, 6);
int j;
for (j=0; j<wanderIntervalSecs; j++) {
if (IsScrlOn() != scrollLockOn){
Serial.println("End Wandering");
Keyboard.press(KEY_SCROLL_LOCK);
Keyboard.releaseAll();
return;
}
delay(1000);
}
}
}
void lightShow() {
bool scrollLockOn = IsScrlOn();
bool numLockOn = IsNumbOn();
bool capsOn = IsCapsOn();
if (IsCapsOn()) {
Keyboard.press(KEY_CAPS_LOCK);
Keyboard.releaseAll();
}
if (IsScrlOn()) {
Keyboard.press(KEY_SCROLL_LOCK);
Keyboard.releaseAll();
}
if (IsNumbOn()) {
Keyboard.press(KEY_NUM_LOCK);
Keyboard.releaseAll();
}
int i;
for (int i = 0; i<20; i++) {
Keyboard.press(KEY_CAPS_LOCK);
Keyboard.releaseAll();
delay(200);
Keyboard.press(KEY_SCROLL_LOCK);
Keyboard.releaseAll();
delay(200);
Keyboard.press(KEY_NUM_LOCK);
Keyboard.releaseAll();
delay(200);
}
if (capsOn && !IsCapsOn())
Keyboard.press(KEY_CAPS_LOCK);
if (scrollLockOn && !IsScrlOn())
Keyboard.press(KEY_SCROLL_LOCK);
if (numLockOn && !IsNumbOn())
Keyboard.press(KEY_NUM_LOCK);
Keyboard.releaseAll();
}
void ledOn() {
digitalWrite(ledPin, HIGH);
}
void ledOff() {
digitalWrite(ledPin, LOW);
}