mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 06:59:59 +01:00
added buffer functions and fixed APScan issue
This commit is contained in:
@@ -26,6 +26,8 @@ bool APScan::start(){
|
|||||||
_ssid.toCharArray(names[i],33);
|
_ssid.toCharArray(names[i],33);
|
||||||
//data_getVendor(WiFi.BSSID(i)[0],WiFi.BSSID(i)[1],WiFi.BSSID(i)[2]).toCharArray(vendors[i],9);
|
//data_getVendor(WiFi.BSSID(i)[0],WiFi.BSSID(i)[1],WiFi.BSSID(i)[2]).toCharArray(vendors[i],9);
|
||||||
if(debug){
|
if(debug){
|
||||||
|
Serial.print((String)i);
|
||||||
|
Serial.print(" - ");
|
||||||
_ap._print();
|
_ap._print();
|
||||||
Serial.print(" - ");
|
Serial.print(" - ");
|
||||||
Serial.print(channels[i]);
|
Serial.print(channels[i]);
|
||||||
@@ -44,7 +46,8 @@ bool APScan::start(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//for debugging the APScan crash bug
|
//for debugging the APScan crash bug
|
||||||
/*if(debug){
|
/*
|
||||||
|
if(debug){
|
||||||
for(int i=results;i<maxAPScanResults;i++){
|
for(int i=results;i<maxAPScanResults;i++){
|
||||||
Mac _ap;
|
Mac _ap;
|
||||||
_ap.set(random(255),random(255),random(255),random(255),random(255),random(255));
|
_ap.set(random(255),random(255),random(255),random(255),random(255),random(255));
|
||||||
@@ -55,6 +58,8 @@ bool APScan::start(){
|
|||||||
String _ssid = "test_dbeJwq3tPtJsuWtgULgShD9dxXV";
|
String _ssid = "test_dbeJwq3tPtJsuWtgULgShD9dxXV";
|
||||||
_ssid.toCharArray(names[i],33);
|
_ssid.toCharArray(names[i],33);
|
||||||
|
|
||||||
|
Serial.print((String)i);
|
||||||
|
Serial.print(" - ");
|
||||||
_ap._print();
|
_ap._print();
|
||||||
Serial.print(" - ");
|
Serial.print(" - ");
|
||||||
Serial.print(channels[i]);
|
Serial.print(channels[i]);
|
||||||
@@ -68,10 +73,10 @@ bool APScan::start(){
|
|||||||
|
|
||||||
results++;
|
results++;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if(debug) Serial.println("scan done");
|
if(debug) Serial.println("scan done");
|
||||||
if(debug) Serial.println(getResults());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +120,67 @@ int APScan::getFirstTarget(){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void APScan::sendResults(){
|
||||||
|
if(debug) Serial.print("sending AP scan result JSON ");
|
||||||
|
|
||||||
|
size_t _size = 10; // {"aps":[]}
|
||||||
|
for(int i=0;i<results && i<maxAPScanResults;i++){
|
||||||
|
/*
|
||||||
|
_size++; // {
|
||||||
|
_size += 5; // "i": ,
|
||||||
|
_size += String(i).length();
|
||||||
|
_size += 5; // "c": ,
|
||||||
|
_size += String(getAPChannel(i)).length();
|
||||||
|
_size += 24; // "m":"d4:21:22:da:85:f3",
|
||||||
|
_size += 8; // "ss":" ",
|
||||||
|
_size += getAPName(i).length();
|
||||||
|
_size += 5; // "r": ,
|
||||||
|
_size += String(getAPRSSI(i)).length();
|
||||||
|
_size += 6; // "e": ,
|
||||||
|
_size += 6; // "se":0
|
||||||
|
_size++; // }*/
|
||||||
|
_size += 61;
|
||||||
|
_size += String(i).length();
|
||||||
|
_size += String(getAPChannel(i)).length();
|
||||||
|
_size += getAPName(i).length();
|
||||||
|
_size += String(getAPRSSI(i)).length();
|
||||||
|
|
||||||
|
if((i!=results-1) && (i!=maxAPScanResults-1)) _size++; // ,
|
||||||
|
}
|
||||||
|
|
||||||
|
sendHeader(200, "text/json", _size);
|
||||||
|
|
||||||
|
String json;
|
||||||
|
int bufc = 0; //bufferCounter
|
||||||
|
json = "{\"aps\":[";
|
||||||
|
|
||||||
|
sendToBuffer(json);
|
||||||
|
|
||||||
|
for(int i=0;i<results && i<maxAPScanResults;i++){
|
||||||
|
if(debug) Serial.print(".");
|
||||||
|
json = "{";
|
||||||
|
json += "\"i\":"+(String)i+",";
|
||||||
|
json += "\"c\":"+(String)getAPChannel(i)+",";
|
||||||
|
json += "\"m\":\""+getAPMac(i)+"\",";
|
||||||
|
json += "\"ss\":\""+getAPName(i)+"\",";
|
||||||
|
json += "\"r\":"+(String)getAPRSSI(i)+",";
|
||||||
|
json += "\"e\":"+(String)encryption[i]+",";
|
||||||
|
//json += "\"v\":\""+getAPVendor(i)+"\",";
|
||||||
|
json += "\"se\":"+(String)getAPSelected(i);
|
||||||
|
json += "}";
|
||||||
|
if((i!=results-1) && (i!=maxAPScanResults-1)) json += ",";
|
||||||
|
|
||||||
|
sendToBuffer(json);
|
||||||
|
|
||||||
|
}
|
||||||
|
json = "]}";
|
||||||
|
sendToBuffer(json);
|
||||||
|
sendBuffer();
|
||||||
|
|
||||||
|
if(debug) Serial.println("done");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
String APScan::getResults(){
|
String APScan::getResults(){
|
||||||
if(debug) Serial.print("getting AP scan result JSON ");
|
if(debug) Serial.print("getting AP scan result JSON ");
|
||||||
String json = "{ \"aps\":[ ";
|
String json = "{ \"aps\":[ ";
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
#ifndef APScan_h
|
#ifndef APScan_h
|
||||||
#define APScan_h
|
#define APScan_h
|
||||||
|
|
||||||
#define maxAPScanResults 30
|
#define maxAPScanResults 80
|
||||||
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include "Mac.h"
|
#include "Mac.h"
|
||||||
#include "MacList.h"
|
#include "MacList.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
|
||||||
extern String data_getVendor(uint8_t first,uint8_t second,uint8_t third);
|
extern String data_getVendor(uint8_t first,uint8_t second,uint8_t third);
|
||||||
|
extern ESP8266WebServer server;
|
||||||
|
extern void sendBuffer();
|
||||||
|
extern void sendToBuffer(String str);
|
||||||
|
extern void sendHeader(int code, String type, size_t _size);
|
||||||
extern const bool debug;
|
extern const bool debug;
|
||||||
|
|
||||||
extern Settings settings;
|
extern Settings settings;
|
||||||
@@ -21,6 +26,7 @@ class APScan{
|
|||||||
String getResults();
|
String getResults();
|
||||||
String getResult(int i);
|
String getResult(int i);
|
||||||
void select(int num);
|
void select(int num);
|
||||||
|
void sendResults();
|
||||||
|
|
||||||
String getAPName(int num);
|
String getAPName(int num);
|
||||||
String getAPEncryption(int num);
|
String getAPEncryption(int num);
|
||||||
@@ -38,6 +44,7 @@ class APScan{
|
|||||||
int selectedSum;
|
int selectedSum;
|
||||||
MacList aps;
|
MacList aps;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int channels[maxAPScanResults];
|
int channels[maxAPScanResults];
|
||||||
int rssi[maxAPScanResults];
|
int rssi[maxAPScanResults];
|
||||||
char names[maxAPScanResults][33];
|
char names[maxAPScanResults][33];
|
||||||
@@ -47,6 +54,7 @@ class APScan{
|
|||||||
String getEncryption(int code);
|
String getEncryption(int code);
|
||||||
|
|
||||||
bool selected[maxAPScanResults];
|
bool selected[maxAPScanResults];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -8,6 +8,8 @@ extern "C" {
|
|||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP8266WebServer server(80);
|
||||||
|
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "NameList.h"
|
#include "NameList.h"
|
||||||
@@ -21,8 +23,6 @@ extern "C" {
|
|||||||
const bool debug = true;
|
const bool debug = true;
|
||||||
/* ========== DEBUG ========== */
|
/* ========== DEBUG ========== */
|
||||||
|
|
||||||
ESP8266WebServer server(80);
|
|
||||||
|
|
||||||
NameList nameList;
|
NameList nameList;
|
||||||
|
|
||||||
APScan apScan;
|
APScan apScan;
|
||||||
@@ -71,12 +71,14 @@ void startAPScan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sendAPResults() {
|
void sendAPResults() {
|
||||||
|
apScan.sendResults();
|
||||||
|
/*
|
||||||
if (server.hasArg("apid")) {
|
if (server.hasArg("apid")) {
|
||||||
int apid = server.arg("apid").toInt();
|
int apid = server.arg("apid").toInt();
|
||||||
server.send ( 200, "text/json", apScan.getResult(apid));
|
server.send ( 200, "text/json", apScan.getResult(apid));
|
||||||
} else {
|
} else {
|
||||||
server.send ( 200, "text/json", apScan.getResults());
|
server.send ( 200, "text/json", apScan.getResults());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void selectAP() {
|
void selectAP() {
|
||||||
|
|||||||
Reference in New Issue
Block a user