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

Commit

Permalink
Merge pull request #37 from Pwnagotchi-Unofficial/development
Browse files Browse the repository at this point in the history
1.0.0 merge
  • Loading branch information
dj1ch authored Nov 26, 2023
2 parents d2b62d1 + 644c322 commit 5a95b61
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 143 deletions.
23 changes: 12 additions & 11 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
Here you can find out how to install minigotchi on the esp8266, or the raspberry pi pico. The esp8266 microcontroller has more support than the pico at the moment. They can be both built using arduino, ~~but you can build manually with the pico, assuming that you have all the libraries from the arduino esp8266 repo. Again, building with Arduino IDE is an option for the raspberry pi pico.~~ The support for this has been dropped, as this is not maintained nor tested by me.
#### Building using Arduino IDE
I believe that you can also use the raspberry pi pico and run arduino .ino files. It would be much easier to do this then to build it yourself manually.
- Download the latest release [here](https://github.com/Pwnagotchi-Unofficial/minigotchi/releases)
- Go to your arduino folder (on linux, it should be `~/Arduino`)
- Create a folder called `minigotchi`
- Copy and paste all the files from the release into the folder `~/Arduino/minigotchi`
- Open the arduino IDE in that directory (right clicking the .ino file and opening it with the IDE)
- It should prompt you to create a new folder called minigotchi, listen to what it tells you to do.
- Add additional .h files if needed, make sure you install all the dependancies
- From here you can select the board, and then you can run it on the board. Make sure you add the esp8266 libraries, which are on the arduino repo I put [at the bottom here](README.md)
- You first verify, then upload the files to the board using the IDE. The IDE should let you know when it's done programming the board. You can then go to the serial monitor and the board should be giving output, in this case it is showing the packets being sent.
- Note that the pwnagotchi will not notice these packets, yet.
- You can however, notice if a pwnagotchi is nearby, using the ability to read the packets being sent
- Download the latest release [here](https://github.com/Pwnagotchi-Unofficial/minigotchi/releases).
- Unzip the file
- Navigate to the `minigotchi.ino` file in the unzipped folder, and open it up
- At the line that says `raw.init("bssid of ap you will listen on", channel number); // set the settings here, ("BSSID", channel)`, replace the `"bssid of ap you will listen on"` with your actual BSSID(in the quotations), and the `channel` with the channel you prefer(not in quotations).
- Save and exit the file.
- Right click on the folder(should be called minigotchi) then archive it, making it back into a zip file. If you need to rename it, rename it
- Go to the [arduino web editor](create.arduino.cc/editor), then sign in/create an account
- Import the zip file by clicking the button that looks like an upload button, then selecting the minigotchi zip file that you edited
- Select the board as `ESP8266 WEMOS(LOLIN) D1 mini Lite`, and select the port it is plugged into(if you haven't already, plug in the board)
- Click on the upload button(arrow pointing to the left).
- You can click on the monitor button on the sidebar to see the serial monitor. Make sure the baud rate is `115200`.
- Happy hacking!
####
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### an even smaller pwnagotchi.
###
### Note that this project is undergoing a major rewrite in the code and the structure of everything(see development branch)
It will take a really long time to get a fully stable and working release! You can watch this repository and see the activity on this repository. I got several issues to sort out, including the packet sending and the pwnagotchi detection system. If you want to help, feel free to fork and make a couple changes to my code.
###
#### Intro
Overall, this project started as a thought. A pwnagotchi on an even smaller board, in this case an esp8266. Crazy, right? Anyway, this project may make it a little bit more possible. Instead of pwning networks, it will be a friend to a local pwnagotchi(Most likely one of yours), along with deauthing random networks if the esp8266 is in the vicinity of any.
Expand All @@ -19,8 +20,9 @@ The install guide is [here](INSTALL.md), now that I have put out releases.
- Go (maybe)
####
#### Prerequisites
- An IDE (most likely the arduino ide or thonny on the raspberry pi pico)
- Hardware(esp8266 microcontroller or raspberry pi pico with esp8266 wifi module)
- An IDE (most likely the arduino ide)
- Hardware(esp8266 microcontroller)
- A reliable and appropriate power source and supply for the hardware
- Patience (a lot of it)
#### How it operates/works
The minigotchi relies on the IDE/serial shell for communication through logs. It will send raw frames to associate to an access point, and will advertise itself on a network like a pwnagotchi, or perhaps interact with the local pwngrid server that the pwnagotchi is running.
Expand All @@ -31,6 +33,8 @@ We have dropped support for the pico, as it turns out, the esp8266 is a microcon
- Hardware is here(the esp8266):

https://www.amazon.com/QCCAN-Internet-ESP8266-Compatible-MicroPython/dp

Keep in mind it comes with two of them. It's best to keep one extra in case a board gets burnt out and/or lost. I don't think I can find a singular one. I believe this is a clone, so be sure to set this as the clone in the Arduino IDE board manager.
####
#### To do
- screen support?
Expand Down
75 changes: 28 additions & 47 deletions minigotchi/deauth.cpp
Original file line number Diff line number Diff line change
@@ -1,60 +1,41 @@
// deauth.cpp: handles the deauth of a local ap
// minigotchi.ino: everything implemented here

#include "pwnagotchi.h"
#include "deauth.h"
#include "packet.h"

void DeauthAttack::addToWhitelist(const char* bssid) {
whitelist.push_back(bssid);
}

void DeauthAttack::selectRandomAP() {
int apCount = WiFi.scanNetworks();

if (apCount > 0) {
int randomIndex = random(apCount);
randomAP = WiFi.SSID(randomIndex);
Pwnagotchi pwnagotchi;
PacketSender packetSender;
DeauthAttack deauthAttack;

// check for ap in whitelist
if (std::find(whitelist.begin(), whitelist.end(), randomAP) != whitelist.end()) {
Serial.println("Selected AP is in the whitelist. Skipping deauthentication.");
return;
}
void setup() {
Serial.begin(115200);
deauthAttack.addToWhitelist("SSID");
Serial.println();

Serial.print("Selected random AP: ");
Serial.println(randomAP);
Serial.println("Formatting SPIFFS. This may take a while...");
if (SPIFFS.format()) {
Serial.println("SPIFFS formatted successfully.");
} else {
Serial.println("No access points found.");
Serial.println("Failed to format SPIFFS.");
}
}

void DeauthAttack::startRandomDeauth() {
if (randomAP.length() > 0) {
Serial.println("Starting deauthentication attack on the selected AP...");
// define the attack
if (!running) {
// Deauth, beacon, deauth all stations, probe, output, timeout
start(true, false, false, false, true, 0);
} else {
Serial.println("Attack is already running.");
}
} else {
Serial.println("No access point selected. Use selectRandomAP() first.");
}
}

void DeauthAttack::start(bool param1, bool param2, bool param3, bool param4, bool param5, int param6) {
running = true;
void loop() {
// get local payload from local pwnagotchi
pwnagotchi.detectPwnagotchi();
delay(5000);

// make the deauth frame
String reasonCode = "3"; // means "Deauthenticated because sending STA is leaving (or has left) BSS"
String deauthPacket = "c0:ff:ee:c0:ff:ee" + randomAP + reasonCode;
uint8_t* deauthPacketBytes = (uint8_t*)deauthPacket.c_str();
int packetSize = deauthPacket.length();

// send the deauth 10 times
for (int i = 0; i < 10; ++i) {
wifi_send_pkt_freedom(deauthPacketBytes, packetSize, 0);
delay(100);
// send payload
if (SPIFFS.begin()) {
packetSender.sendJsonPayloadFromFile("packet.json");
} else {
Serial.println("Failed to mount file, does the file exist?");
delay(5000);
}

running = false;
// deauth a random ap
deauthAttack.selectRandomAP();
deauthAttack.startRandomDeauth();
delay(5000);
}
34 changes: 24 additions & 10 deletions minigotchi/minigotchi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,47 @@
#include "pwnagotchi.h"
#include "deauth.h"
#include "packet.h"
#include "raw80211.h"

Pwnagotchi pwnagotchi;
PacketSender packetSender;
DeauthAttack deauthAttack;
Raw80211 raw;

void setup() {
Serial.begin(115200); // this is the rate for the serial monitor
deauthAttack.addToWhitelist("SSID"); // set your ssid you want to use
if (SPIFFS.begin()) {
// Use the appropriate file path
packetSender.sendJsonPayloadFromFile("/packet.json");
} else {
Serial.println("Failed to mount file, does the file exist?");
}
Serial.begin(115200);
Serial.println(" ");
Serial.println("Hi, I'm Minigotchi, your pwnagotchi's best friend!");
Serial.println(" ");
Serial.println("You can edit my whitelist in the minigotchi.ino, and you can also edit the json parameters in the packet.cpp");
Serial.println(" ");
Serial.println("Starting now...");
deauthAttack.addToWhitelist("SSID"); // add your ssid(s) here
deauthAttack.addToWhitelist("ANOTHER_SSID");
raw.init("bssid of ap you will listen on", channel number); // set the settings here, ("BSSID", channel)
raw.start();
delay(15000);
Serial.println(" ");
Serial.println("Started successfully!");
}

void loop() {
// get local payload from local pwnagotchi
pwnagotchi.detectPwnagotchi("de:ad:be:ef:de:ad");
pwnagotchi.detectAndHandlePwnagotchi();
delay(5000);

// stop for deauthing and payload
raw.stop();

// send payload
packetSender.sendJsonPayloadFromFile("/packet.json");
packetSender.sendJsonPayload();
delay(5000);

// deauth a random ap
deauthAttack.selectRandomAP();
deauthAttack.startRandomDeauth();
delay(5000);

// restart the process
raw.start();
}
75 changes: 56 additions & 19 deletions minigotchi/packet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,63 @@

#include "packet.h"
#include "raw80211.h"
#include <ArduinoJson.h>

void PacketSender::sendJsonPayloadFromFile(const char* filePath) {
File configFile = SPIFFS.open(filePath, "r");
if (configFile) {
size_t size = configFile.size();
std::unique_ptr<char[]> buf(new char[size]);
configFile.readBytes(buf.get(), size);
configFile.close();

DynamicJsonDocument doc(1024);
deserializeJson(doc, buf.get());

// make json string
String jsonString;
serializeJson(doc, jsonString);

// send payload
Raw80211::send(reinterpret_cast<const uint8_t*>(jsonString.c_str()), jsonString.length());
// set magic number(222 in hex)
const uint8_t MAGIC_NUMBER = 0xDE;

void PacketSender::sendJsonPayload() {

// json object creation
DynamicJsonDocument doc(1024);

// all settings
doc["epoch"] = 1;
doc["face"] = "(◕‿‿◕)";
doc["identity"] = "b9210077f7c14c0651aa338c55e820e93f90110ef679648001b1cecdbffc0090";
doc["name"] = "minigotchi";

JsonObject policy = doc.createNestedObject("policy");
policy["advertise"] = true;
policy["ap_ttl"] = 0;
policy["associate"] = true;
policy["bored_num_epochs"] = 0;

JsonArray channels = policy.createNestedArray("channels");
channels.add(1);
channels.add(3);
channels.add(4);
channels.add(5);
channels.add(6);

policy["deauth"] = true;
policy["excited_num_epochs"] = 1;
policy["hop_recon_time"] = 1;
policy["max_inactive_scale"] = 0;
policy["max_interactions"] = 1;
policy["max_misses_for_recon"] = 1;
policy["min_recon_time"] = 1;
policy["min_rssi"] = 1;
policy["recon_inactive_multiplier"] = 1;
policy["recon_time"] = 1;
policy["sad_num_epochs"] = 1;
policy["sta_ttl"] = 0;

doc["pwnd_run"] = 0;
doc["pwnd_tot"] = 0;
doc["session_id"] = "84:f3:eb:58:95:bd";
doc["uptime"] = 1;
doc["version"] = "v1.0.0";

String jsonString;
if (serializeJson(doc, jsonString) == 0) {
// handle errors here
Serial.println("Failed to serialize JSON");
} else {
Serial.println("Failed to open JSON file for reading");
// put number in payload
Raw80211::send(&MAGIC_NUMBER, sizeof(MAGIC_NUMBER));
Raw80211::send(reinterpret_cast<const uint8_t*>(jsonString.c_str()), jsonString.length());

Serial.println("Sent payload!");
}
}

3 changes: 1 addition & 2 deletions minigotchi/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
#define PACKET_H

#include <Arduino.h>
#include <FS.h>
#include "raw80211.h"
#include <ArduinoJson.h>

class PacketSender {
public:
void sendJsonPayloadFromFile(const char* filePath);
void sendJsonPayload();
};

#endif // PACKET_H
31 changes: 0 additions & 31 deletions minigotchi/packet.json

This file was deleted.

Loading

0 comments on commit 5a95b61

Please sign in to comment.