Update PowerHuntShares.psm1

Feature: interesting files page, added the ability to click the category on the bar chart to filter the interesting files table rows for that category.
This commit is contained in:
Scott Sutherland 2024-07-24 08:49:19 -05:00 committed by GitHub
parent 4a6be74349
commit efc57d864c
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.86 # Version: v1.87
# 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
{ {
@ -6017,7 +6017,6 @@ The left menu can be used to find summary data, the scan summary is in the table
<br> <br>
</div> </div>
<script> <script>
// -------------------------- // --------------------------
// Function to support collapsing and expanding sections // Function to support collapsing and expanding sections
// -------------------------- // --------------------------
@ -6074,14 +6073,21 @@ function updateChart() {
// -------------------------- // --------------------------
// Bar Chart Code - Interesting Files // Interesting Files - Bar Chart
// -------------------------- // --------------------------
// Initialize ApexCharts // Initialize ApexCharts
const chartOptions = { const chartOptions = {
chart: { chart: {
type: 'bar', type: 'bar',
height: 150 height: 150,
events: {
dataPointSelection: function(event, chartContext, config) {
// Get the clicked category
var category = config.w.config.xaxis.categories[config.dataPointIndex];
handleCategoryClick(category);
}
}
}, },
series: [{ series: [{
name: 'Count', name: 'Count',
@ -6153,6 +6159,13 @@ const chartOptions = {
const chart = new ApexCharts(document.querySelector("#chart"), chartOptions); const chart = new ApexCharts(document.querySelector("#chart"), chartOptions);
chart.render(); chart.render();
// apply category filter to interestiong table rows
function handleCategoryClick(category) {
//alert("Category clicked: " + category);
document.getElementById('filterInputIF').value = category;
applyFiltersAndSort('InterestingFileTable', 'filterInputIF', 'filterCounterIF', 'paginationIF',2);
}
// -------------------------- // --------------------------
// Sorting Functions // Sorting Functions
// -------------------------- // --------------------------
@ -6211,7 +6224,7 @@ function updateSortIndicators(tableId, columnIndex) {
} }
// Filtering Function // Filtering Function
function applyFiltersAndSort(tableId, searchInputId, filterCounterId, paginationId) { function applyFiltersAndSort(tableId, searchInputId, filterCounterId, paginationId, columnId = null) {
const table = document.getElementById(tableId); const table = document.getElementById(tableId);
const tbody = table.querySelector('tbody'); const tbody = table.querySelector('tbody');
const rows = Array.from(tbody.rows); const rows = Array.from(tbody.rows);
@ -6226,7 +6239,9 @@ function applyFiltersAndSort(tableId, searchInputId, filterCounterId, pagination
currentFilteredRows = rows.filter(row => { // Update filtered rows currentFilteredRows = rows.filter(row => { // Update filtered rows
const cells = Array.from(row.cells); const cells = Array.from(row.cells);
const matchesTextFilter = cells.some(cell => cell.innerText.toLowerCase().includes(filterInputValue)); const matchesTextFilter = columnId !== null
? cells[columnId].innerText.toLowerCase().includes(filterInputValue)
: cells.some(cell => cell.innerText.toLowerCase().includes(filterInputValue));
const matchesCheckboxFilter = checkedFilters.every(filter => row.getAttribute(filter) === "Yes"); const matchesCheckboxFilter = checkedFilters.every(filter => row.getAttribute(filter) === "Yes");
return matchesTextFilter && matchesCheckboxFilter; return matchesTextFilter && matchesCheckboxFilter;
@ -6368,6 +6383,7 @@ applyFiltersAndSort('foldergrouptable', 'filterInputTwo', 'filterCounterTwo', 'p
document.getElementById('filterInputIF').addEventListener("keyup", () => applyFiltersAndSort('InterestingFileTable', 'filterInputIF', 'filterCounterIF', 'paginationIF')); document.getElementById('filterInputIF').addEventListener("keyup", () => applyFiltersAndSort('InterestingFileTable', 'filterInputIF', 'filterCounterIF', 'paginationIF'));
applyFiltersAndSort('InterestingFileTable', 'filterInputIF', 'filterCounterIF', 'paginationIF'); applyFiltersAndSort('InterestingFileTable', 'filterInputIF', 'filterCounterIF', 'paginationIF');
// CSV export function
function extractAndDownloadCSV(tableId, columnIndex) { function extractAndDownloadCSV(tableId, columnIndex) {
const regex = /\\\\[^\s\\]+\\[^\s\\]+\\[^\s\\]+/g; // UNC path regex const regex = /\\\\[^\s\\]+\\[^\s\\]+\\[^\s\\]+/g; // UNC path regex
const uncPaths = []; const uncPaths = [];
@ -6402,7 +6418,6 @@ function extractAndDownloadCSV(tableId, columnIndex) {
document.body.removeChild(link); document.body.removeChild(link);
} }
</script> </script>
</div> </div>
</div> </div>