Update PowerHuntShares.psm1

Added sorting on folder group table.
This commit is contained in:
Scott Sutherland 2024-07-18 09:17:00 -05:00 committed by GitHub
parent 0830a520f8
commit f3520f9439
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.72 # Version: v1.73
# 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
{ {
@ -5146,7 +5146,7 @@ This section lists the most common share owners.
</div> </div>
<!-- <!--
|||||||||| PAGE: SHARE FOLDERS |||||||||| PAGE: FOLDER GROUPS
--> -->
<input class="tabInput" name="tabs" type="radio" id="ShareFolders"/> <input class="tabInput" name="tabs" type="radio" id="ShareFolders"/>
@ -5159,16 +5159,16 @@ Folder groups are SMB shares that contain the exact same file listing. Each file
<div style="border-bottom: 1px solid #DEDFE1 ; background-color:#f0f3f5; height:5px; margin-bottom:10px;"></div> <div style="border-bottom: 1px solid #DEDFE1 ; background-color:#f0f3f5; height:5px; margin-bottom:10px;"></div>
<table class="table table-striped table-hover tabledrop"> <table class="table table-striped table-hover tabledrop" id="foldergrouptable">
<thead> <thead>
<tr> <tr>
<th align="left">Unique Share Name Count</th> <th onclick="sortTablefg(0)" align="left">Unique Share Name Count</th>
<th align="left">Affected Share Count</th> <th onclick="sortTablefg(1)" align="left">Affected Share Count</th>
<th align="left">File Group</th> <th onclick="sortTablefg(2)" align="left">File Group</th>
<th align="left">File Count</th> <th onclick="sortTablefg(3)" align="left">File Count</th>
<th align="left">Affected Computers</th> <th onclick="sortTablefg(4)" align="left">Affected Computers</th>
<th align="left">Affected Shares</th> <th onclick="sortTablefg(5)" align="left">Affected Shares</th>
<th align="left">Affected ACLs</th> <th onclick="sortTablefg(6)" align="left">Affected ACLs</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -5629,10 +5629,11 @@ Invoke-HuntSMBShares -Threads 20 -RunSpaceTimeOut 10 -OutputDirectory c:\folder\
<br> <br>
</div> </div>
<script> <script>
var coll = document.getElementsByClassName("collapsible"); // Function to support collapsing and expanding sections
var i; var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) { for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() { coll[i].addEventListener("click", function() {
this.classList.toggle("active"); this.classList.toggle("active");
var content = this.nextElementSibling; var content = this.nextElementSibling;
@ -5643,11 +5644,43 @@ for (i = 0; i < coll.length; i++) {
content.style.maxHeight = "100%"; content.style.maxHeight = "100%";
} }
}); });
} }
let currentSortColumn = -1; let currentSortColumn = -1;
let currentSortDir = "asc"; let currentSortDir = "asc";
// Function to support sorting in tables - folder group table
function sortTablefg(n) {
const table = document.getElementById("foldergrouptable");
const rows = Array.from(table.rows).slice(1);
const dir = currentSortColumn === n && currentSortDir === "asc" ? "desc" : "asc";
currentSortDir = dir;
currentSortColumn = n;
rows.sort((a, b) => {
const cellA = a.cells[n].innerText.toLowerCase();
const cellB = b.cells[n].innerText.toLowerCase();
if (n !== 1) { // Sort numerically for all columns except the second one
const numA = parseFloat(cellA) || 0;
const numB = parseFloat(cellB) || 0;
return dir === "asc" ? numA - numB : numB - numA;
} else {
if (cellA < cellB) return dir === "asc" ? -1 : 1;
if (cellA > cellB) return dir === "asc" ? 1 : -1;
return 0;
}
});
const tbody = table.tBodies[0];
rows.forEach(row => tbody.appendChild(row));
updateSortIndicators(n);
updateFilterCounter();
}
// Function to support sorting in tables - share name table
function sortTable(n) { function sortTable(n) {
const table = document.getElementById("sharenametable"); const table = document.getElementById("sharenametable");
const rows = Array.from(table.rows).slice(1); const rows = Array.from(table.rows).slice(1);