mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 15:35:32 +00:00
Ookbrute (#2354)
This commit is contained in:
parent
458a6634bf
commit
4641dcb449
5
firmware/application/external/external.cmake
vendored
5
firmware/application/external/external.cmake
vendored
@ -111,6 +111,10 @@ set(EXTCPPSRC
|
||||
external/shoppingcart_lock/main.cpp
|
||||
external/shoppingcart_lock/shoppingcart_lock.cpp
|
||||
|
||||
#ookbrute
|
||||
external/ookbrute/main.cpp
|
||||
external/ookbrute/ui_ookbrute.cpp
|
||||
|
||||
#cvs_spam
|
||||
external/cvs_spam/main.cpp
|
||||
external/cvs_spam/cvs_spam.cpp
|
||||
@ -143,5 +147,6 @@ set(EXTAPPLIST
|
||||
sstvtx
|
||||
random_password
|
||||
#acars_rx
|
||||
ookbrute
|
||||
shoppingcart_lock
|
||||
)
|
||||
|
7
firmware/application/external/external.ld
vendored
7
firmware/application/external/external.ld
vendored
@ -50,6 +50,7 @@ MEMORY
|
||||
ram_external_app_acars_rx(rwx) : org = 0xADC90000, len = 32k
|
||||
ram_external_app_shoppingcart_lock(rwx) : org = 0xADCA0000, len = 32k
|
||||
ram_external_app_cvs_spam(rwx) : org = 0xADCB0000, len = 32k
|
||||
ram_external_app_ookbrute(rwx) : org = 0xADCC0000, len = 32k
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
@ -217,4 +218,10 @@ SECTIONS
|
||||
*(*ui*external_app*cvs_spam*);
|
||||
} > ram_external_app_cvs_spam
|
||||
|
||||
.external_app_ookbrute : ALIGN(4) SUBALIGN(4)
|
||||
{
|
||||
KEEP(*(.external_app.app_ookbrute.application_information));
|
||||
*(*ui*external_app*ookbrute*);
|
||||
} > ram_external_app_ookbrute
|
||||
|
||||
}
|
||||
|
82
firmware/application/external/ookbrute/main.cpp
vendored
Normal file
82
firmware/application/external/ookbrute/main.cpp
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Bernd Herzog
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_ookbrute.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "external_app.hpp"
|
||||
|
||||
namespace ui::external_app::ookbrute {
|
||||
void initialize_app(ui::NavigationView& nav) {
|
||||
nav.push<OokBruteView>();
|
||||
}
|
||||
} // namespace ui::external_app::ookbrute
|
||||
|
||||
extern "C" {
|
||||
|
||||
__attribute__((section(".external_app.app_ookbrute.application_information"), used)) application_information_t _application_information_ookbrute = {
|
||||
/*.memory_location = */ (uint8_t*)0x00000000,
|
||||
/*.externalAppEntry = */ ui::external_app::ookbrute::initialize_app,
|
||||
/*.header_version = */ CURRENT_HEADER_VERSION,
|
||||
/*.app_version = */ VERSION_MD5,
|
||||
|
||||
/*.app_name = */ "OokBrute",
|
||||
/*.bitmap_data = */ {
|
||||
0x20,
|
||||
0x00,
|
||||
0x20,
|
||||
0x00,
|
||||
0x20,
|
||||
0x00,
|
||||
0x20,
|
||||
0x00,
|
||||
0xE0,
|
||||
0x07,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0x30,
|
||||
0x0C,
|
||||
0x30,
|
||||
0x0C,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0x70,
|
||||
0x0D,
|
||||
0xB0,
|
||||
0x0E,
|
||||
0x70,
|
||||
0x0D,
|
||||
0xB0,
|
||||
0x0E,
|
||||
0xF0,
|
||||
0x0F,
|
||||
0xE0,
|
||||
0x07,
|
||||
},
|
||||
/*.icon_color = */ ui::Color::orange().v,
|
||||
/*.menu_location = */ app_location_t::TX,
|
||||
|
||||
/*.m4_app_tag = portapack::spi_flash::image_tag_ook */ {'P', 'O', 'O', 'K'},
|
||||
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
|
||||
};
|
||||
}
|
253
firmware/application/external/ookbrute/ui_ookbrute.cpp
vendored
Normal file
253
firmware/application/external/ookbrute/ui_ookbrute.cpp
vendored
Normal file
@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (C) 2024 HTotoo
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "ui_ookbrute.hpp"
|
||||
#include "audio.hpp"
|
||||
#include "rtc_time.hpp"
|
||||
#include "baseband_api.hpp"
|
||||
#include "string_format.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
using namespace portapack;
|
||||
using namespace ui;
|
||||
|
||||
namespace ui::external_app::ookbrute {
|
||||
|
||||
void OokBruteView::focus() {
|
||||
button_startstop.focus();
|
||||
}
|
||||
|
||||
OokBruteView::OokBruteView(NavigationView& nav)
|
||||
: nav_{nav} {
|
||||
add_children({
|
||||
&button_startstop,
|
||||
&field_frequency,
|
||||
&tx_view,
|
||||
&options_atkmode,
|
||||
&field_start,
|
||||
&field_stop,
|
||||
});
|
||||
|
||||
button_startstop.on_select = [this](Button&) {
|
||||
if (is_running) {
|
||||
is_running = false;
|
||||
stop();
|
||||
} else {
|
||||
is_running = true;
|
||||
start();
|
||||
}
|
||||
};
|
||||
|
||||
options_atkmode.on_change = [this](size_t, int32_t i) {
|
||||
update_start_stop(i);
|
||||
validate_start_stop();
|
||||
};
|
||||
field_start.on_change = [this](int32_t) {
|
||||
validate_start_stop();
|
||||
};
|
||||
field_stop.on_change = [this](int32_t) {
|
||||
validate_start_stop();
|
||||
};
|
||||
update_start_stop(0);
|
||||
}
|
||||
|
||||
void OokBruteView::update_start_stop(uint32_t proto) {
|
||||
uint8_t bits = 12;
|
||||
switch (proto) {
|
||||
default:
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
bits = 12;
|
||||
break;
|
||||
case 1:
|
||||
case 3:
|
||||
case 5:
|
||||
bits = 24;
|
||||
break;
|
||||
}
|
||||
uint32_t max = (1 << bits) - 1;
|
||||
field_start.set_range(0, max);
|
||||
field_stop.set_range(0, max);
|
||||
field_start.set_value(0);
|
||||
field_stop.set_value(max);
|
||||
}
|
||||
|
||||
void OokBruteView::validate_start_stop() {
|
||||
if (field_start.value() > field_stop.value()) {
|
||||
field_start.set_value(field_stop.value());
|
||||
}
|
||||
if (field_stop.value() < field_start.value()) {
|
||||
field_stop.set_value(field_start.value());
|
||||
}
|
||||
}
|
||||
|
||||
void OokBruteView::generate_packet() {
|
||||
uint32_t protocol = options_atkmode.selected_index_value();
|
||||
uint8_t byte = 0;
|
||||
size_t bitstream_length = 0;
|
||||
uint8_t* bitstream = shared_memory.bb_data.data; // max 512 in size
|
||||
uint32_t samples_per_bit = 0; // OOK_SAMPLERATE * bit_duration_in_sec
|
||||
std::string dataFormat = "";
|
||||
std::string zero = "";
|
||||
std::string one = "";
|
||||
uint16_t databits = 0;
|
||||
uint16_t repeat = 1;
|
||||
uint16_t pause_sym = 0;
|
||||
if (protocol == 0) { // came 12
|
||||
samples_per_bit = OOK_SAMPLERATE / ((3 * 1000) / 1);
|
||||
dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data
|
||||
databits = 12;
|
||||
zero = "011";
|
||||
one = "001";
|
||||
repeat = 2;
|
||||
pause_sym = 0;
|
||||
}
|
||||
|
||||
if (protocol == 1) { // came24
|
||||
samples_per_bit = OOK_SAMPLERATE / ((3 * 1000) / 1);
|
||||
dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data
|
||||
databits = 24;
|
||||
zero = "011";
|
||||
one = "001";
|
||||
repeat = 2;
|
||||
pause_sym = 0;
|
||||
}
|
||||
if (protocol == 2) { // nice12
|
||||
samples_per_bit = OOK_SAMPLERATE * (680.0 / 1000000.0);
|
||||
dataFormat = "000000000000000000000000000000000000000001CCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data
|
||||
databits = 12;
|
||||
zero = "011";
|
||||
one = "001";
|
||||
repeat = 2;
|
||||
pause_sym = 0;
|
||||
}
|
||||
if (protocol == 3) { // nice24
|
||||
samples_per_bit = OOK_SAMPLERATE * (680.0 / 1000000.0);
|
||||
dataFormat = "000000000000000000000000000000000000000001CCCCCCCCCCCCCCCCCCCCCCCC0000"; // 36 0 preamble +start bit + data
|
||||
databits = 24;
|
||||
zero = "011";
|
||||
one = "001";
|
||||
repeat = 2;
|
||||
pause_sym = 0;
|
||||
}
|
||||
if (protocol == 4) { // holtek_ht12
|
||||
samples_per_bit = OOK_SAMPLERATE * (390.0 / 1000000.0);
|
||||
dataFormat = "0000000000000000000000000000000000001CCCCCCCCCCCC00000000000"; // 36 0 preamble +start bit + data.
|
||||
databits = 12;
|
||||
zero = "011";
|
||||
one = "001";
|
||||
repeat = 2;
|
||||
pause_sym = 0;
|
||||
}
|
||||
if (protocol == 5) { // princeton24
|
||||
samples_per_bit = OOK_SAMPLERATE * (450.0 / 1000000.0); // long = 3*
|
||||
dataFormat = "000000000000000000000000000000000000CCCCCCCCCCCCCCCCCCCCCCCC10000000"; //
|
||||
databits = 24;
|
||||
zero = "1000";
|
||||
one = "1110";
|
||||
repeat = 6;
|
||||
pause_sym = 0;
|
||||
}
|
||||
|
||||
std::string fragments = ""; // storage
|
||||
|
||||
uint16_t cdb = 0; // current data bit
|
||||
for (auto c : dataFormat) { // generate fragments from template
|
||||
if (c == '0') fragments += '0';
|
||||
if (c == '1') fragments += '1';
|
||||
if (c == 'C') {
|
||||
if (counter & (1 << (databits - cdb - 1))) {
|
||||
fragments += one;
|
||||
} else {
|
||||
fragments += zero;
|
||||
}
|
||||
cdb++;
|
||||
}
|
||||
}
|
||||
|
||||
// create bitstream
|
||||
for (auto c : fragments) {
|
||||
byte <<= 1;
|
||||
if (c != '0') byte |= 1;
|
||||
if ((bitstream_length & 7) == 7)
|
||||
bitstream[bitstream_length >> 3] = byte;
|
||||
bitstream_length++;
|
||||
}
|
||||
|
||||
// Finish last byte if needed
|
||||
size_t padding = 8 - (bitstream_length & 7);
|
||||
if (padding != 8) {
|
||||
byte <<= padding;
|
||||
bitstream[(bitstream_length + padding - 1) >> 3] = byte;
|
||||
padding++;
|
||||
}
|
||||
|
||||
// send bitstream
|
||||
baseband::set_ook_data(
|
||||
bitstream_length,
|
||||
samples_per_bit,
|
||||
repeat,
|
||||
pause_sym,
|
||||
0);
|
||||
}
|
||||
|
||||
void OokBruteView::stop() {
|
||||
transmitter_model.disable();
|
||||
baseband::shutdown();
|
||||
button_startstop.set_text(LanguageHelper::currentMessages[LANG_START]);
|
||||
}
|
||||
|
||||
void OokBruteView::start() {
|
||||
counter = field_start.value();
|
||||
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
|
||||
transmitter_model.enable();
|
||||
button_startstop.set_text(LanguageHelper::currentMessages[LANG_STOP]);
|
||||
generate_packet();
|
||||
}
|
||||
|
||||
void OokBruteView::on_tx_progress(const bool done) {
|
||||
if (done) {
|
||||
if (is_running) {
|
||||
counter++;
|
||||
field_start.set_value(counter);
|
||||
if (counter > (uint32_t)field_stop.value()) {
|
||||
stop();
|
||||
} else {
|
||||
generate_packet();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OokBruteView::~OokBruteView() {
|
||||
is_running = false;
|
||||
stop();
|
||||
}
|
||||
|
||||
} // namespace ui::external_app::ookbrute
|
||||
|
||||
/*
|
||||
|
||||
https://web.archive.org/web/20230331125843/https://phreakerclub.com/447
|
||||
|
||||
|
||||
*/
|
106
firmware/application/external/ookbrute/ui_ookbrute.hpp
vendored
Normal file
106
firmware/application/external/ookbrute/ui_ookbrute.hpp
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2024 HTotoo
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UI_OOKBRUTE_H__
|
||||
#define __UI_OOKBRUTE_H__
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "ui_language.hpp"
|
||||
#include "ui_navigation.hpp"
|
||||
#include "ui_transmitter.hpp"
|
||||
#include "ui_freq_field.hpp"
|
||||
#include "ui_record_view.hpp"
|
||||
#include "app_settings.hpp"
|
||||
#include "radio_state.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
using namespace ui;
|
||||
|
||||
namespace ui::external_app::ookbrute {
|
||||
|
||||
#define OOK_SAMPLERATE 2280000U
|
||||
|
||||
class OokBruteView : public View {
|
||||
public:
|
||||
OokBruteView(NavigationView& nav);
|
||||
~OokBruteView();
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override {
|
||||
return "OokBrute";
|
||||
};
|
||||
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
TxRadioState radio_state_{
|
||||
433920000 /* frequency */,
|
||||
1750000 /* bandwidth */,
|
||||
OOK_SAMPLERATE /* sampling rate */
|
||||
};
|
||||
|
||||
TxFrequencyField field_frequency{
|
||||
{0 * 8, 0 * 16},
|
||||
nav_};
|
||||
TransmitterView2 tx_view{
|
||||
{11 * 8, 0 * 16},
|
||||
/*short_ui*/ true};
|
||||
app_settings::SettingsManager settings_{
|
||||
"tx_ookbrute", app_settings::Mode::TX};
|
||||
|
||||
Button button_startstop{
|
||||
{0, 3 * 16, 96, 24},
|
||||
LanguageHelper::currentMessages[LANG_START]};
|
||||
|
||||
NumberField field_start{
|
||||
{0 * 8, 1 * 16},
|
||||
8,
|
||||
{0, 2500},
|
||||
1,
|
||||
' ',
|
||||
true};
|
||||
|
||||
NumberField field_stop{
|
||||
{11 * 8, 1 * 16},
|
||||
9,
|
||||
{0, 2500},
|
||||
1,
|
||||
' ',
|
||||
true};
|
||||
|
||||
OptionsField options_atkmode{
|
||||
{0 * 8, 2 * 16},
|
||||
12,
|
||||
{{"Came12", 0},
|
||||
{"Came24", 1},
|
||||
{"Nice12", 2},
|
||||
{"Nice24", 3},
|
||||
{"Holtek12", 4},
|
||||
{"Princeton24", 5}}};
|
||||
|
||||
bool is_running{false};
|
||||
|
||||
uint32_t counter = 0; // for packet change
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
void on_tx_progress(const bool done);
|
||||
void validate_start_stop();
|
||||
void update_start_stop(uint32_t proto);
|
||||
void generate_packet();
|
||||
|
||||
MessageHandlerRegistration message_handler_tx_progress{
|
||||
Message::ID::TXProgress,
|
||||
[this](const Message* const p) {
|
||||
const auto message = *reinterpret_cast<const TXProgressMessage*>(p);
|
||||
this->on_tx_progress(message.done);
|
||||
}};
|
||||
};
|
||||
}; // namespace ui::external_app::ookbrute
|
||||
|
||||
#endif /*__UI_OOKBRUTE_H__*/
|
Loading…
Reference in New Issue
Block a user