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
# 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.
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>
</div>
<script>
// --------------------------
// Function to support collapsing and expanding sections
// --------------------------
@ -6074,21 +6073,28 @@ function updateChart() {
// --------------------------
// Bar Chart Code - Interesting Files
// Interesting Files - Bar Chart
// --------------------------
// Initialize ApexCharts
const chartOptions = {
chart: {
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: [{
name: 'Count',
data: [4, 3, 3]
}],
xaxis: {
$ChartCategoryCat
$ChartCategoryCat
labels: {
style: {
fontSize: '18px',
@ -6152,7 +6158,14 @@ const chartOptions = {
const chart = new ApexCharts(document.querySelector("#chart"), chartOptions);
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
// --------------------------
@ -6211,7 +6224,7 @@ function updateSortIndicators(tableId, columnIndex) {
}
// Filtering Function
function applyFiltersAndSort(tableId, searchInputId, filterCounterId, paginationId) {
function applyFiltersAndSort(tableId, searchInputId, filterCounterId, paginationId, columnId = null) {
const table = document.getElementById(tableId);
const tbody = table.querySelector('tbody');
const rows = Array.from(tbody.rows);
@ -6226,7 +6239,9 @@ function applyFiltersAndSort(tableId, searchInputId, filterCounterId, pagination
currentFilteredRows = rows.filter(row => { // Update filtered rows
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");
return matchesTextFilter && matchesCheckboxFilter;
@ -6242,8 +6257,8 @@ function applyFiltersAndSort(tableId, searchInputId, filterCounterId, pagination
}
function updateFilterCounter(filterCounterId, visibleRows) {
const filterCounter = document.getElementById(filterCounterId);
filterCounter.textContent = ```${visibleRows} matches found``;
const filterCounter = document.getElementById(filterCounterId);
filterCounter.textContent = ```${visibleRows} matches found``;
}
// Pagination Functions
@ -6368,6 +6383,7 @@ applyFiltersAndSort('foldergrouptable', 'filterInputTwo', 'filterCounterTwo', 'p
document.getElementById('filterInputIF').addEventListener("keyup", () => applyFiltersAndSort('InterestingFileTable', 'filterInputIF', 'filterCounterIF', 'paginationIF'));
applyFiltersAndSort('InterestingFileTable', 'filterInputIF', 'filterCounterIF', 'paginationIF');
// CSV export function
function extractAndDownloadCSV(tableId, columnIndex) {
const regex = /\\\\[^\s\\]+\\[^\s\\]+\\[^\s\\]+/g; // UNC path regex
const uncPaths = [];
@ -6401,7 +6417,6 @@ function extractAndDownloadCSV(tableId, columnIndex) {
// Clean up by removing the link
document.body.removeChild(link);
}
</script>
</div>