From 22e32d4ae7bbf2cf73f44b91084cd9d142edc5e5 Mon Sep 17 00:00:00 2001
From: eadmaster <925171+eadmaster@users.noreply.github.com>
Date: Sun, 4 Aug 2024 15:29:54 +0200
Subject: [PATCH] added badusb support in the webui (#107)
---
src/modules/others/webInterface.cpp | 3 +++
src/modules/others/webInterface.h | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/modules/others/webInterface.cpp b/src/modules/others/webInterface.cpp
index d1cceb85..6e6a10a4 100644
--- a/src/modules/others/webInterface.cpp
+++ b/src/modules/others/webInterface.cpp
@@ -132,6 +132,9 @@ String listFiles(FS fs, bool ishtml, String folder, bool isLittleFS) {
//if (String(foundfile.name()).substring(String(foundfile.name()).lastIndexOf('.') + 1).equalsIgnoreCase("bin")) returnText+= "  \n";
if (String(foundfile.name()).substring(String(foundfile.name()).lastIndexOf('.') + 1).equalsIgnoreCase("sub")) returnText+= "  \n";
if (String(foundfile.name()).substring(String(foundfile.name()).lastIndexOf('.') + 1).equalsIgnoreCase("ir")) returnText+= "  \n";
+ #if defined(USB_as_HID)
+ if (String(foundfile.name()).substring(String(foundfile.name()).lastIndexOf('.') + 1).equalsIgnoreCase("txt")) returnText+= "  \n";
+ #endif
returnText += "  \n";
returnText += "\n\n";
} else {
diff --git a/src/modules/others/webInterface.h b/src/modules/others/webInterface.h
index ee6deb28..eec60c8e 100644
--- a/src/modules/others/webInterface.h
+++ b/src/modules/others/webInterface.h
@@ -448,6 +448,20 @@ function sendSubFile(filePath) {
listFilesButton(actualFolder, fs, true);
}
+function sendBadusbFile(filePath) {
+ if(!confirm("Confirm executing the selected DuckyScript on the machine connected via USB?")) return;
+ var actualFolder = document.getElementById("actualFolder").value;
+ var fs = document.getElementById("actualFS").value;
+ const ajax5 = new XMLHttpRequest();
+ const formdata5 = new FormData();
+ formdata5.append("cmnd", "badusb tx_from_file " + filePath);
+ ajax5.open("POST", "/cm", false);
+ ajax5.send(formdata5);
+ document.getElementById("status").innerHTML = ajax5.responseText;
+ var fs = document.getElementById("actualFS").value;
+ listFilesButton(actualFolder, fs, true);
+}
+
function downloadDeleteButton(filename, action) {
var fs = document.getElementById("actualFS").value;
var urltocall = "/file?name=" + filename + "&action=" + action + "&fs=" + fs;