Fixed attack crashed on debug
This commit is contained in:
parent
f823e92a41
commit
c6e3f89a53
|
@ -50,7 +50,7 @@ namespace attack {
|
|||
if (!msc::getInLine()) cur_pos = msc::getPosition();
|
||||
len = msc::readLine(buffer, READ_BUFFER);
|
||||
debugln(len);
|
||||
debugln(std::string(buffer, len-1).c_str());
|
||||
//debugln(std::string(buffer, len-1).c_str());
|
||||
|
||||
// Reached end of file
|
||||
if (len == 0) {
|
||||
|
@ -93,6 +93,8 @@ namespace attack {
|
|||
|
||||
debugln("OK");
|
||||
}
|
||||
|
||||
debugln("Attack finished");
|
||||
}
|
||||
|
||||
void start() {
|
||||
|
|
|
@ -78,8 +78,9 @@ namespace cli {
|
|||
// help
|
||||
cli.addCmd("help", [](cmd* c) {
|
||||
Serial.println("[ = Available Commands =]");
|
||||
Serial.println(cli.toString());
|
||||
Serial.print(cli.toString());
|
||||
Serial.println("Enter any BadUSB Scripts to run it.");
|
||||
Serial.println();
|
||||
}).setDescription(" Get a list of available commands.");
|
||||
|
||||
// version
|
||||
|
@ -131,6 +132,11 @@ namespace cli {
|
|||
Command cmd(c);
|
||||
Argument arg = cmd.getArgument(0);
|
||||
attack::start(arg.getValue().c_str());
|
||||
if(selector::mode() == SETUP) {
|
||||
led::setColor(preferences::getSetupColor());
|
||||
} else {
|
||||
led::setColor(preferences::getIdleColor());
|
||||
}
|
||||
}).setDescription(" Start a BadUSB Script.");
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace msc {
|
|||
return fatfs.exists(filename);
|
||||
}
|
||||
|
||||
bool open(const char* path) {
|
||||
bool open(const char* path, bool add_to_stack) {
|
||||
debug("Open new file: ");
|
||||
debugln(path);
|
||||
|
||||
|
@ -142,7 +142,7 @@ namespace msc {
|
|||
if (!path) return false;
|
||||
|
||||
// If the stack isn't empty, save the current position
|
||||
if (!file_stack.empty()) {
|
||||
if (add_to_stack && !file_stack.empty()) {
|
||||
file_stack.top().pos = file.curPosition();
|
||||
}
|
||||
|
||||
|
@ -150,10 +150,12 @@ namespace msc {
|
|||
if (file.isOpen()) file.close();
|
||||
|
||||
// Create a new file element and push it to the stack
|
||||
file_element_t file_element;
|
||||
file_element.path = std::string(path);
|
||||
file_element.pos = 0;
|
||||
file_stack.push(file_element);
|
||||
if(add_to_stack) {
|
||||
file_element_t file_element;
|
||||
file_element.path = std::string(path);
|
||||
file_element.pos = 0;
|
||||
file_stack.push(file_element);
|
||||
}
|
||||
|
||||
// Open file and return whether it was successful
|
||||
return file.open(path);
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace msc {
|
|||
bool changed();
|
||||
bool exists(const char* filename);
|
||||
|
||||
bool open(const char* path);
|
||||
bool open(const char* path, bool add_to_stack = true);
|
||||
bool openNextFile();
|
||||
|
||||
void close();
|
||||
|
|
|
@ -99,7 +99,7 @@ namespace preferences {
|
|||
DynamicJsonDocument config_doc(JSON_SIZE);
|
||||
|
||||
// Open the file and read it into a buffer
|
||||
if (!msc::open(PREFERENCES_PATH)) return;
|
||||
if (!msc::open(PREFERENCES_PATH), false) return;
|
||||
msc::read(buffer, JSON_SIZE);
|
||||
|
||||
// Deserialize the JSON document
|
||||
|
|
Loading…
Reference in New Issue