Skip to content

Commit

Permalink
EEPROM save fix and Custom IR revamp
Browse files Browse the repository at this point in the history
* Changelog 1.2.1:
    * Fixed EEPROM save
    * Fixed Custom IR commands
    * Added IR to the main menu
    * Added Pause on IR Custom Spam
  • Loading branch information
bmorcelli committed Jul 25, 2024
1 parent 943ae17 commit a9dafba
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 39 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ For more information on each function supported by Bruce, [read our wiki here](h
## RFID
- [x] Read and Write - @incursiohack

## Others
## IR
- [x] TV-B-Gone
- [x] Custom IR (NEC, NEC42, NECExt, SIRC, SIRC15, SIRC20, Samsung32, RC5, RC5X, RC6)

## Others
- [x] SD Card Mngr (New)
- [x] SPIFFS Mngr (New)
- [x] WebUI (New)
Expand All @@ -82,7 +85,6 @@ For more information on each function supported by Bruce, [read our wiki here](h
- [x] SDCard Mngr
- [x] Spiffs Mngr
- [x] Megalodon (New)
- [x] Custom IR (New, SPIFFS and SDCard)
- [x] BADUsb (New features, SPIFFS and SDCard)
- [X] Openhaystack

Expand All @@ -101,3 +103,10 @@ For more information on each function supported by Bruce, [read our wiki here](h
# Disclaimer

Bruce is a tool for cyber offensive and red team operations, distributed under the terms of the Affero General Public License (AGPL). It is intended for legal and authorized security testing purposes only. Use of this software for any malicious or unauthorized activities is strictly prohibited. By downloading, installing, or using Bruce, you agree to comply with all applicable laws and regulations. This software is provided free of charge, and we do not accept payments for copies or modifications. The developers of Bruce assume no liability for any misuse of the software. Use at your own risk.

# Changelog
* 1.2.1:
* Fixed EEPROM save
* Fixed Custom IR commands
* Added IR to the main menu
* Added Pause on IR Custom Spam
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ default_envs =

[common]
build_flags =
-DBRUCE_VERSION='"1.2.0"'
-DBRUCE_VERSION='"1.2.1"'
-DMAXFILES=256
-DEEPROMSIZE=128
-DLH=8
Expand Down
14 changes: 13 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,18 @@ void load_eeprom() {
tmz = EEPROM.read(10);
FGCOLOR = EEPROM.read(11) << 8 | EEPROM.read(12);

//log_i("EEPROM 0=%d, 1=%s, 2=%d, 6=%d, 7=%d, 8=%d, 9=%d, 10=%d, 11-12=%d", rotation, dimmerSet, bright,IrTx, IrRx, RfTx, RfRx, tmz, FGCOLOR);
log_i("\
\n*-*EEPROM Settings*-* \
\n- rotation =%03d, \
\n- dimmerSet =%03d, \
\n- Brightness=%03d, \
\n- IR Tx Pin =%03d, \
\n- IR Rx Pin =%03d, \
\n- RF Tx Pin =%03d, \
\n- RF Rx Pin =%03d, \
\n- Time Zone =%03d, \
\n- FGColor =0x%04X \
\n*-*-*-*-*-*-*-*-*-*-*", rotation, dimmerSet, bright,IrTx, IrRx, RfTx, RfRx, tmz, FGCOLOR);
if (rotation>3 || dimmerSet>60 || bright>100 || IrTx>100 || IrRx>100 || RfRx>100 || RfTx>100 || tmz>24) {
rotation = ROTATION;
dimmerSet=10;
Expand All @@ -161,6 +172,7 @@ void load_eeprom() {
RfTx=GROVE_SDA;
RfRx=GROVE_SCL;
FGCOLOR=0xA80F;
tmz=0;

EEPROM.write(0, rotation);
EEPROM.write(1, dimmerSet);
Expand Down
96 changes: 62 additions & 34 deletions src/modules/others/TV-B-Gone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ By Anton Grimpelhuber ([email protected])
#define NOPP __asm__ __volatile__ ("nop")

// Not used any more on esp8266, so don't bother
// Tweak this if neccessary to change timing
// Tweak this if cessary to change timing
// -for 8MHz Arduinos, a good starting value is 11
// -for 16MHz Arduinos, a good starting value is 25
#define DELAY_CNT 25
Expand Down Expand Up @@ -159,7 +159,7 @@ void StartTvBGone() {
while (checkSelPress()) yield();
displayRedStripe("Paused", TFT_WHITE, BGCOLOR);

while (!checkSelPress()){ // Se apertar Select denovo, continua
while (!checkSelPress()){ // If Presses Select again, continues
if(checkEscPress()) {
endingEarly= true;
break;
Expand All @@ -168,7 +168,7 @@ void StartTvBGone() {
while (checkSelPress()){
yield();
}
if (endingEarly) break; // Cancela o TV-B-Gone
if (endingEarly) break; // Cancels TV-B-Gone
displayRedStripe("Running, Wait", TFT_WHITE, FGCOLOR);
}

Expand Down Expand Up @@ -285,9 +285,9 @@ void otherIRcodes() {
bool exit = false;
for(int i=0; i<=total_codes; i++) {
if(codes[i].type=="raw") options.push_back({ codes[i].name.c_str(), [=](){ sendRawCommand(codes[i].frequency, codes[i].data); }});
if(codes[i].protocol=="NECext") options.push_back({ codes[i].name.c_str(), [=](){ sendNECextCommand(codes[i].address, codes[i].command); }});
if(codes[i].protocol=="NEC") options.push_back({ codes[i].name.c_str(), [=](){ sendNECCommand(codes[i].address, codes[i].command); }});
if(codes[i].protocol=="RC5") options.push_back({ codes[i].name.c_str(), [=](){ sendRC5Command(codes[i].address, codes[i].command); }});
if(codes[i].protocol.startsWith("NEC")) options.push_back({ codes[i].name.c_str(), [=](){ sendNECCommand(codes[i].address, codes[i].command); }});
if(codes[i].protocol.startsWith("RC5")) options.push_back({ codes[i].name.c_str(), [=](){ sendRC5Command(codes[i].address, codes[i].command); }});
if(codes[i].protocol.startsWith("RC6")) options.push_back({ codes[i].name.c_str(), [=](){ sendRC6Command(codes[i].address, codes[i].command); }});
if(codes[i].protocol.startsWith("Samsung")) options.push_back({ codes[i].name.c_str(), [=](){ sendSamsungCommand(codes[i].address, codes[i].command); }});
if(codes[i].protocol=="SIRC") options.push_back({ codes[i].name.c_str(), [=](){ sendSonyCommand(codes[i].address, codes[i].command); }});
}
Expand All @@ -305,7 +305,7 @@ void otherIRcodes() {


else { // SPAM all codes of the file

bool endingEarly;
int codes_sent=0;
int frequency = 0;
String rawData = "";
Expand Down Expand Up @@ -375,12 +375,12 @@ void otherIRcodes() {
command.trim();
Serial.println("Command: "+command);
} else if (line.indexOf("#") != -1) {
if (protocol == "NECext") {
sendNECextCommand(address, command);
} else if (protocol == "NEC") {
if (protocol.startsWith("NEC")) {
sendNECCommand(address, command);
} else if (protocol == "RC5") {
} else if (protocol.startsWith("RC5")) {
sendRC5Command(address, command);
} else if (protocol.startsWith("RC6")) {
sendRC6Command(address, command);
} else if (protocol.startsWith("Samsung")) {
sendSamsungCommand(address, command);
} else if (protocol.startsWith("SIRC")) {
Expand All @@ -396,6 +396,24 @@ void otherIRcodes() {
}
}
}
// if user is pushing (holding down) TRIGGER button, stop transmission early
if (checkSelPress()) // Pause TV-B-Gone
{
while (checkSelPress()) yield();
displayRedStripe("Paused", TFT_WHITE, BGCOLOR);

while (!checkSelPress()){ // If Presses Select again, continues
if(checkEscPress()) {
endingEarly= true;
break;
}
}
while (checkSelPress()){
yield();
}
if (endingEarly) break; // Cancels custom IR Spam
displayRedStripe("Running, Wait", TFT_WHITE, FGCOLOR);
}

}
databaseFile.close();
Expand All @@ -408,12 +426,9 @@ void otherIRcodes() {

//IR commands
void sendNECCommand(String address, String command) {
IRsend irsend(IrTx,true); // Set the GPIO to be used to sending the message.
IRsend irsend(IrTx); // Set the GPIO to be used to sending the message.
irsend.begin();
displayRedStripe("Sending..",TFT_WHITE,FGCOLOR);
//uint32_t addressValue = strtoul(address.c_str(), nullptr, 16);
//uint32_t commandValue = strtoul(command.c_str(), nullptr, 16);
//irsend.sendNEC(addressValue, commandValue, 32);
uint8_t first_zero_byte_pos = address.indexOf("00", 2);
if(first_zero_byte_pos!=-1) address = address.substring(0, first_zero_byte_pos);
first_zero_byte_pos = command.indexOf("00", 2);
Expand All @@ -422,50 +437,63 @@ void sendNECCommand(String address, String command) {
uint16_t commandValue = strtoul(command.c_str(), nullptr, 16);
uint64_t data = irsend.encodeNEC(addressValue, commandValue);
irsend.sendNEC(data, 32, 10);
Serial.println("Sent1");
Serial.println("Sent NEC Command");
digitalWrite(IrTx, LED_OFF);
}

void sendNECextCommand(String address, String command) {
IRsend irsend(IrTx); // Set the GPIO to be used to sending the message.

void sendRC5Command(String address, String command) {
IRsend irsend(IrTx,true); // Set the GPIO to be used to sending the message.
irsend.begin();
displayRedStripe("Sending..",TFT_WHITE,FGCOLOR);
uint32_t addressValue = strtoul(address.c_str(), nullptr, 16);
uint32_t commandValue = strtoul(command.c_str(), nullptr, 16);
irsend.sendNEC(addressValue, commandValue, 32);
Serial.println("Sent2");
uint8_t addressValue = strtoul(address.substring(0,2).c_str(), nullptr, 16);
uint8_t commandValue = strtoul(command.substring(0,2).c_str(), nullptr, 16);
uint16_t data = irsend.encodeRC5(addressValue, commandValue);
irsend.sendRC5(data, 13, 10);
Serial.println("Sent RC5 command");
digitalWrite(IrTx, LED_OFF);
}

void sendRC5Command(String address, String command) {
IRsend irsend(IrTx); // Set the GPIO to be used to sending the message.
void sendRC6Command(String address, String command) {
IRsend irsend(IrTx,true); // Set the GPIO to be used to sending the message.
irsend.begin();
displayRedStripe("Sending..",TFT_WHITE,FGCOLOR);
uint32_t addressValue = strtoul(address.c_str(), nullptr, 16);
uint32_t commandValue = strtoul(command.c_str(), nullptr, 16);
irsend.sendRC5(addressValue, commandValue, 12);
Serial.println("Sent3");
uint64_t data = irsend.encodeRC6(addressValue, commandValue);
irsend.sendRC6(data,20, 10);
Serial.println("Sent RC5 command");
digitalWrite(IrTx, LED_OFF);
}

void sendSamsungCommand(String address, String command) {
IRsend irsend(IrTx); // Set the GPIO to be used to sending the message.
irsend.begin();
displayRedStripe("Sending..",TFT_WHITE,FGCOLOR);
uint64_t data = ((uint64_t)strtoul(address.c_str(), nullptr, 16) << 32) | strtoul(command.c_str(), nullptr, 16);
irsend.sendSamsung36(data, 36);
Serial.println("Sent4");
//uint64_t data = ((uint64_t)strtoul(address.c_str(), nullptr, 16) << 32) | strtoul(command.c_str(), nullptr, 16);
uint32_t addressValue = strtoul(address.c_str(), nullptr, 16);
uint32_t commandValue = strtoul(command.c_str(), nullptr, 16);
uint64_t data = irsend.encodeSAMSUNG(addressValue, commandValue);
irsend.sendSAMSUNG(data, 32, 10);
//delay(20);
//irsend.sendSamsung36(data, 36, 10);
Serial.println("Sent Samsung Command");
digitalWrite(IrTx, LED_OFF);
}

void sendSonyCommand(String address, String command) {
IRsend irsend(IrTx); // Set the GPIO to be used to sending the message.
irsend.begin();
displayRedStripe("Sending..",TFT_WHITE,FGCOLOR);
uint16_t data = (uint16_t)strtoul(command.c_str(), nullptr, 16);
uint16_t addressValue = (uint16_t)strtoul(address.c_str(), nullptr, 16);
irsend.sendSony(addressValue, data);
Serial.println("Sent5");
uint16_t commandValue = strtoul(command.substring(0,2).c_str(), nullptr, 16);
uint16_t addressValue = strtoul(address.substring(0,2).c_str(), nullptr, 16);
uint16_t addressValue2 = strtoul(address.substring(3,6).c_str(), nullptr, 16);
uint16_t nbits = 12;
if(addressValue2>0) nbits = 20;
else if(addressValue>=0x80) nbits = 15;
uint32_t data = irsend.encodeSony(nbits,commandValue,addressValue);
irsend.sendSony(data,20,10);
Serial.println("Sent Sony Command");
digitalWrite(IrTx, LED_OFF);
}

Expand All @@ -492,6 +520,6 @@ void sendRawCommand(int frequency, String rawData) {
// Send raw command
irsend.sendRaw(dataBuffer, count, frequency);

Serial.println("Sent6");
Serial.println("Sent Raw command");
digitalWrite(IrTx, LED_OFF);
}
2 changes: 1 addition & 1 deletion src/modules/others/TV-B-Gone.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ void StartTvBGone();

// custom Ir
void sendRawCommand(int frequency, String rawData);
void sendNECextCommand(String address, String command);
void sendNECCommand(String address, String command);
void sendRC5Command(String address, String command);
void sendRC6Command(String address, String command);
void sendSamsungCommand(String address, String command);
void sendSonyCommand(String address, String command);
void otherIRcodes();

0 comments on commit a9dafba

Please sign in to comment.