Skip to content

Commit 9072a56

Browse files
author
Stefan Kremser
committed
Added option to use an OLED display
1 parent ea17fa4 commit 9072a56

File tree

8 files changed

+621
-26
lines changed

8 files changed

+621
-26
lines changed

esp8266_deauther/APScan.cpp

+36-20
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void APScan::sendResults(){
181181

182182
}
183183

184-
String APScan::getResults(){
184+
String APScan::getResultsJSON(){
185185
if(debug) Serial.print("getting AP scan result JSON ");
186186
String json = "{ \"aps\":[ ";
187187
for(int i=0;i<results && i<maxAPScanResults;i++){
@@ -206,26 +206,42 @@ String APScan::getResults(){
206206
return json;
207207
}
208208

209-
String APScan::getResult(int i){
210-
if(debug) Serial.print("getting AP scan result JSON for ID " + String(i));
211-
String json = "{ \"aps\":[ ";
212-
if(debug) Serial.print(".");
213-
json += "{";
214-
json += "\"i\":"+(String)i+",";
215-
json += "\"c\":"+(String)getAPChannel(i)+",";
216-
json += "\"m\":\""+getAPMac(i)+"\",";
217-
json += "\"ss\":\""+getAPName(i)+"\",";
218-
json += "\"r\":"+(String)getAPRSSI(i)+",";
219-
json += "\"e\":"+(String)encryption[i]+",";
220-
//json += "\"v\":\""+getAPVendor(i)+"\",";
221-
json += "\"se\":"+(String)getAPSelected(i);
222-
json += "}";
223-
json += "] }";
224-
if(debug){
225-
Serial.println(json);
226-
Serial.println("done");
209+
void APScan::sort(){
210+
if(debug) Serial.println("sorting APs ");
211+
212+
//bubble sort
213+
for(int i=0;i<results-1;i++){
214+
Serial.println("--------------");
215+
for(int h=0;h<results-i-1;h++){
216+
217+
if(rssi[h] < rssi[h+1]){
218+
Serial.println("switched: "+(String)rssi[h]+" > "+(String)rssi[h+1]);
219+
int tmpA = channels[h];
220+
channels[h] = channels[h+1];
221+
channels[h+1] = tmpA;
222+
223+
tmpA = rssi[h];
224+
rssi[h] = rssi[h+1];
225+
rssi[h+1] = tmpA;
226+
227+
tmpA = encryption[h];
228+
encryption[h] = encryption[h+1];
229+
encryption[h+1] = tmpA;
230+
231+
String tmpB = names[h];
232+
strncpy(names[h],names[h+1],32);
233+
tmpB.toCharArray(names[h+1],32);
234+
235+
bool tmpC = hidden[h];
236+
hidden[h] = hidden[h+1];
237+
hidden[h+1] = tmpC;
238+
239+
tmpC = selected[h];
240+
selected[h] = selected[h+1];
241+
selected[h+1] = tmpC;
242+
}else Serial.println((String)rssi[h]+" < "+(String)rssi[h+1]);
243+
}
227244
}
228-
return json;
229245
}
230246

231247
void APScan::select(int num){

esp8266_deauther/APScan.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class APScan{
2323
APScan();
2424

2525
bool start();
26-
String getResults();
27-
String getResult(int i);
26+
void sort();
27+
String getResultsJSON();
2828
void select(int num);
2929
void sendResults();
3030

esp8266_deauther/Attack.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void Attack::run(){
196196
if(debug) Serial.println(" done");
197197
if(settings.attackTimeout > 0){
198198
attackTimeoutCounter[0]++;
199-
if(attackTimeoutCounter[0] > settings.attackTimeout) stop(1);
199+
if(attackTimeoutCounter[0] > settings.attackTimeout) stop(0);
200200
}
201201
}
202202

@@ -316,6 +316,7 @@ void Attack::start(int num){
316316
attackTimeoutCounter[num] = 0;
317317
refreshLed();
318318
if(debug) Serial.println("starting "+(String)attackNames[num]+" attack...");
319+
if(num == 0) attackMode = "stop";
319320
if(num == 1){
320321
stop(2);
321322
stop(3);
@@ -332,6 +333,7 @@ void Attack::start(int num){
332333
void Attack::stop(int num){
333334
if(isRunning[num]){
334335
if(debug) Serial.println("stopping "+(String)attackNames[num]+" attack...");
336+
if(num == 0) attackMode = "start";
335337
isRunning[num] = false;
336338
stati[num] = "ready";
337339
prevTime[num] = millis();

esp8266_deauther/Attack.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern void PrintHex8(uint8_t *data, uint8_t length);
2424
extern void getRandomVendorMac(uint8_t *buf);
2525
extern String data_getVendor(uint8_t first,uint8_t second,uint8_t third);
2626
extern const bool debug;
27+
extern String attackMode;
2728

2829
extern APScan apScan;
2930
extern ClientScan clientScan;

esp8266_deauther/ClientScan.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ ClientScan::ClientScan(){
55
zero.set(0x00,0x00,0x00,0x00,0x00,0x00);
66
}
77

8+
void ClientScan::clearList(){
9+
clients._clear();
10+
}
11+
812
void ClientScan::start(int _time){
913
Serial.println();
1014
Serial.println("starting client scan");
1115

12-
clients._clear();
16+
clearList();
1317
for(int i=0;i<maxClientScanResults;i++){
1418
selected[i] = false;
1519
packets[i] = 0;

esp8266_deauther/ClientScan.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ClientScan{
2626
ClientScan();
2727

2828
void start(int _time);
29+
void clearList();
2930
bool stop();
3031
void packetSniffer(uint8_t *buf, uint16_t len);
3132

0 commit comments

Comments
 (0)