Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Restyled fix whitelist #187

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions minigotchi/channel.h.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* channel.h: header files for channel.cpp
*/

#ifndef CHANNEL_H
#define CHANNEL_H

#include "config.h"
#include "minigotchi.h"
#include "mood.h"
#include <ESP8266WiFi.h>

class Mood;

class Channel {
public:
static void init(int initChannel);
static void cycle();
static void switchChannel(int newChannel);
static int getChannel();
static void checkChannel(int channel);
static bool isValidChannel(int channel);
static int channelList[13]; // 13 channels

private:
static Mood &mood;
static int randomIndex;
static int numChannels;
static int currentChannel;
static int newChannel;
};

#endif // CHANNEL_H
168 changes: 168 additions & 0 deletions minigotchi/config.cpp.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/**
* config.cpp: configuration for minigotchi
*/

#include "config.h"

/** developer note:
*
* this is the very equivalent of the 'config.toml' for the pwnagotchi
* variables are defined here which will be used by the minigotchi
* whatever can be disabled/enabled can be enabled here
*
*/

// define if features will be used
bool Config::deauth = true;
bool Config::advertise = true;
bool Config::scan = true;

// define access point ssid and password
const char *Config::ssid = "minigotchi";
const char *Config::pass = "dj1ch-minigotchi";

// define universal delays
int Config::shortDelay = 500;
int Config::longDelay = 5000;

// Defines if this is running in parasite mode where it hooks up directly to a
// Pwnagotchi
bool Config::parasite = false;

// screen configuration
bool Config::display = false;
std::string Config::screen = "";

// define baud rate
int Config::baud = 115200;

// define init channel
int Config::channel = 1;

// define whitelist
std::vector<std::string> Config::whitelist = {"SSID", "SSID", "SSID"};

// define faces
String Config::happy = "(^-^)";
String Config::sad = "(;-;)";
String Config::broken = "(X-X)";
String Config::intense = "(>-<)";
String Config::looking1 = "(0-o)";
String Config::looking2 = "(o-0)";
String Config::neutral = "('-')";
String Config::sleeping = "(-.-)";

// json config
int Config::epoch = Minigotchi::currentEpoch;
std::string Config::face = "(^-^)";
std::string Config::identity =
"b9210077f7c14c0651aa338c55e820e93f90110ef679648001b1cecdbffc0090";
std::string Config::name = "minigotchi";
std::string Config::grid_version = "1.11.1";
int Config::ap_ttl = Config::random(30, 600);
bool Config::associate = true;
int Config::bored_num_epochs = Config::random(5, 30);

// define channels
int Config::channels[13] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

// see https://github.com/evilsocket/pwnagotchi/blob/master/pwnagotchi/ai/gym.py
int Config::excited_num_epochs = Config::random(5, 30);
int Config::hop_recon_time = Config::random(5, 60);
int Config::max_inactive_scale = Config::random(3, 10);
int Config::max_interactions = Config::random(1, 25);
int Config::max_misses_for_recon = Config::random(3, 10);
int Config::min_recon_time = Config::random(1, 30);
int Config::min_rssi = Config::random(-200, -50);
int Config::recon_inactive_multiplier = Config::random(1, 3);
int Config::recon_time = Config::random(5, 60);
int Config::sad_num_epochs = Config::random(5, 30);
int Config::sta_ttl = Config::random(60, 300);
int Config::pwnd_run = 0;
int Config::pwnd_tot = 0;
std::string Config::session_id = "84:f3:eb:58:95:bd";
int Config::uptime = Config::time();

// define version(please do not change, this should not be changed)
std::string Config::version = "3.3.2-beta";

// configured flag which only the WebUI changes
bool Config::configured = false;

/**
* Erases EEPROM
*/
void Config::clearConfig() {
EEPROM.begin(512);

// write zeroes
for (int i = 0; i < 512; i++) {
EEPROM.write(i, 0);
}

// write
EEPROM.commit();
EEPROM.end();
}

/**
* Loads configuration values from EEPROM
*/
void Config::loadConfig() {
EEPROM.begin(512); // 512 bytes for EEPROM

// load Config::configured
Config::configured = EEPROM.read(0) == 1;

// load Config::whitelist
for (int i = 0; i < 10; ++i) {
char ssid[33] = {0};
for (int j = 0; j < 32; ++j) {
ssid[j] = EEPROM.read(1 + i * 32 + j);
}
if (ssid[0] != '\0') {
whitelist.push_back(ssid);
}
}
EEPROM.end();
}

/**
* Saves configuration to EEPROM
*/
void Config::saveConfig() {
EEPROM.begin(512);

// save Config::configured
EEPROM.write(0, Config::configured ? 1 : 0);

// save Config::whitelist
for (int i = 0; i < 10; ++i) {
if (i < whitelist.size()) {
const char *ssid = whitelist[i].c_str();
for (int j = 0; j < 32; ++j) {
EEPROM.write(1 + i * 32 + j, ssid[j]);
}
} else {
for (int j = 0; j < 32; ++j) {
EEPROM.write(1 + i * 32 + j, 0);
}
}
}
EEPROM.commit();
EEPROM.end();
}

/** developer note:
*
* these are meant to provide valid values for the frame's data to be almost
* identical to a pwnagotchi's. they must be within a certain range to be valid.
*
*/

// randomize config values
int Config::random(int min, int max) { return min + rand() % (max - min + 1); }

int Config::time() {
return millis() / 1000; // convert to seconds
}
75 changes: 75 additions & 0 deletions minigotchi/config.h.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* config.h: header files for config.cpp
*/

#ifndef CONFIG_H
#define CONFIG_H

#include "minigotchi.h"
#include <Arduino.h>
#include <EEPROM.h>
#include <iostream>
#include <random>
#include <string>
#include <vector>

class Config {
public:
static bool deauth;
static bool advertise;
static bool scan;
static const char *ssid;
static const char *pass;
static int shortDelay;
static int longDelay;
static bool parasite;
static bool display;
static std::string screen;
static int baud;
static int channel;
static std::vector<std::string> whitelist;
static String happy;
static String sad;
static String broken;
static String intense;
static String looking1;
static String looking2;
static String neutral;
static String sleeping;
static int epoch;
static std::string grid_version;
static std::string face;
static std::string identity;
static std::string name;
static int ap_ttl;
static bool associate;
static int bored_num_epochs;
static int channels[13];
static int excited_num_epochs;
static int hop_recon_time;
static int max_inactive_scale;
static int max_interactions;
static int max_misses_for_recon;
static int min_recon_time;
static int min_rssi;
static int recon_inactive_multiplier;
static int recon_time;
static int sad_num_epochs;
static int sta_ttl;
static int pwnd_run;
static int pwnd_tot;
static std::string session_id;
static int timestamp;
static int uptime;
static std::string version;
static bool configured;
static void clearConfig();
static void loadConfig();
static void saveConfig();

private:
static int random(int min, int max);
static int time();
};

#endif // CONFIG_H
47 changes: 47 additions & 0 deletions minigotchi/deauth.h.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* deauth.h: header files for deauth.cpp
*/

#ifndef DEAUTH_H
#define DEAUTH_H

#include "config.h"
#include "minigotchi.h"
#include "mood.h"
#include "parasite.h"
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>

class Mood;

class Deauth {
public:
static void deauth();
static void list();
static void add(const std::string &bssids);
static uint8_t deauthTemp[26];
static uint8_t deauthFrame[26];
static uint8_t disassociateFrame[26];
static uint8_t broadcastAddr[6];
static int randomIndex;

private:
static Mood &mood;
static bool send(uint8_t *buf, uint16_t len, bool sys_seq);
static bool broadcast(uint8_t *mac);
static String printHidden(int network);
static void printMac(uint8_t *mac);
static String printMacStr(uint8_t *mac);
static bool select();
static void start();
static uint8_t bssid[6];
static bool running;
static std::vector<String> whitelist;
static String randomAP;
};

#endif // DEAUTH_H
52 changes: 52 additions & 0 deletions minigotchi/frame.h.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* frame.h: header files for frame.cpp
*/

#ifndef FRAME_H
#define FRAME_H

#include "channel.h"
#include "config.h"
#include "display.h"
#include "minigotchi.h"
#include "mood.h"
#include "parasite.h"
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <sstream>
#include <string>
#include <vector>

class Mood;

class Frame {
public:
~Frame();

static uint8_t *pack();
static bool send();
static void advertise();
static const uint8_t header[];
static const uint8_t IDWhisperPayload;
static const uint8_t IDWhisperCompression;
static const uint8_t IDWhisperIdentity;
static const uint8_t IDWhisperSignature;
static const uint8_t IDWhisperStreamHeader;
static const uint8_t SignatureAddr[];
static const uint8_t BroadcastAddr[];
static const uint16_t wpaFlags;

static const int pwngridHeaderLength;
static size_t essidLength;
static uint8_t headerLength;

static size_t payloadSize;
static const size_t chunkSize;

static bool sent;

private:
static Mood &mood;
};

#endif // FRAME_H
Loading