Skip to content

Commit

Permalink
add bonkers api
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-zip committed Jul 29, 2024
1 parent 6e31b54 commit 8cab826
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/lib/maid_shell/tinybox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,5 @@ Future<int> tinyBox(List<String> 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);
}
9 changes: 9 additions & 0 deletions src/lib/maid_shell/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ Future<int> panzerRunner(List<String> terminalArgs) async {
return await terminalShellExec(terminalArgs, completer);
}

/// Execute one option uni like commands
Future<int> commandOption(
Map commandListList, List<String> 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";
Expand Down
9 changes: 9 additions & 0 deletions src/lib/maid_toolkit/bonkers/api.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:panzer_maid/maid_shell/utils.dart';
import 'bonkers.dart';

Future<int> tinyBox(List<String> terminalArgs, String option) async {
final Map tinyBoxCommands = {
'attack.luks': (terminalArgs) => luks_bonkers(terminalArgs),
};
return commandOption(tinyBoxCommands, terminalArgs, option);
}
24 changes: 24 additions & 0 deletions src/lib/maid_toolkit/bonkers/bonkers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'dart:io';
import 'package:panzer_maid/maid_shell/utils.dart';

Future<int> luks_bonkers(List<String> 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');
}
}

0 comments on commit 8cab826

Please sign in to comment.