Skip to content

Commit

Permalink
Merge pull request #24 from bmorcelli/main
Browse files Browse the repository at this point in the history
SSH, LittleFS,  mykeyboard
  • Loading branch information
pr3y authored May 31, 2024
2 parents 0d2fde4 + 15fc1d2 commit 5c0394d
Show file tree
Hide file tree
Showing 18 changed files with 387 additions and 275 deletions.
43 changes: 30 additions & 13 deletions html/WebUI.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,17 @@
<h1 align="center">BRUCE Firmware</h1>
<p>Firmware for offensive pranks and pentest studies and analysis. For educational purposes only. Don't use in environments where you are not allowed. All responsibilities for irresponsible usage of this firmware rest on your fin, sharky. Sincerely, Bruce.</p>
<p>Firmware version: %FIRMWARE%</p>
<p>Free Storage: <span id="freeSD">%FREESD%</span> | Used: <span id="usedSD">%USEDSD%</span> | Total: <span id="totalSD">%TOTALSD%</span></p>
<p>SD Free Storage: <span id="freeSD">%FREESD%</span> | Used: <span id="usedSD">%USEDSD%</span> | Total: <span id="totalSD">%TOTALSD%</span></p>
<p>LittleFS Free Storage: <span id="freeSD">%FREELittleFS%</span> | Used: <span id="usedSD">%USEDLittleFS%</span> | Total: <span id="totalSD">%TOTALLittleFS%</span></p>
<p>
<form id="save" enctype="multipart/form-data" method="post"><input type="hidden" id="actualFolder" name="actualFolder" value="/"></form>
<form id="save" enctype="multipart/form-data" method="post">
<input type="hidden" id="actualFolder" name="actualFolder" value="/">
<input type="hidden" id="actualFS" name="actualFS" value="SD">
</form>
<button onclick="rebootButton()">Reboot</button>
<button onclick="WifiConfig()">Usr/Pass</button>
<button onclick="listFilesButton('/')">SD Files</button>
<button onclick="listFilesButton('/', 'SD')">SD Files</button>
<button onclick="listFilesButton('/', 'LittleFS')">LittleFS</button>

</p>
<p id="detailsheader"></p>
Expand Down Expand Up @@ -295,10 +300,11 @@ <h1 align="center">BRUCE Firmware</h1>
}
}

function listFilesButton(folders) {
function listFilesButton(folders, fs = 'SD') {
xmlhttp=new XMLHttpRequest();
document.getElementById("actualFolder").value = "";
document.getElementById("actualFolder").value = folders;
document.getElementById("actualFS").value = fs;

xmlhttp.onload = function() {
if (xmlhttp.status === 200) {
Expand All @@ -311,7 +317,7 @@ <h1 align="center">BRUCE Firmware</h1>
console.error('Erro na rede ou falha na requisição.');
};

xmlhttp.open("GET", "/listfiles?folder=" + folders, true);
xmlhttp.open("GET", "/listfiles?fs=" + fs + "&folder=" + folders, true);
xmlhttp.send();

document.getElementById("detailsheader").innerHTML = "<h3>Files<h3>";
Expand All @@ -321,24 +327,28 @@ <h1 align="center">BRUCE Firmware</h1>

function renameFile(filePath, oldName) {
var actualFolder = document.getElementById("actualFolder").value;
var fs = document.getElementById("actualFS").value;
let fileName = prompt("Enter the new name: ", oldName);
if (fileName == null || fileName == "") {
window.alert("Invalid Name");
} else {
const ajax5 = new XMLHttpRequest();
const formdata5 = new FormData();
formdata5.append("fs", fs);
formdata5.append("filePath", filePath);
formdata5.append("fileName", fileName);
ajax5.open("POST", "/rename", false);
ajax5.send(formdata5);
document.getElementById("status").innerHTML = ajax5.responseText;

listFilesButton(actualFolder);
var fs = document.getElementById("actualFS").value;
listFilesButton(actualFolder, fs);
}
}

function downloadDeleteButton(filename, action) {
var urltocall = "/file?name=" + filename + "&action=" + action;
var fs = document.getElementById("actualFS").value;
var urltocall = "/file?name=" + filename + "&action=" + action + "&fs=" + fs;
var actualFolder = document.getElementById("actualFolder").value;
var option;
if (action == "delete") {
Expand All @@ -350,7 +360,8 @@ <h1 align="center">BRUCE Firmware</h1>
xmlhttp.open("GET", urltocall, false);
xmlhttp.send();
document.getElementById("status").innerHTML = xmlhttp.responseText;
listFilesButton(actualFolder);
var fs = document.getElementById("actualFS").value;
listFilesButton(actualFolder, fs);
}
if (action == "download") {
document.getElementById("status").innerHTML = "";
Expand All @@ -359,9 +370,11 @@ <h1 align="center">BRUCE Firmware</h1>
}

function showCreateFolder(folders) {
var fs = document.getElementById("actualFS").value;
var uploadform = "";
//document.getElementById("updetailsheader").innerHTML = "<h3>Create new Folder<h3>"
document.getElementById("status").innerHTML = "";
var uploadform =
uploadform =
"<p>Creating folder at: <b>" + folders + "</b>"+
"<form id=\"create_form\" enctype=\"multipart/form-data\" method=\"post\">" +
"<input type=\"hidden\" id=\"folder\" name=\"folder\" value=\"" + folders + "\">" +
Expand All @@ -384,7 +397,7 @@ <h1 align="center">BRUCE Firmware</h1>
"<p>Send file to " + folders + "</p>"+
"<form id=\"upload_form\" enctype=\"multipart/form-data\" method=\"post\">" +
"<input type=\"hidden\" id=\"folder\" name=\"folder\" value=\"" + folders + "\">" +
"<input type=\"file\" name=\"file1\" id=\"file1\" onchange=\"uploadFile('" + folders + "')\"><br>" +
"<input type=\"file\" name=\"file1\" id=\"file1\" onchange=\"uploadFile('" + folders + "', 'SD')\"><br>" +
"<progress id=\"progressBar\" value=\"0\" max=\"100\" style=\"width:100%;\"></progress>" +
"<h3 id=\"status\"></h3>" +
"<p id=\"loaded_n_total\"></p>" +
Expand All @@ -395,6 +408,7 @@ <h1 align="center">BRUCE Firmware</h1>
return document.getElementById(el);
}
function uploadFile(folder) {
var fs = document.getElementById("actualFS").value;
var file = _("file1").files[0];
var folder = _("folder").value;
// alert(file.name+" | "+file.size+" | "+file.type);
Expand All @@ -406,7 +420,7 @@ <h1 align="center">BRUCE Firmware</h1>
ajax.addEventListener("load", completeHandler, false); // doesnt appear to ever get called even upon success
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "/upload");
ajax.open("POST", "/upload" + fs);
ajax.send(formdata);
}
function progressHandler(event) {
Expand All @@ -423,7 +437,8 @@ <h1 align="center">BRUCE Firmware</h1>
_("progressBar").value = 0;
var actualFolder = document.getElementById("actualFolder").value
document.getElementById("status").innerHTML = "File Uploaded";
listFilesButton(actualFolder);
var fs = document.getElementById("actualFS").value;
listFilesButton(actualFolder, fs);
}
function errorHandler(event) {
_("status").innerHTML = "Upload Failed";
Expand All @@ -433,7 +448,9 @@ <h1 align="center">BRUCE Firmware</h1>
}

window.addEventListener("load", function() {
listFilesButton("/");
var actualFolder = document.getElementById("actualFolder").value
var fs = document.getElementById("actualFS").value;
listFilesButton(actualFolder, fs);
});

</script>
Expand Down
4 changes: 2 additions & 2 deletions src/TV-B-Gone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ void otherIRcodes() {
bool teste=false;
options = {
{"SD Card", [&]() { fs=&SD; }},
{"Spiffs", [&]() { fs=&SPIFFS; }},
{"LittleFS", [&]() { fs=&LittleFS; }},
};
delay(200);
loopOptions(options);
} else fs=&SPIFFS;
} else fs=&LittleFS;


filepath = loopSD(*fs, true);
Expand Down
4 changes: 2 additions & 2 deletions src/bad_usb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,11 @@ void usb_setup() {
bool teste=false;
options = {
{"SD Card", [&]() { fs=&SD; }},
{"Spiffs", [&]() { fs=&SPIFFS; }},
{"LittleFS", [&]() { fs=&LittleFS; }},
};
delay(200);
loopOptions(options);
} else fs=&SPIFFS;
} else fs=&LittleFS;

bad_script = loopSD(*fs,true);
tft.fillScreen(BGCOLOR);
Expand Down
Loading

0 comments on commit 5c0394d

Please sign in to comment.