From 8cab8261f6dbe1e02a7148d5a749fd7536f8102c Mon Sep 17 00:00:00 2001 From: cosmic-zip <36008397+cosmic-zip@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:31:37 -0300 Subject: [PATCH] add bonkers api --- src/lib/maid_shell/tinybox.dart | 6 +----- src/lib/maid_shell/utils.dart | 9 +++++++++ src/lib/maid_toolkit/bonkers/api.dart | 9 +++++++++ src/lib/maid_toolkit/bonkers/bonkers.dart | 24 +++++++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 src/lib/maid_toolkit/bonkers/api.dart create mode 100644 src/lib/maid_toolkit/bonkers/bonkers.dart diff --git a/src/lib/maid_shell/tinybox.dart b/src/lib/maid_shell/tinybox.dart index 8e95439..2b49678 100644 --- a/src/lib/maid_shell/tinybox.dart +++ b/src/lib/maid_shell/tinybox.dart @@ -269,9 +269,5 @@ Future tinyBox(List terminalArgs, String option) async { 'deviceZero': (terminalArgs) => deviceZero(terminalArgs), 'systeminfo': (terminalArgs) => systeminfo(terminalArgs), }; - - if (tinyBoxCommands.containsKey(option) == true) { - return await tinyBoxCommands[option]!(terminalArgs); - } - return stdint('fail'); + return commandOption(tinyBoxCommands, terminalArgs, option); } diff --git a/src/lib/maid_shell/utils.dart b/src/lib/maid_shell/utils.dart index 146e5e4..3653501 100644 --- a/src/lib/maid_shell/utils.dart +++ b/src/lib/maid_shell/utils.dart @@ -208,6 +208,15 @@ Future panzerRunner(List terminalArgs) async { return await terminalShellExec(terminalArgs, completer); } +/// Execute one option uni like commands +Future commandOption( + Map commandListList, List terminalArgs, String option) async { + if (commandListList.containsKey(option) == true) { + return await commandListList[option]!(terminalArgs); + } + return stdint('fail'); +} + int maidStatus() { String slim(String symbol, String key, String value) { return "\u001b[1m\u001b[35m$symbol \ $key ::\u001b[0m $value\u001b[0m"; diff --git a/src/lib/maid_toolkit/bonkers/api.dart b/src/lib/maid_toolkit/bonkers/api.dart new file mode 100644 index 0000000..b5eb2c1 --- /dev/null +++ b/src/lib/maid_toolkit/bonkers/api.dart @@ -0,0 +1,9 @@ +import 'package:panzer_maid/maid_shell/utils.dart'; +import 'bonkers.dart'; + +Future tinyBox(List terminalArgs, String option) async { + final Map tinyBoxCommands = { + 'attack.luks': (terminalArgs) => luks_bonkers(terminalArgs), + }; + return commandOption(tinyBoxCommands, terminalArgs, option); +} diff --git a/src/lib/maid_toolkit/bonkers/bonkers.dart b/src/lib/maid_toolkit/bonkers/bonkers.dart new file mode 100644 index 0000000..2c15a33 --- /dev/null +++ b/src/lib/maid_toolkit/bonkers/bonkers.dart @@ -0,0 +1,24 @@ +import 'dart:io'; +import 'package:panzer_maid/maid_shell/utils.dart'; + +Future luks_bonkers(List terminalArgs) async { + try { + String device = searchKeyValue(terminalArgs, key: 'device'); + + final file = File(''); + var contents = await file.readAsLines(); + for (final line in contents) { + var cmd = + "echo '$line' | cryptsetup open --key-file - /dev/$device encrypted_device"; + var out = await flawlessExec(cmd); + if (out == 0) { + puts("Found! key :: $line", color: 'green'); + return out; + } + } + } catch (e) { + return stdint('error'); + } finally { + return stdint('ok'); + } +}