mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 06:59:59 +01:00
Added SSID List
This commit is contained in:
@@ -20,7 +20,10 @@ bool APScan::start(){
|
||||
channels[i] = WiFi.channel(i);
|
||||
rssi[i] = WiFi.RSSI(i);
|
||||
getEncryption(WiFi.encryptionType(i)).toCharArray(encryption[i],5);
|
||||
WiFi.SSID(i).toCharArray(names[i],33);
|
||||
String _ssid;
|
||||
_ssid = WiFi.SSID(i);
|
||||
_ssid.replace("\"","\\\"");
|
||||
_ssid.toCharArray(names[i],33);
|
||||
data_getVendor(WiFi.BSSID(i)[0],WiFi.BSSID(i)[1],WiFi.BSSID(i)[2]).toCharArray(vendors[i],9);
|
||||
if(debug){
|
||||
_ap._print();
|
||||
@@ -58,6 +61,8 @@ String APScan::getEncryption(int code){
|
||||
case ENC_TYPE_AUTO:
|
||||
return "WPA*";
|
||||
break;
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
Attack::Attack(){
|
||||
randomSeed(os_random());
|
||||
for(int i=0;i<attacksNum;i++) stati[i] = "ready";
|
||||
}
|
||||
|
||||
void Attack::generate(){
|
||||
@@ -235,6 +234,11 @@ String Attack::getResults(){
|
||||
if(debug) Serial.print("getting attacks JSON...");
|
||||
|
||||
if(apScan.getFirstTarget() < 0) stati[0] = stati[1] = "no AP";
|
||||
else {
|
||||
for(int i=0;i<attacksNum;i++){
|
||||
if(!isRunning[i]) stati[i] = "ready";
|
||||
}
|
||||
}
|
||||
|
||||
int _selected;
|
||||
String json = "{ \"aps\": [";
|
||||
@@ -265,11 +269,19 @@ String Attack::getResults(){
|
||||
json += "{";
|
||||
json += "\"name\": \""+attackNames[i]+"\",";
|
||||
json += "\"status\": \""+stati[i]+"\",";
|
||||
json += "\"running\": "+(String)isRunning[i];
|
||||
json += "\"running\": "+(String)isRunning[i]+"";
|
||||
json += "}";
|
||||
if(i != attacksNum-1) json += ",";
|
||||
}
|
||||
json += "] }";
|
||||
json += "],";
|
||||
|
||||
json += "\"ssid\": [";
|
||||
for(int i=0;i<ssidList.len;i++){
|
||||
json += "\""+ssidList.get(i)+"\"";
|
||||
if(i != ssidList.len-1) json += ",";
|
||||
}
|
||||
json += "]";
|
||||
json += "}";
|
||||
if(debug) Serial.println("done ");
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,10 @@ extern "C" {
|
||||
#include "APScan.h"
|
||||
#include "ClientScan.h"
|
||||
#include "Settings.h"
|
||||
#include "SSIDList.h"
|
||||
|
||||
#define attacksNum 2
|
||||
#define macListLen 80
|
||||
#define macListLen 64
|
||||
#define macChangeInterval 4
|
||||
|
||||
extern void PrintHex8(uint8_t *data, uint8_t length);
|
||||
@@ -25,6 +26,7 @@ extern const bool debug;
|
||||
extern APScan apScan;
|
||||
extern ClientScan clientScan;
|
||||
extern Settings settings;
|
||||
extern SSIDList ssidList;
|
||||
|
||||
class Attack
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ void NameList::clear(){
|
||||
clients._clear();
|
||||
EEPROM.write(romAdr,len);
|
||||
EEPROM.commit();
|
||||
Serial.println("EEPROM cleared");
|
||||
Serial.println("nameList cleared");
|
||||
}
|
||||
|
||||
void NameList::save(){
|
||||
@@ -84,3 +84,10 @@ void NameList::remove(int num){
|
||||
save();
|
||||
}
|
||||
|
||||
void NameList::edit(int num, String name){
|
||||
for(int i=0;i<nameLength;i++){
|
||||
if(i<name.length()) names[num][i] = name[i];
|
||||
else names[num][i] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#define romAdr 0
|
||||
#define maxSize 1024
|
||||
#define listLength 30
|
||||
#define listLength 50
|
||||
#define nameLength 18
|
||||
|
||||
/*
|
||||
@@ -24,6 +24,7 @@ class NameList
|
||||
void load();
|
||||
void clear();
|
||||
void add(Mac client, String name);
|
||||
void edit(int num, String name);
|
||||
String get(Mac client);
|
||||
String getName(int num);
|
||||
Mac getMac(int num);
|
||||
|
||||
80
esp8266_deauther/SSIDList.cpp
Normal file
80
esp8266_deauther/SSIDList.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "SSIDList.h"
|
||||
|
||||
SSIDList::SSIDList(){
|
||||
if(listAdr+SSIDListLength*SSIDLength > 4096) Serial.println("WARNING: EEPROM overflow!");
|
||||
}
|
||||
|
||||
void SSIDList::load(){
|
||||
len = EEPROM.read(lenAdr);
|
||||
for(int i=0;i<len;i++){
|
||||
for(int h=0;h<SSIDLength;h++){
|
||||
char _nextChar = EEPROM.read(listAdr+(i*SSIDLength)+h);
|
||||
names[i][h] = _nextChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SSIDList::clear(){
|
||||
len = 0;
|
||||
}
|
||||
|
||||
void SSIDList::add(String name){
|
||||
if(len < SSIDListLength){
|
||||
for(int i=0;i<SSIDLength;i++){
|
||||
if(i<name.length()) names[len][i] = name[i];
|
||||
else names[len][i] = 0x00;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
}
|
||||
|
||||
void SSIDList::edit(int num, String name){
|
||||
for(int i=0;i<SSIDLength;i++){
|
||||
if(i<name.length()) names[num][i] = name[i];
|
||||
else names[num][i] = 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
String SSIDList::get(int num){
|
||||
String _name = "";
|
||||
for(int i=0;i<SSIDLength;i++){
|
||||
if(names[num][i] != 0x00) _name += names[num][i];
|
||||
}
|
||||
return _name;
|
||||
}
|
||||
|
||||
void SSIDList::remove(int num){
|
||||
if(num >= 0 && num < len){
|
||||
for(int i=num;i<len-1;i++){
|
||||
for(int h=0;h<SSIDLength;h++){
|
||||
names[i][h] = names[i+1][h];
|
||||
}
|
||||
}
|
||||
len--;
|
||||
}
|
||||
}
|
||||
|
||||
void SSIDList::save(){
|
||||
if(debug) Serial.print("saving SSIDList...");
|
||||
EEPROM.write(lenAdr, len);
|
||||
for(int i=0;i<len;i++){
|
||||
for(int h=0;h<SSIDLength;h++){
|
||||
EEPROM.write(listAdr+(i*SSIDLength)+h, names[i][h]);
|
||||
}
|
||||
}
|
||||
EEPROM.commit();
|
||||
if(debug) Serial.println("done");
|
||||
}
|
||||
|
||||
void SSIDList::_random(){
|
||||
String _rName;
|
||||
for(int i=len;i<SSIDListLength;i++){
|
||||
_rName = "";
|
||||
//_rName = "a"+(String)(int)random(0,99);
|
||||
for(int h=0; h < SSIDLength; h++) _rName += letters[random(0,sizeof(letters))];
|
||||
add(_rName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
35
esp8266_deauther/SSIDList.h
Normal file
35
esp8266_deauther/SSIDList.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef SSIDList_h
|
||||
#define SSIDList_h
|
||||
|
||||
#include <EEPROM.h>
|
||||
#include "Mac.h"
|
||||
#include "MacList.h"
|
||||
|
||||
#define listAdr 2048
|
||||
#define lenAdr 2047
|
||||
#define SSIDListLength 64
|
||||
#define SSIDLength 32
|
||||
|
||||
extern const bool debug;
|
||||
|
||||
class SSIDList
|
||||
{
|
||||
public:
|
||||
SSIDList();
|
||||
|
||||
void load();
|
||||
void clear();
|
||||
void add(String name);
|
||||
void edit(int num, String name);
|
||||
String get(int num);
|
||||
void remove(int num);
|
||||
void _random();
|
||||
|
||||
int len = 0;
|
||||
private:
|
||||
void save();
|
||||
char letters[67] = {0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x20,0x2c,0x2e,0x2d,0x5f};
|
||||
char names[SSIDListLength][SSIDLength];
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because one or more lines are too long
@@ -15,8 +15,9 @@ extern "C" {
|
||||
#include "ClientScan.h"
|
||||
#include "Attack.h"
|
||||
#include "Settings.h"
|
||||
#include "SSIDList.h"
|
||||
|
||||
const bool debug = true;
|
||||
const bool debug = false;
|
||||
|
||||
ESP8266WebServer server(80);
|
||||
|
||||
@@ -32,6 +33,7 @@ APScan apScan;
|
||||
ClientScan clientScan;
|
||||
Attack attack;
|
||||
Settings settings;
|
||||
SSIDList ssidList;
|
||||
|
||||
void sniffer(uint8_t *buf, uint16_t len){
|
||||
clientScan.packetSniffer(buf,len);
|
||||
@@ -66,6 +68,10 @@ void setup(){
|
||||
attack.stopAll();
|
||||
attack.generate();
|
||||
|
||||
ssidList._random();
|
||||
for(int i=0;i<ssidList.len;i++) Serial.println(ssidList.get(i));
|
||||
Serial.println(attack.getResults());
|
||||
|
||||
/* ========== Web Server ========== */
|
||||
|
||||
/* HTML sites */
|
||||
@@ -94,7 +100,13 @@ void setup(){
|
||||
server.on("/attackStart.json", startAttack);
|
||||
server.on("/settings.json", getSettings);
|
||||
server.on("/settingsSave.json", saveSettings);
|
||||
server.on("/settingsReset.json", resetSettings);
|
||||
server.on("/deleteName.json", deleteName);
|
||||
server.on("/clearNameList.json", clearNameList);
|
||||
server.on("/editNameList.json", editClientName);
|
||||
server.on("/addSSID.json", addSSID);
|
||||
server.on("/deleteSSID.json", deleteSSID);
|
||||
server.on("/randomSSID.json", randomSSID);
|
||||
|
||||
server.begin();
|
||||
}
|
||||
@@ -175,9 +187,24 @@ void startAttack(){
|
||||
}
|
||||
}
|
||||
|
||||
void addSSID(){
|
||||
ssidList.add(server.arg("name"));
|
||||
server.send( 200, "text/json", "true");
|
||||
}
|
||||
|
||||
void deleteSSID(){
|
||||
ssidList.remove(server.arg("num").toInt());
|
||||
server.send( 200, "text/json", "true");
|
||||
}
|
||||
|
||||
void randomSSID(){
|
||||
ssidList._random();
|
||||
server.send( 200, "text/json", "true");
|
||||
}
|
||||
|
||||
//==========Settings==========
|
||||
void getSettings(){ server.send ( 200, "text/json", settings.get() ); }
|
||||
|
||||
void saveSettings(){
|
||||
if(server.hasArg("ssid")) settings.ssid = server.arg("ssid");
|
||||
if(server.hasArg("password")) settings.password = server.arg("password");
|
||||
@@ -190,6 +217,11 @@ void saveSettings(){
|
||||
server.send( 200, "text/json", "true" );
|
||||
}
|
||||
|
||||
void resetSettings(){
|
||||
settings.reset();
|
||||
server.send( 200, "text/json", "true" );
|
||||
}
|
||||
|
||||
void deleteName(){
|
||||
if(server.hasArg("num")) {
|
||||
int _num = server.arg("num").toInt();
|
||||
@@ -198,3 +230,15 @@ void deleteName(){
|
||||
}
|
||||
}
|
||||
|
||||
void clearNameList(){
|
||||
nameList.clear();
|
||||
server.send( 200, "text/json", "true" );
|
||||
}
|
||||
|
||||
void editClientName(){
|
||||
if(server.hasArg("id") && server.hasArg("name")) {
|
||||
nameList.edit(server.arg("id").toInt(),server.arg("name"));
|
||||
server.send( 200, "text/json", "true");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,11 @@
|
||||
<b>beacon [beacon flood attack]:</b><br>
|
||||
Spams beacon frames with a similar SSID as the selected WiFi access point(s).
|
||||
</p>
|
||||
<br />
|
||||
<p class="block bold">SSIDs: <button class="marginNull warnBtn">clear</button> <button class="marginNull" onclick="randomSSID()">random</button> <button class="marginNull" onclick="addSSID()">add</button></p>
|
||||
<br />
|
||||
<table>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
@@ -54,11 +59,13 @@
|
||||
var selectedAPs = document.getElementById("selectedAPs");
|
||||
var selectedClients = document.getElementById("selectedClients");
|
||||
var table = document.getElementsByTagName("table")[0];
|
||||
var ssidList = document.getElementsByTagName("table")[1];
|
||||
var resultInterval;
|
||||
var res;
|
||||
|
||||
function getResults(){
|
||||
getResponse("attackInfo.json",function(responseText){
|
||||
var res = JSON.parse(responseText);
|
||||
res = JSON.parse(responseText);
|
||||
var aps = "";
|
||||
var clients = "";
|
||||
var tr = "<tr><th>Attack</th><th>Status</th><th>Start/Stop</th></tr>";
|
||||
@@ -81,22 +88,45 @@
|
||||
tr += "</tr>";
|
||||
}
|
||||
table.innerHTML = tr;
|
||||
|
||||
var tr = "<tr><th>Name</th><th>X</th></tr>";
|
||||
for(var i=0;i<res.ssid.length;i++){
|
||||
tr += "<tr>";
|
||||
tr += "<td>"+res.ssid[i]+"</td>";
|
||||
tr += '<td><button class="marginNull warnBtn" onclick="deleteSSID('+i+')">x</button></td>';
|
||||
tr += "</tr>";
|
||||
}
|
||||
ssidList.innerHTML = tr;
|
||||
|
||||
},function(){
|
||||
clearInterval(resultInterval);
|
||||
alert("timeout error. Please reload the site");
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function startStop(num){
|
||||
getResponse("attackStart.json?num="+num,function(responseText){
|
||||
if(responseText == "true") {
|
||||
getResults();
|
||||
setTimeout(getResults,3000);
|
||||
}
|
||||
if(responseText == "true") getResults();
|
||||
else alert("error");
|
||||
});
|
||||
}
|
||||
|
||||
function addSSID(){
|
||||
if(res.ssid.length >= 64) alert("SSID list full :(");
|
||||
else{
|
||||
var _ssidName = prompt("new SSID:");
|
||||
if(_ssidName != null) getResponse("addSSID.json?name="+_ssidName,getResults);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteSSID(num){
|
||||
getResponse("deleteSSID.json?num="+num,getResults);
|
||||
}
|
||||
|
||||
function randomSSID(){
|
||||
getResponse("randomSSID.json",getResults);
|
||||
}
|
||||
|
||||
getResults();
|
||||
resultInterval = setInterval(getResults,3000);
|
||||
</script>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function getResponse(adr, callback, timeoutCallback = function(){alert("timeout error. Please reload the site");}, timeout = 5000){
|
||||
function getResponse(adr, callback, timeoutCallback = function(){location.reload()}, timeout = 5000){
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if(xmlhttp.readyState == 4){
|
||||
|
||||
@@ -121,6 +121,8 @@
|
||||
if(responseText == "true") getResults();
|
||||
else alert("error");
|
||||
toggleBtn(true);
|
||||
},function(){
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -62,13 +62,16 @@
|
||||
<p class="small">only for deauth attack - may cause instability!</p>
|
||||
<br />
|
||||
<br />
|
||||
<button onclick="saveSettings()">save</button><p class="small" id="saved"></p>
|
||||
<button class="warnBtn" onclick="resetSettings()">reset</button> <button onclick="saveSettings()">save</button><p class="small" id="saved"></p>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<p class="block bold">Client Names</p>
|
||||
<p class="block bold" id="clientNames">Client Names</p>
|
||||
<table id="nameList">
|
||||
<tr><th>MAC</th><th>Vendor</th><th>Name</th><th>X</th></tr>
|
||||
</table>
|
||||
<br />
|
||||
<button class="warnBtn" onclick="clearNameList()">clear</button></p>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
@@ -84,6 +87,7 @@
|
||||
var deauthReason = document.getElementById('deauthReason');
|
||||
var packetRate = document.getElementById('packetRate');
|
||||
var saved = document.getElementById('saved');
|
||||
var clientNames = document.getElementById('clientNames');
|
||||
var res;
|
||||
|
||||
function getData(){
|
||||
@@ -97,8 +101,9 @@
|
||||
deauthReason.value = res.deauthReason;
|
||||
packetRate.value = res.attackPacketRate;
|
||||
|
||||
var tr = '';
|
||||
if(res.nameList.length > 0) tr += '<tr><th>MAC</th><th>Vendor</th><th>Name</th><th>X</th></tr>';
|
||||
clientNames.innerHTML = "Client Names "+res.nameList.length+"/50";
|
||||
|
||||
var tr = '<tr><th>MAC</th><th>Vendor</th><th>Name</th><th>X</th></tr>';
|
||||
|
||||
for(var i=0;i<res.nameList.length;i++){
|
||||
|
||||
@@ -118,8 +123,8 @@
|
||||
function changeName(id){
|
||||
var newName = prompt("Name for "+res.nameList[id].mac);
|
||||
if(newName != null){
|
||||
getResponse("setName.json?id="+id+"&name="+newName,function(responseText){
|
||||
if(responseText == "true") getResults();
|
||||
getResponse("editNameList.json?id="+id+"&name="+newName,function(responseText){
|
||||
if(responseText == "true") getData();
|
||||
else alert("error");
|
||||
});
|
||||
}
|
||||
@@ -151,6 +156,23 @@
|
||||
});
|
||||
}
|
||||
|
||||
function resetSettings(){
|
||||
getResponse("settingsReset.json", function(responseText){
|
||||
if(responseText == "true"){
|
||||
getData();
|
||||
saved.innerHTML = "saved";
|
||||
}
|
||||
else alert("error");
|
||||
});
|
||||
}
|
||||
|
||||
function clearNameList(){
|
||||
getResponse("clearNameList.json", function(responseText){
|
||||
if(responseText == "true") getData();
|
||||
else alert("error");
|
||||
});
|
||||
}
|
||||
|
||||
getData();
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user