Update PowerHuntShares.psm1

Converted computer os chart to counts.
This commit is contained in:
Scott Sutherland 2024-10-01 07:54:55 -05:00 committed by GitHub
parent 326458e9c6
commit 21f5248b65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,7 +4,7 @@
#-------------------------------------- #--------------------------------------
# Author: Scott Sutherland, 2024 NetSPI # Author: Scott Sutherland, 2024 NetSPI
# License: 3-clause BSD # License: 3-clause BSD
# Version: v1.141 # Version: v1.142
# References: This script includes custom code and code taken and modified from the open source projects PowerView, Invoke-Ping, and Invoke-Parrell. # References: This script includes custom code and code taken and modified from the open source projects PowerView, Invoke-Ping, and Invoke-Parrell.
function Invoke-HuntSMBShares function Invoke-HuntSMBShares
{ {
@ -2560,7 +2560,7 @@ function Invoke-HuntSMBShares
$DomainComputerOSSum | $DomainComputerOSSum |
foreach{ foreach{
$TargetOSName = $_.os $TargetOSName = $_.os
$TargetOSValue = $_.percent $TargetOSValue = $_.count
$DomainComputerOSListJsNames = $DomainComputerOSListJsNames + ",'" + $TargetOSName + "'" $DomainComputerOSListJsNames = $DomainComputerOSListJsNames + ",'" + $TargetOSName + "'"
$DomainComputerOSListJsValues = $DomainComputerOSListJsValues + "," + $TargetOSValue $DomainComputerOSListJsValues = $DomainComputerOSListJsValues + "," + $TargetOSValue
} }
@ -10478,17 +10478,17 @@ const ChartComputersDisco = new ApexCharts(document.querySelector("#ChartCompute
ChartComputersDisco.render(); ChartComputersDisco.render();
// -------------------------- // --------------------------
// Computers Page - Computers Count by OS (Data shown as percentages) // Computers Page - Computers Count by OS
// -------------------------- // --------------------------
// Calculate the total sum of the series to convert values to percentages // Calculate the total sum of the series
const total = $DomainComputerOSListJsValues.reduce((a, b) => a + b, 0); const total = $DomainComputerOSListJsValues
// Map the OS names and values into a combined array and sort by values in descending order // Map the OS names and values into a combined array and sort by values in descending order
const sortedData = $DomainComputerOSListJsNames.map((name, index) => ({ const sortedData = $DomainComputerOSListJsNames.map((name, index) => ({
name: name, name: name,
value: ($DomainComputerOSListJsValues[index] / total) * 100 // Convert to percentages value: $DomainComputerOSListJsValues[index]
})).sort((a, b) => b.value - a.value); // Sort by percentage in descending order })).sort((a, b) => b.value - a.value);
// Extract the sorted names and values back into separate arrays // Extract the sorted names and values back into separate arrays
const sortedNames = sortedData.map(item => item.name); const sortedNames = sortedData.map(item => item.name);
@ -10497,7 +10497,7 @@ const sortedValues = sortedData.map(item => item.value);
// Initialize ApexCharts with sorted data // Initialize ApexCharts with sorted data
const ChartComputersOSOptions = { const ChartComputersOSOptions = {
series: [{ series: [{
name: 'Percentage', name: 'Count',
data: sortedValues // Use sorted values for percentages data: sortedValues // Use sorted values for percentages
}], }],
chart: { chart: {
@ -10526,7 +10526,7 @@ const ChartComputersOSOptions = {
tooltip: { tooltip: {
y: { y: {
formatter: function (val) { formatter: function (val) {
return val.toFixed(2) + "%"; // Show tooltips as percentages return val.toFixed(2) // + "%"; // Show tooltips as percentages
} }
} }
}, },
@ -10541,7 +10541,7 @@ const ChartComputersOSOptions = {
} }
}, },
title: { title: {
text: 'Percentage', // Custom label for x-axis text: 'Count', // Custom label for x-axis
style: { style: {
fontSize: '12px', fontSize: '12px',
fontWeight: 'normal', fontWeight: 'normal',
@ -10567,7 +10567,7 @@ const ChartComputersOSOptions = {
} }
}, },
title: { title: {
text: 'Computer Count OS Percentage Summary', text: 'Computer Count by OS',
align: 'center', // Aligns the title align: 'center', // Aligns the title
margin: 10, // Space between the title and the chart margin: 10, // Space between the title and the chart
style: { style: {