Skip to content

Commit

Permalink
Issues...
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Aug 21, 2024
1 parent 693acc3 commit 7328076
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 62 deletions.
38 changes: 29 additions & 9 deletions Protest/Front/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ class Issues extends List {
};

static SEVERITY_COLOR = {
1 : "var(--clr-dark)",
1 : "rgb(8,96,240)",
2 : "rgb(240,140,8)",
3 : "var(--clr-error)",
4 : "var(--clr-critical)",
};

static CATEGORY_ICON = {
"Directory" : "url(mono/directory.svg)",
"Password" : "url(mono/lock.svg)",
"Printer component" : "url(mono/printer.svg)",
"CPU usage" : "url(mono/cpu.svg)",
Expand Down Expand Up @@ -127,13 +128,14 @@ class Issues extends List {
this.list.appendChild(element);

this.link.data[key] = {
key: key,
key : {v: key},
severity: {v: issue.severity},
issue : {v: issue.issue},
target : {v: issue.target},
category: {v: issue.category},
source : {v: issue.source},
isUser : {v: issue.isUser},
file : {v: issue.file},
};

this.InflateElement(element, this.link.data[key]);
Expand Down Expand Up @@ -204,11 +206,11 @@ class Issues extends List {

let value;
if (propertyName === "severity") {
value = Issues.SEVERITY_TEXT[entry[this.columnsElements[i].textContent].v];
value = Issues.SEVERITY_TEXT[entry[propertyName].v];
icon.style.left = this.columnsElements[i].style.left;
}
else {
value = entry[this.columnsElements[i].textContent].v
value = entry[propertyName].v
}

if (value.length === 0) continue;
Expand All @@ -231,6 +233,16 @@ class Issues extends List {
newAttr.style.backgroundPosition = "0px 50%";
newAttr.style.backgroundRepeat = "no-repeat";
}
else if (propertyName === "target") {
newAttr.style.left = this.columnsElements[i].style.left;
newAttr.style.width = this.columnsElements[i].style.width;

newAttr.style.paddingLeft = "24px";
newAttr.style.backgroundImage = entry.isUser.v ? "url(mono/user.svg)" : "url(mono/gear.svg)";
newAttr.style.backgroundSize = "20px 20px";
newAttr.style.backgroundPosition = "0px 50%";
newAttr.style.backgroundRepeat = "no-repeat";
}
else {
newAttr.style.left = this.columnsElements[i].style.left;
newAttr.style.width = this.columnsElements[i].style.width;
Expand All @@ -239,15 +251,23 @@ class Issues extends List {

element.onclick = ()=> {
if (this.selected) this.selected.style.backgroundColor = "";

this.args.select = entry.key;

this.args.select = entry.key.v;
this.selected = element;
element.style.backgroundColor = "var(--clr-select)";
};

element.ondblclick = ()=> {

element.ondblclick = event=> {
event.stopPropagation();
const file = element.getAttribute("id");
const entry = this.link.data[file];
if (entry) {
if (entry.isUser.v) {
LOADER.OpenUserByFile(entry.file.v);
}
else {
LOADER.OpenDeviceByFile(entry.file.v);
}
}
};
}
}
7 changes: 4 additions & 3 deletions Protest/Front/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,14 @@ class List extends Window {
found = [];
const keywords = this.args.find.toLowerCase().split(" ").filter(o=> o.length > 0);

for (let i = 0; i < filtered.length; i++) {
for (let i=0; i<filtered.length; i++) {
let matched = true;

for (let j = 0; j < keywords.length; j++) {
for (let j=0; j<keywords.length; j++) {
let wordIncluded = false;
for (const key in this.link.data[filtered[i]]) {
if (this.link.data[filtered[i]][key].v.toLowerCase().includes(keywords[j])) {
const value = this.link.data[filtered[i]][key].v;
if (typeof value === "string" && value.toLowerCase().includes(keywords[j])) {
wordIncluded = true;
break;
}
Expand Down
39 changes: 11 additions & 28 deletions Protest/Tools/LiveStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,21 @@ public static async void UserStats(HttpListenerContext ctx) {
}

object mutex = new object();
try {
if (OperatingSystem.IsWindows()
&& entry.attributes.TryGetValue("username", out Database.Attribute username)
&& Issues.CheckDomainUser(entry, out Issues.Issue[] issues, out long lockedTime)) {

if (OperatingSystem.IsWindows() && entry.attributes.TryGetValue("username", out Database.Attribute username)) {
try {
SearchResult result = Kerberos.GetUser(username.value);
if (result != null) {
if (result.Properties["lastLogonTimestamp"].Count > 0) {
if (Int64.TryParse(result.Properties["lastLogonTimestamp"][0].ToString(), out long time) && time > 0) {
WsWriteText(ws, $"{{\"info\":\"Last logon: {DateTime.FromFileTime(time)}\",\"source\":\"Kerberos\"}}", mutex);
}
}

if (result.Properties["lastLogoff"].Count > 0) {
if (Int64.TryParse(result.Properties["lastLogoff"][0].ToString(), out long time) && time > 0) {
WsWriteText(ws, $"{{\"info\":\"Last logoff: {DateTime.FromFileTime(time)}\",\"source\":\"Kerberos\"}}", mutex);
}
}

if (result.Properties["badPasswordTime"].Count > 0) {
if (Int64.TryParse(result.Properties["badPasswordTime"][0].ToString(), out long time) && time > 0) {
WsWriteText(ws, $"{{\"info\":\"Bad password time: {(DateTime.FromFileTime(time))}\",\"source\":\"Kerberos\"}}", mutex);
}
}
if (lockedTime > 0) {
WsWriteText(ws, $"{{\"lockedOut\":\"{DateTime.FromFileTime(lockedTime)}\",\"source\":\"Kerberos\"}}", mutex);
}

if (result.Properties["lockoutTime"].Count > 0) {
if (Int64.TryParse(result.Properties["lockoutTime"][0].ToString(), out long time) && time > 0) {
WsWriteText(ws, $"{{\"lockedOut\":\"{DateTime.FromFileTime(time)}\",\"source\":\"Kerberos\"}}", mutex);
}
}
for (int i = 0; i < issues.Length; i++) {
WsWriteText(ws, issues[i].ToLiveStatsJsonBytes(), mutex);
}
}
catch { }
}
catch { }

if (Issues.CheckPasswordStrength(entry, true, out Issues.Issue? weakPsIssue)) {
WsWriteText(ws, weakPsIssue?.ToLiveStatsJsonBytes(), mutex);
Expand Down Expand Up @@ -210,7 +193,7 @@ public static async void DeviceStats(HttpListenerContext ctx) {
string hostname = _hostname.value;
SearchResult result = Kerberos.GetWorkstation(hostname);

if (result != null) {
if (result is not null) {
if (result.Properties["lastLogonTimestamp"].Count > 0) {
string time = Kerberos.FileTimeString(result.Properties["lastLogonTimestamp"][0].ToString());
if (time.Length > 0) {
Expand Down
16 changes: 8 additions & 8 deletions Protest/Workers/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,14 @@ public static byte[] DevicesTask(HttpListenerContext ctx, Dictionary<string, str
}
}

dns ??= "false";
wmi ??= "false";
kerberos ??= "false";
snmp2 ??= "false";
snmp3 ??= "false";
portScan ??= "false";
retriesStr ??= "0";
intervalStr ??= "-1";
dns ??= "false";
wmi ??= "false";
kerberos ??= "false";
snmp2 ??= "false";
snmp3 ??= "false";
portScan ??= "false";
retriesStr ??= "0";
intervalStr ??= "-1";

SnmpProfiles.Profile[] snmpProfiles = SnmpProfiles.Load();

Expand Down
Loading

0 comments on commit 7328076

Please sign in to comment.