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

Function saveHandshakeToFile

src/modules/wifi/karma_attack.cpp:2223–2258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2221}
2222
2223void saveHandshakeToFile(const HandshakeCapture &hs) {
2224 FS *fs = nullptr;
2225 if (!getFsStorage(fs)) return;
2226
2227 if (!fs->exists("/BrucePCAP/handshakes")) { fs->mkdir("/BrucePCAP/handshakes"); }
2228
2229 char macStr[18];
2230 snprintf(
2231 macStr,
2232 sizeof(macStr),
2233 "%02X%02X%02X%02X%02X%02X",
2234 hs.bssid[0],
2235 hs.bssid[1],
2236 hs.bssid[2],
2237 hs.bssid[3],
2238 hs.bssid[4],
2239 hs.bssid[5]
2240 );
2241
2242 String filename = "/BrucePCAP/handshakes/HS_" + String(macStr) + "_" + hs.ssid + ".pcap";
2243 filename.replace(" ", "_");
2244 filename.replace("*", "");
2245
2246 File file = fs->open(filename, FILE_APPEND);
2247 if (file) {
2248 uint32_t ts_sec = hs.timestamp / 1000;
2249 uint32_t ts_usec = (hs.timestamp % 1000) * 1000;
2250 file.write((uint8_t *)&ts_sec, 4);
2251 file.write((uint8_t *)&ts_usec, 4);
2252 uint32_t len = hs.frameLen;
2253 file.write((uint8_t *)&len, 4);
2254 file.write((uint8_t *)&len, 4);
2255 file.write(hs.eapolFrame, hs.frameLen);
2256 file.close();
2257 }
2258}
2259
2260void setChannelWithSecond(uint8_t channel) {
2261 wifi_second_chan_t secondCh = WIFI_SECOND_CHAN_NONE;

Callers 1

probe_snifferFunction · 0.85

Calls 3

getFsStorageFunction · 0.85
closeMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected