MCPcopy Create free account
hub / github.com/BruceDevices/firmware / buildBeaconFrame

Function buildBeaconFrame

src/modules/wifi/karma_attack.cpp:1214–1272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1212}
1213
1214size_t buildBeaconFrame(uint8_t *buffer, const String &ssid, uint8_t channel, const RSNInfo &rsn) {
1215 uint8_t pos = 0;
1216 buffer[pos++] = 0x80;
1217 buffer[pos++] = 0x00;
1218 buffer[pos++] = 0x00;
1219 buffer[pos++] = 0x00;
1220 memset(&buffer[pos], 0xFF, 6);
1221 pos += 6;
1222 memcpy(&buffer[pos], currentBSSID, 6);
1223 pos += 6;
1224 memcpy(&buffer[pos], currentBSSID, 6);
1225 pos += 6;
1226 buffer[pos++] = 0x00;
1227 buffer[pos++] = 0x00;
1228 static uint64_t timestamp = 0;
1229 timestamp += 1024;
1230 for (int i = 0; i < 8; i++) buffer[pos++] = (timestamp >> (8 * i)) & 0xFF;
1231 buffer[pos++] = 0x64;
1232 buffer[pos++] = 0x00;
1233 if (rsn.akmSuite > 0) {
1234 buffer[pos++] = 0x31;
1235 buffer[pos++] = 0x04;
1236 } else {
1237 buffer[pos++] = 0x21;
1238 buffer[pos++] = 0x04;
1239 }
1240 buffer[pos++] = 0x00;
1241 buffer[pos++] = (uint8_t)ssid.length();
1242 if (ssid.length() > 0 && ssid != "*HIDDEN*" && ssid != "*WILDCARD*") {
1243 memcpy(&buffer[pos], ssid.c_str(), ssid.length());
1244 pos += ssid.length();
1245 }
1246 buffer[pos++] = 0x01;
1247 buffer[pos++] = sizeof(beacon_rates);
1248 memcpy_P(&buffer[pos], beacon_rates, sizeof(beacon_rates));
1249 pos += sizeof(beacon_rates);
1250 buffer[pos++] = 0x03;
1251 buffer[pos++] = 0x01;
1252 buffer[pos++] = channel;
1253 if (rsn.akmSuite > 0) {
1254 buffer[pos++] = 0x30;
1255 if (rsn.akmSuite == 2) {
1256 buffer[pos++] = sizeof(rsn_wpa3);
1257 memcpy_P(&buffer[pos], rsn_wpa3, sizeof(rsn_wpa3));
1258 pos += sizeof(rsn_wpa3);
1259 } else {
1260 buffer[pos++] = sizeof(rsn_wpa2);
1261 memcpy_P(&buffer[pos], rsn_wpa2, sizeof(rsn_wpa2));
1262 pos += sizeof(rsn_wpa2);
1263 }
1264 }
1265 buffer[pos++] = 0x05;
1266 buffer[pos++] = 0x04;
1267 buffer[pos++] = 0x00;
1268 buffer[pos++] = 0x01;
1269 buffer[pos++] = 0x00;
1270 buffer[pos++] = 0x00;
1271 return pos;

Callers 1

sendBeaconFramesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected