Skip to content

Commit

Permalink
Reverse proxy prep.
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Jul 13, 2024
1 parent 3d7ef10 commit 1673254
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 28 deletions.
18 changes: 6 additions & 12 deletions Protest/Front/certificates.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Certificates extends List {
const dropArea = document.createElement("div");
dropArea.style.minHeight = "20px";
dropArea.style.margin = "16px";
dropArea.style.padding = "64px";
dropArea.style.padding = "32px 0";
dropArea.style.border = "2px dashed var(--clr-dark)";
dropArea.style.borderRadius = "8px";
dropArea.style.transition = ".4s";
Expand All @@ -213,7 +213,6 @@ class Certificates extends List {
dropArea.append(message);

let isBusy = false;


dropArea.ondragover = ()=> {
if (isBusy) return;
Expand All @@ -234,17 +233,17 @@ class Certificates extends List {
dropArea.style.backgroundColor = "";
dropArea.style.border = "2px dashed var(--clr-dark)";

/*if (event.dataTransfer.files.length !== 1) {
this.ConfirmBox("Please upload a single file.", true);
if (event.dataTransfer.files.length !== 1) {
message.textContent = "Please drop a single file.";
return;
}*/
}

let file = event.dataTransfer.files[0];
let extension = file.name.split(".");
extension = extension[extension.length-1].toLowerCase();

if (extension != "pfx") {
//this.ConfirmBox("Unsupported file", true);
if (extension !== "pfx") {
message.textContent = "Unsupported file type.";
return;
}

Expand Down Expand Up @@ -289,11 +288,6 @@ class Certificates extends List {
};

innerBox.appendChild(dropArea);

okButton.onclick = ()=> {
this.GetCertFiles();
dialog.Close();
};
}

Download() {
Expand Down
3 changes: 3 additions & 0 deletions Protest/Front/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ class List extends Window {
this.link.length :
`${this.list.childNodes.length} / ${this.link.length}`;
}
else {
this.counter.textContent = "0";
}
}

InflateElement(element, entry, c_type) { //overridable
Expand Down
2 changes: 2 additions & 0 deletions Protest/Front/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const LOADER = {
"snmp.js",
"speedtest.js",
"sitecheck.js",
"reverseproxy.js",
"passwordgen.js",
"passwordstrength.js",
"gandalf.js",
Expand Down Expand Up @@ -323,6 +324,7 @@ const LOADER = {
case "DhcpDiscover" : return new DhcpDiscover(command.args);
case "NtpClient" : return new NtpClient(command.args);
case "SiteCheck" : return new SiteCheck(command.args);
case "ReverseProxy" : return new ReverseProxy(command.args);
case "Telnet" : return new Telnet(command.args);
case "Ssh" : return new Ssh(command.args);
case "Wmi" : return new Wmi(command.args);
Expand Down
6 changes: 3 additions & 3 deletions Protest/Front/mono/hypervisor.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Protest/Front/mono/reverseproxy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Protest/Front/mono/server.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Protest/Front/reverseproxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class ReverseProxy extends List {
constructor(args) {
super(null);

this.args = args ?? "";

this.AddCssDependencies("list.css");

this.SetTitle("Reverse proxy");
this.SetIcon("mono/reverseproxy.svg");

const columns = ["name", "traffic"];
this.SetupColumns(columns);
this.columnsOptions.style.display = "none";

this.SetupToolbar();
this.createButton = this.AddToolbarButton("Create task", "mono/add.svg?light");
this.deleteButton = this.AddToolbarButton("Delete", "mono/delete.svg?light");
this.AddToolbarSeparator();
this.startButton = this.AddToolbarButton("Start", "mono/play.svg?light");
this.pauseButton = this.AddToolbarButton("Pause", "mono/pause.svg?light");
this.stopButton = this.AddToolbarButton("Stop", "mono/stop.svg?light");

this.list.style.right = "unset";
this.list.style.width = "min(40%, 480px)";

this.listTitle.style.right = "unset";
this.listTitle.style.width = "min(40%, 480px)";

this.stats = document.createElement("div");
this.stats.style.position = "absolute";
this.stats.style.left = "calc(min(40%, 480px) + 8px)";
this.stats.style.right = "0";
this.stats.style.top = "0";
this.stats.style.bottom = "28px";
this.stats.style.overflowY = "auto";
this.content.appendChild(this.stats);

}

}
2 changes: 1 addition & 1 deletion Protest/Front/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Tasks extends List {
this.SetupToolbar();
this.createButton = this.AddToolbarButton("Create task", "mono/add.svg?light");
this.deleteButton = this.AddToolbarButton("Delete", "mono/delete.svg?light");
this.toolbar.appendChild(this.AddToolbarSeparator());
this.AddToolbarSeparator();
this.startButton = this.AddToolbarButton("Start", "mono/play.svg?light");
this.pauseButton = this.AddToolbarButton("Pause", "mono/pause.svg?light");
this.stopButton = this.AddToolbarButton("Stop", "mono/stop.svg?light");
Expand Down
9 changes: 5 additions & 4 deletions Protest/Front/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,11 @@ const MENU = {
{ t:"Watchdog", i:"mono/watchdog.svg?light", g:"tools", h:false, f:()=> new Watchdog(), k:"" },
{ t:"Gandalf", i:"mono/gandalf.svg?light", g:"tools", h:false, f:()=> new Gandalf() },
//{ t:"Issues", i:"mono/issues.svg?light", g:"tools", h:false, f:()=> new Issues() },
{ t:"WMI client", i:"mono/wmi.svg?light", g:"tools", h:false, f:args=> new Wmi(args), k:"windows management instrumentation viewer" },
{ t:"SNMP polling", i:"mono/snmp.svg?light", g:"tools", h:false, f:args=> new Snmp(args) },
//{ t:"SNMP traps", i:"mono/trap.svg?light", g:"tools", h:false, f:args=> new Snmp(args) },
//{ t:"Scripts", i:"mono/scripts.svg?light", g:"tools", h:false, f:args=> {} },
//{ t:"Script reports", i:"mono/reportfile.svg?light", g:"tools", h:true, f:args=> {} },
//{ t:"Ongoing scripts", i:"mono/ongoingscript.svg?light", g:"tools", h:true, f:args=> {} },

{ t:"Ping", i:"mono/ping.svg?light", g:"utilities", h:false, f:args=> new Ping(args), k:"roundtrip rtt icmp echo reply" },
{ t:"ARP ping", i:"mono/ping.svg?light", g:"utilities", h:true, f:args=> new Ping({entries:[], timeout:500, method:"arp", interval:1000, moveToBottom:false, status:"play"}) },
{ t:"DNS lookup", i:"mono/dns.svg?light", g:"utilities", h:false, f:args=> new DnsLookup(args), k:"resolve resolution" },
Expand All @@ -323,7 +321,10 @@ const MENU = {
{ t:"DHCP client", i:"mono/dhcp.svg?light", g:"utilities", h:false, f:args=> new DhcpDiscover(args), k:"discover" },
{ t:"NTP client", i:"mono/clock.svg?light", g:"utilities", h:false, f:args=> new NtpClient(args), k:"network time" },
{ t:"Site check", i:"mono/websitecheck.svg?light", g:"utilities", h:false, f:args=> new SiteCheck(args), k:"www website" },
{ t:"Reverse proxt", i:"mono/reverseproxy.svg?light", g:"utilities", h:false, f:args=> new ReverseProxy(args), k:"man in the middle" },
//{ t:"Speed test", i:"mono/speedtest.svg?light", g:"utilities", h:false, f:args=> new SpeedTest(args) },
{ t:"SNMP polling", i:"mono/snmp.svg?light", g:"utilities", h:false, f:args=> new Snmp(args) },
{ t:"WMI client", i:"mono/wmi.svg?light", g:"utilities", h:false, f:args=> new Wmi(args), k:"windows management instrumentation viewer" },
{ t:"Secure shell", i:"mono/ssh.svg?light", g:"utilities", h:false, f:()=> new Ssh({host:""}), k:"ssh terminal" },
{ t:"Telnet", i:"mono/telnet.svg?light", g:"utilities", h:true, f:()=> new Telnet({host:""}), k:"terminal" },
//{ t:"RS-232", i:"mono/serialconsole.svg?light", g:"utilities", h:true, f:()=>{}, k:"rs 232 serial terminal console" },
Expand Down Expand Up @@ -353,9 +354,9 @@ const MENU = {
{ t:"Tasks", i:"mono/task.svg?light", g:"manage", h:false, f:()=> new Tasks(), k:"" },
{ t:"Automation", i:"mono/automation.svg?light", g:"manage", h:false, f:()=> new Automation(), k:"" },
{ t:"Certificates", i:"mono/certificate.svg?light", g:"manage", h:false, f:()=> new Certificates(), k: "" },

{ t:"Backup", i:"mono/backup.svg?light", g:"manage", h:false, f:()=> new Backup() },
{ t:"Log", i:"mono/log.svg?light", g:"manage", h:false, f:()=> new Log() },

{ t:"Update", i:"mono/update.svg?light", g:"manage", h:true, f:()=> new About("update") },
{ t:"Update modules", i:"mono/department.svg?light", g:"manage", h:true, f:()=> new About("updatemod") },
{ t:"About", i:"mono/logo.svg?light", g:"manage", h:false, f:()=> new About("about") },
Expand Down
13 changes: 6 additions & 7 deletions Protest/Tools/Cert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,26 @@ public static byte[] Upload(HttpListenerContext ctx, string origin) {
continue;
}

string filename = $"{Data.DIR_CERTIFICATES}{Data.DELIMITER}{name}.pfx";

int counter = 2;
while (File.Exists(filename)) {
filename = $"{Data.DIR_CERTIFICATES}{Data.DELIMITER}{name} {counter++}.pfx";
string newName = $"{name}.pfx";
while (File.Exists($"{Data.DIR_CERTIFICATES}{Data.DELIMITER}{newName}")) {
newName = $"{name} {counter++}.pfx";
}

int startIndex = part.IndexOf("\r\n\r\n") + 4;

byte[] fileContent = encoding.GetBytes(part.Substring(startIndex).TrimEnd('\r', '\n', '-'));

File.WriteAllBytes(filename, fileContent);
File.WriteAllBytes($"{Data.DIR_CERTIFICATES}{Data.DELIMITER}{newName}", fileContent);

Logger.Action(origin, $"Upload certificate: {filename}");
Logger.Action(origin, $"Upload certificate: {newName}");
break;
}
catch { }
}
}

return null;
return List();
}

public static byte[] List() {
Expand Down

0 comments on commit 1673254

Please sign in to comment.