mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-22 23:26:49 -08:00
Dynamic ledPin switching
This commit is contained in:
@@ -461,11 +461,11 @@ void Attack::refreshLed() {
|
|||||||
}
|
}
|
||||||
if (numberRunning >= 1 && settings.useLed) {
|
if (numberRunning >= 1 && settings.useLed) {
|
||||||
if (debug) Serial.println("Attack LED : ON");
|
if (debug) Serial.println("Attack LED : ON");
|
||||||
digitalWrite(settings.ledPin, LOW);
|
digitalWrite(settings.ledPin, !settings.pinStateOff);
|
||||||
}
|
}
|
||||||
else if (numberRunning == 0 || !settings.useLed) {
|
else if (numberRunning == 0 || !settings.useLed) {
|
||||||
if (debug) Serial.println("Attack LED : OFF");
|
if (debug) Serial.println("Attack LED : OFF");
|
||||||
digitalWrite(settings.ledPin, HIGH);
|
digitalWrite(settings.ledPin, settings.pinStateOff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define attacksNum 3
|
#define attacksNum 3
|
||||||
#define macListLen 64
|
#define macListLen 64
|
||||||
|
#define PIN_STATE_OFF false
|
||||||
|
#define PIN_STATE_ON true
|
||||||
|
|
||||||
extern void PrintHex8(uint8_t *data, uint8_t length);
|
extern void PrintHex8(uint8_t *data, uint8_t length);
|
||||||
extern void getRandomVendorMac(uint8_t *buf);
|
extern void getRandomVendorMac(uint8_t *buf);
|
||||||
|
|||||||
@@ -26,6 +26,21 @@ void Settings::syncMacInterface(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::setLedPin(int newLedPin){
|
||||||
|
prevLedPin = ledPin;
|
||||||
|
if(newLedPin > 0 && newLedPin != prevLedPin){
|
||||||
|
ledPin = newLedPin;
|
||||||
|
pinMode(ledPin, OUTPUT);
|
||||||
|
if(!prevLedPin == 0){
|
||||||
|
digitalWrite(ledPin, digitalRead(prevLedPin));
|
||||||
|
digitalWrite(prevLedPin, pinStateOff);
|
||||||
|
pinMode(prevLedPin, INPUT);
|
||||||
|
}else{
|
||||||
|
digitalWrite(ledPin, pinStateOff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::load() {
|
void Settings::load() {
|
||||||
|
|
||||||
if (EEPROM.read(checkNumAdr) != checkNum) {
|
if (EEPROM.read(checkNumAdr) != checkNum) {
|
||||||
@@ -72,7 +87,7 @@ void Settings::load() {
|
|||||||
multiAttacks = (bool)EEPROM.read(multiAttacksAdr);
|
multiAttacks = (bool)EEPROM.read(multiAttacksAdr);
|
||||||
macInterval = eepromReadInt(macIntervalAdr);
|
macInterval = eepromReadInt(macIntervalAdr);
|
||||||
beaconInterval = (bool)EEPROM.read(beaconIntervalAdr);
|
beaconInterval = (bool)EEPROM.read(beaconIntervalAdr);
|
||||||
ledPin = (int)EEPROM.read(ledPinAdr);
|
setLedPin((int)EEPROM.read(ledPinAdr));
|
||||||
isSettingsLoaded = 1;
|
isSettingsLoaded = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ class Settings
|
|||||||
void save();
|
void save();
|
||||||
void send();
|
void send();
|
||||||
void info();
|
void info();
|
||||||
void syncMacInterface();
|
|
||||||
|
|
||||||
int ssidLen;
|
int ssidLen;
|
||||||
String ssid = "";
|
String ssid = "";
|
||||||
@@ -76,11 +75,15 @@ class Settings
|
|||||||
bool multiAttacks;
|
bool multiAttacks;
|
||||||
int macInterval;
|
int macInterval;
|
||||||
bool beaconInterval;
|
bool beaconInterval;
|
||||||
int ledPin;
|
int ledPin = 0;
|
||||||
|
int prevLedPin = 0;
|
||||||
Mac defaultMacAP;
|
Mac defaultMacAP;
|
||||||
Mac macAP;
|
Mac macAP;
|
||||||
bool isMacAPRand;
|
bool isMacAPRand;
|
||||||
bool isSettingsLoaded = 0;
|
bool isSettingsLoaded = 0;
|
||||||
|
void syncMacInterface();
|
||||||
|
void setLedPin(int newLedPin);
|
||||||
|
bool pinStateOff = true; // When attack is off, pin state is HIGH
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t getSize();
|
size_t getSize();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -445,7 +445,7 @@ void saveSettings() {
|
|||||||
else settings.multiAttacks = true;
|
else settings.multiAttacks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server.hasArg("ledPin")) settings.ledPin = server.arg("ledPin").toInt();
|
if (server.hasArg("ledPin")) settings.setLedPin(server.arg("ledPin").toInt());
|
||||||
if(server.hasArg("macInterval")) settings.macInterval = server.arg("macInterval").toInt();
|
if(server.hasArg("macInterval")) settings.macInterval = server.arg("macInterval").toInt();
|
||||||
|
|
||||||
settings.save();
|
settings.save();
|
||||||
@@ -479,6 +479,8 @@ void setup() {
|
|||||||
nameList.load();
|
nameList.load();
|
||||||
ssidList.load();
|
ssidList.load();
|
||||||
|
|
||||||
|
attack.refreshLed();
|
||||||
|
|
||||||
delay(500); // Prevent bssid leak
|
delay(500); // Prevent bssid leak
|
||||||
|
|
||||||
startWifi();
|
startWifi();
|
||||||
@@ -568,9 +570,6 @@ void setup() {
|
|||||||
if(digitalRead(resetPin) == LOW) settings.reset();
|
if(digitalRead(resetPin) == LOW) settings.reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pinMode(settings.ledPin, OUTPUT);
|
|
||||||
digitalWrite(settings.ledPin, HIGH);
|
|
||||||
|
|
||||||
if(debug){
|
if(debug){
|
||||||
Serial.println("\nStarting...\n");
|
Serial.println("\nStarting...\n");
|
||||||
#ifndef USE_DISPLAY
|
#ifndef USE_DISPLAY
|
||||||
|
|||||||
@@ -137,7 +137,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<label for="ledPin">LED Pin (restart needed)</label>
|
<label for="ledPin">LED Pin</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<input type="number" id="ledPin" min="0" max="18">
|
<input type="number" id="ledPin" min="0" max="18">
|
||||||
|
|||||||
Reference in New Issue
Block a user