61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <WiFi.h>
|
|
#include "esp_wifi.h"
|
|
#include <SD.h>
|
|
|
|
// Bypass ESP32 frame sanity check
|
|
extern "C" int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, int32_t arg3);
|
|
|
|
// PCAP structures
|
|
typedef struct {
|
|
uint32_t magic_number;
|
|
uint16_t version_major;
|
|
uint16_t version_minor;
|
|
int32_t thiszone;
|
|
uint32_t sigfigs;
|
|
uint32_t snaplen;
|
|
uint32_t network;
|
|
} __attribute__((packed)) pcap_global_header_t;
|
|
|
|
typedef struct {
|
|
uint32_t ts_sec;
|
|
uint32_t ts_usec;
|
|
uint32_t incl_len;
|
|
uint32_t orig_len;
|
|
} __attribute__((packed)) pcap_record_header_t;
|
|
|
|
// Network structure
|
|
typedef struct {
|
|
String ssid;
|
|
uint8_t bssid[6];
|
|
int ch;
|
|
int rssi;
|
|
String encryption;
|
|
bool handshake_captured;
|
|
} Network;
|
|
|
|
// Global variables (extern)
|
|
extern Network networks[20];
|
|
extern Network target;
|
|
extern bool is_capturing;
|
|
extern bool with_deauth;
|
|
extern uint8_t eapol_count;
|
|
extern bool beacon_captured;
|
|
|
|
// Functions
|
|
void handshakeCaptureInit();
|
|
void scanNetworksSortedByRSSI(); // fills networks array sorted by RSSI
|
|
void startCapture(bool deauth);
|
|
void stopCapture();
|
|
void saveHandshakeToSD();
|
|
void promiscuousRxCallback(void* buf, wifi_promiscuous_pkt_type_t type);
|
|
void pcapInit();
|
|
void pcapAppend(const uint8_t* frame, size_t len);
|
|
void sendDeauth();
|
|
void setTarget(int index);
|
|
int getCurrentTargetIndex();
|
|
bool isHandshakeCaptured(int index);
|
|
void markHandshakeCaptured(int index);
|
|
void handshakeCaptureLoop(); |