Skip to content

Commit

Permalink
Merge pull request #299 from bmorcelli/main
Browse files Browse the repository at this point in the history
NRF24 Dedicated Menu and 2,4Ghz Spectrum
  • Loading branch information
pr3y authored Oct 3, 2024
2 parents e0bcd29 + 3f66059 commit c3d4146
Show file tree
Hide file tree
Showing 15 changed files with 274 additions and 40 deletions.
3 changes: 3 additions & 0 deletions src/core/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ MainMenu::MainMenu() {
&rfidMenu,
&irMenu,
&fmMenu,
#if defined(USE_NRF24_VIA_SPI)
&nrf24Menu,
#endif
#if !defined(CORE) && !defined(CORE2)
&scriptsMenu,
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/core/main_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "menu_items/RFMenu.h"
#include "menu_items/WifiMenu.h"
#include "menu_items/ScriptsMenu.h"
#include "menu_items/NRF24.h"


class MainMenu {
Expand All @@ -27,6 +28,7 @@ class MainMenu {
RFMenu rfMenu;
WifiMenu wifiMenu;
ScriptsMenu scriptsMenu;
NRF24Menu nrf24Menu;

MainMenu();
~MainMenu();
Expand Down
5 changes: 1 addition & 4 deletions src/core/menu_items/BleMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "core/display.h"
#include "modules/ble/ble_spam.h"
#include "modules/ble/ble_common.h"
#include "modules/ble/ble_jammer.h"
#include "modules/NRF24/nrf_jammer.h"
#include "modules/ble/bad_ble.h"

void BleMenu::optionsMenu() {
Expand All @@ -22,9 +22,6 @@ void BleMenu::optionsMenu() {
#endif
#if defined(CARDPUTER)
options.push_back({"BLE Keyboard", [=]() { ble_keyboard(); }});
#endif
#if defined(USE_NRF24_VIA_SPI)
options.push_back({"NRF24 Jammer", [=]() { ble_jammer(); }});
#endif
options.push_back({"iOS Spam", [=]() { aj_adv(0); }});
options.push_back({"Windows Spam", [=]() { aj_adv(1); }});
Expand Down
4 changes: 3 additions & 1 deletion src/core/menu_items/IRMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ void IRMenu::optionsMenu() {
};

delay(200);
loopOptions(options,false,true,"Infrared");
String txt = "Infrared";
txt+=" Tx: " + String(IrTx) + " Rx: " + String(IrRx);
loopOptions(options,false,true,txt);
}

void IRMenu::configMenu() {
Expand Down
51 changes: 51 additions & 0 deletions src/core/menu_items/NRF24.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "NRF24.h"
#include "core/display.h"
#include "modules/NRF24/nrf_common.h"
#include "modules/NRF24/nrf_jammer.h"
#include "modules/NRF24/nrf_spectrum.h"

void NRF24Menu::optionsMenu() {
options.clear();
options.push_back({"Information", [=]() { nrf_info(); }});
#if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
options.push_back({"Spectrum", [=]() { nrf_spectrum(&CC_NRF_SPI); }});
#elif defined(CARDPUTER) || defined(ESP32S3DEVKITC1)
options.push_back({"Spectrum", [=]() { nrf_spectrum(&sdcardSPI); }});
#else
options.push_back({"Spectrum", [=]() { nrf_spectrum(&SPI); }});
#endif
options.push_back({"Jammer 2.4G", [=]() { nrf_jammer(); }});

options.push_back({"Main Menu", [=]() { backToMenu(); }});
delay(200);
loopOptions(options,false,true,"Bluetooth");
}

String NRF24Menu::getName() {
return _name;
}

void NRF24Menu::draw() {
// Blank
tft.fillRect(iconX,iconY,80,80,BGCOLOR);

// Case
tft.drawRect(0+iconX,40+iconY,60,40,FGCOLOR);
tft.fillRect(60+iconX,55+iconY,10,10,FGCOLOR);
//Antenna
tft.fillRoundRect(70+iconX,10+iconY,10,55,5,FGCOLOR);

//Chip connecto
tft.fillCircle(10+iconX, 48+iconY,3,FGCOLOR);
tft.fillCircle(10+iconX, 56+iconY,3,FGCOLOR);
tft.fillCircle(10+iconX, 64+iconY,3,FGCOLOR);
tft.fillCircle(10+iconX, 72+iconY,3,FGCOLOR);

tft.fillCircle(20+iconX, 48+iconY,3,FGCOLOR);
tft.fillCircle(20+iconX, 56+iconY,3,FGCOLOR);
tft.fillCircle(20+iconX, 64+iconY,3,FGCOLOR);
tft.fillCircle(20+iconX, 72+iconY,3,FGCOLOR);

//Chip
tft.fillRect(35+iconX,55+iconY,10,10,FGCOLOR);
}
17 changes: 17 additions & 0 deletions src/core/menu_items/NRF24.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef __NRF24_MENU_H__
#define __NRF24_MENU_H__

#include "MenuItemInterface.h"


class NRF24Menu : public MenuItemInterface {
public:
void optionsMenu(void);
void draw(void);
String getName(void);

private:
String _name = "NRF24";
};

#endif
7 changes: 6 additions & 1 deletion src/core/menu_items/RFIDMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ void RFIDMenu::optionsMenu() {
};

delay(200);
loopOptions(options,false,true,"RFID");

String txt = "RFID";
if(RfidModule==0) txt+=" (RFID2)";
else if(RfidModule==1) txt+=" (PN532-I2C)";
else if(RfidModule==2) txt+=" (PN532-SPI)";
loopOptions(options,false,true,txt);
}

void RFIDMenu::configMenu() {
Expand Down
6 changes: 5 additions & 1 deletion src/core/menu_items/RFMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ void RFMenu::optionsMenu() {
};

delay(200);
loopOptions(options,false,true,"Radio Frequency");
String txt = "Radio Frequency";
if(RfModule) txt+=" (CC1101)"; // Indicates if CC1101 is connected
else txt+=" Tx: " + String(RfTx) + " Rx: " + String(RfRx);

loopOptions(options,false,true,txt);
}

void RFMenu::configMenu() {
Expand Down
5 changes: 1 addition & 4 deletions src/core/menu_items/WifiMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "modules/wifi/sniffer.h"
#include "modules/wifi/wardriving.h"
#include "modules/wifi/wifi_atks.h"
#include "modules/ble/ble_jammer.h"
#include "modules/NRF24/nrf_jammer.h"

#ifndef LITE_VERSION
#include "modules/pwnagotchi/pwnagotchi.h"
Expand Down Expand Up @@ -39,9 +39,6 @@ void WifiMenu::optionsMenu() {
#ifndef LITE_VERSION
options.push_back({"Wireguard", [=]() { wg_setup(); }});
options.push_back({"Pwnagotchi", [=]() { pwnagotchi_start(); }});
#endif
#if defined(USE_NRF24_VIA_SPI)
options.push_back({"NRF24 Jammer", [=]() { ble_jammer(); }});
#endif
options.push_back({"Main Menu", [=]() { backToMenu(); }});

Expand Down
55 changes: 55 additions & 0 deletions src/modules/NRF24/nrf_common.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#include "nrf_common.h"
#include "../../core/mykeyboard.h"

RF24 NRFradio(NRF24_CE_PIN, NRF24_SS_PIN);

void nrf_info() {
tft.fillScreen(BGCOLOR);
tft.setTextSize(FM);
tft.setTextColor(TFT_RED, BGCOLOR);
tft.drawCentreString("_Disclaimer_",WIDTH/2,10,1);
tft.setTextColor(TFT_WHITE, BGCOLOR);
tft.setTextSize(FP);
tft.setCursor(15,33);
tft.println("These functions were made to be used in a controlled environment for STUDY only.");
tft.println("\nDO NOT use these functions to harm people or companies, you can go to jail!");
tft.setTextColor(FGCOLOR, BGCOLOR);
tft.println("\nThis device is VERY sensible to noise, so long wires or passing near VCC line can make things go wrong.");
delay(1000);
while(!checkAnyKeyPress());
}

bool nrf_start() {
#if defined(USE_NRF24_VIA_SPI)
pinMode(NRF24_SS_PIN, OUTPUT);
digitalWrite(NRF24_SS_PIN, HIGH);
pinMode(NRF24_CE_PIN, OUTPUT);
digitalWrite(NRF24_CE_PIN, LOW);

#if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
CC_NRF_SPI.begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN,NRF24_SS_PIN);
#elif defined(CARDPUTER) || defined(ESP32S3DEVKITC1)
sdcardSPI.begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN,NRF24_SS_PIN);
#else
SPI.begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN,NRF24_SS_PIN);
#endif

#if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
if(NRFradio.begin(&CC_NRF_SPI))
#elif defined(CARDPUTER) || defined(ESP32S3DEVKITC1)
if(NRFradio.begin(&sdcardSPI))
#else
if(NRFradio.begin(&SPI))
#endif
{
return true;
}
else
return false;



#else // NRF24 not set in platfrmio.ini
return false;
#endif
}
16 changes: 16 additions & 0 deletions src/modules/NRF24/nrf_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <RF24.h>
#include "../../core/globals.h"

//Define the Macros case it hasn't been declared
#ifndef NRF24_CE_PIN
#define NRF24_CE_PIN -1
#endif
#ifndef NRF24_SS_PIN
#define NRF24_SS_PIN -1
#endif

extern RF24 NRFradio;

bool nrf_start();

void nrf_info();
41 changes: 13 additions & 28 deletions src/modules/ble/ble_jammer.cpp → src/modules/NRF24/nrf_jammer.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
#include "ble_jammer.h"
#include "nrf_common.h"
#include "nrf_jammer.h"
#include "core/globals.h"
#include "core/mykeyboard.h"
#include "core/display.h"


/* **************************************************************************************
** name : ble_jammer
** name : nrf_jammer
** details : Starts 2.4Gz jammer usinf NRF24
************************************************************************************** */
void ble_jammer() {
#if defined(USE_NRF24_VIA_SPI)
#if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
CC_NRF_SPI.begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN,NRF24_SS_PIN);
#elif defined(CARDPUTER) || defined(ESP32S3DEVKITC1)
sdcardSPI.begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN,NRF24_SS_PIN);
#else
SPI.begin(NRF24_SCK_PIN,NRF24_MISO_PIN,NRF24_MOSI_PIN,NRF24_SS_PIN);
#endif

void nrf_jammer() {
#if defined(NRF24_CE_PIN) && defined(NRF24_SS_PIN) && defined(USE_NRF24_VIA_SPI)
RF24 radio(NRF24_CE_PIN, NRF24_SS_PIN); ///ce-csn
byte hopping_channel[] = {32,34, 46,48, 50, 52, 0, 1, 2, 4, 6, 8, 22, 24, 26, 28, 30, 74, 76, 78, 80, 82, 84,86 }; // channel to hop
byte ptr_hop = 0; // Pointer to the hopping array
#if defined(STICK_C_PLUS) || defined(STICK_C_PLUS2)
if(radio.begin(&CC_NRF_SPI))
#elif defined(CARDPUTER) || defined(ESP32S3DEVKITC1)
if(radio.begin(&sdcardSPI))
#else
if(radio.begin(&SPI))
#endif
if(nrf_start())
{
Serial.println("NRF24 turned On");

radio.setPALevel(RF24_PA_MAX);
radio.startConstCarrier(RF24_PA_MAX, 45);
radio.setAddressWidth(3);//optional
radio.setPayloadSize(2);//optional
if(!radio.setDataRate(RF24_2MBPS)) Serial.println("Fail setting data Rate");
NRFradio.setPALevel(RF24_PA_MAX);
NRFradio.startConstCarrier(RF24_PA_MAX, 45);
NRFradio.setAddressWidth(3);//optional
NRFradio.setPayloadSize(2);//optional
if(!NRFradio.setDataRate(RF24_2MBPS)) Serial.println("Fail setting data Rate");

drawMainBorder();
tft.setCursor(10,28);
Expand All @@ -48,14 +34,13 @@ void ble_jammer() {
while(!checkSelPress()) {
ptr_hop++; /// perform next channel change
if (ptr_hop >= sizeof(hopping_channel)) ptr_hop = 0; // To avoid array indexing overflow
radio.setChannel(hopping_channel[ptr_hop]); // Change channel
NRFradio.setChannel(hopping_channel[ptr_hop]); // Change channel
}
radio.powerDown();
NRFradio.powerDown();
} else {
Serial.println("Fail Starting radio");
displayError("NRF24 not found");
delay(500);
while(!checkAnyKeyPress()); // wait confirmation
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Credits: @smoochiee https://github.com/smoochiee/Ble-jammer
*/


void ble_jammer();
void nrf_jammer();
Loading

0 comments on commit c3d4146

Please sign in to comment.