Skip to content

Commit

Permalink
Fix WMI client inconsistencies
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Apr 13, 2024
1 parent ee10756 commit d76000a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 41 deletions.
25 changes: 0 additions & 25 deletions Protest/Front/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,6 @@ const WIN = {
}
},

SetTaskBarPosition: position => {
//TODO:
switch (position) {
case "left":
break;

case "right":
break;

case "top":
taskbar.style.top = "0";
taskbar.style.bottom = "";
container.style.top = `${WIN.iconSize}px`;
container.style.bottom = "0";
break;

default:
taskbar.style.top = "";
taskbar.style.bottom = "0";
container.style.top = "0";
container.style.bottom = `${WIN.iconSize}px`;
break;
}
},

GridWindows: ()=> {
if (WIN.array.length === 0) return;

Expand Down
10 changes: 7 additions & 3 deletions Protest/Front/wmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,17 @@ class Wmi extends Window {
try {
const response = await fetch(`wmi/killprocess?target=${encodeURIComponent(targetHost)}&pid=${pid}`);
if (response.status !== 200) return;
const text = await response.text();

if (text === "ok")
const json = await response.json();
if (json.error) throw(json.error);



if (json.status === "ok")
table.removeChild(tr);
else {
td.removeChild(terminateButton);
td.textContent = text;
td.textContent = json.status;
}
}
catch (ex) {
Expand Down
14 changes: 6 additions & 8 deletions Protest/Protocols/Wmi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ namespace Protest.Protocols;

[SupportedOSPlatform("windows")]
internal static class Wmi {
//private static readonly ArraySegment<byte> CODE_OK = new ArraySegment<byte>("ok"u8.ToArray());
private static readonly ArraySegment<byte> CODE_ACCESS_DENIED = new ArraySegment<byte>("access denied"u8.ToArray());
private static readonly ArraySegment<byte> CODE_INSUFFICIENT_PRIVILEGE = new ArraySegment<byte>("insufficient privilege"u8.ToArray());
private static readonly ArraySegment<byte> CODE_UNKNOWN = new ArraySegment<byte>("unknown failure"u8.ToArray());
private static readonly ArraySegment<byte> CODE_PATH_NOT_FOUND = new ArraySegment<byte>("path not found"u8.ToArray());
private static readonly ArraySegment<byte> CODE_AUTHENTICATION_FAILED = new ArraySegment<byte>("authentication failed"u8.ToArray());
//private static readonly ArraySegment<byte> CODE_INVALID = new ArraySegment<byte>("invalid parameter"u8.ToArray());
private static readonly ArraySegment<byte> CODE_ACCESS_DENIED = new ArraySegment<byte>("{\"error\":\"access denied\"}"u8.ToArray());
private static readonly ArraySegment<byte> CODE_INSUFFICIENT_PRIVILEGE = new ArraySegment<byte>("{\"error\":\"insufficient privilege\"}"u8.ToArray());
private static readonly ArraySegment<byte> CODE_UNKNOWN = new ArraySegment<byte>("{\"error\":\"unknown failure\"}"u8.ToArray());
private static readonly ArraySegment<byte> CODE_PATH_NOT_FOUND = new ArraySegment<byte>("{\"error\":\"path not found\"}"u8.ToArray());
private static readonly ArraySegment<byte> CODE_AUTHENTICATION_FAILED = new ArraySegment<byte>("{\"error\":\"authentication failed\"}"u8.ToArray());

/*public static ManagementScope WmiScope(string host, string impersonation, string username, string password) {
ImpersonationLevel impersonationLevel = impersonation.ToLower() switch {
Expand Down Expand Up @@ -432,7 +430,7 @@ public static byte[] WmiKillProcess(Dictionary<string, string> parameters) {
ManagementObjectCollection moc;
try {
moc = new ManagementObjectSearcher(scope.Path.ToString(), "SELECT * FROM Win32_Process WHERE ProcessId = " + pid).Get();
if (moc.Count == 0) return "no such process id"u8.ToArray();
if (moc.Count == 0) return "{\"error\":\"no such process id\"}"u8.ToArray();
}
catch {
return CODE_UNKNOWN.Array;
Expand Down
2 changes: 1 addition & 1 deletion Protest/Tasks/Lifeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static partial class Lifeline {
public static TaskWrapper task;

public static void Initialize() {
//TODO: autostart
//TODO: auto-start
StartTask("system");
}

Expand Down
4 changes: 0 additions & 4 deletions Protest/Tools/PasswordStrength.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ public static byte[] GetEntropy() {

bool first = true;
foreach (Database.Entry entry in DatabaseInstances.users.dictionary.Values) {
//TODO: hasPassword

List<string> words = new List<string>();
foreach (KeyValuePair<string, Database.Attribute> pair in entry.attributes) {
if (pair.Key.Contains("password"))
Expand Down Expand Up @@ -168,8 +166,6 @@ public static byte[] GetEntropy() {
}

foreach (Database.Entry entry in DatabaseInstances.devices.dictionary.Values) {
//TODO: hasPassword

List<string> words = new List<string>();
foreach (KeyValuePair<string, Database.Attribute> pair in entry.attributes) {
if (pair.Key.Contains("password"))
Expand Down

0 comments on commit d76000a

Please sign in to comment.