Update PowerHuntShares.psm1

This commit is contained in:
Scott Sutherland 2022-04-20 16:52:11 -05:00 committed by GitHub
parent abc41f450a
commit d351ea3a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@
#--------------------------------------
# Author: Scott Sutherland, 2022 NetSPI
# License: 3-clause BSD
# Version: v1.24
# Version: v1.25
# 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
{
@ -245,29 +245,12 @@ function Invoke-HuntSMBShares
# Create output directory
# ----------------------------------------------------------------------
if(Test-Path $OutputDirectory){
# Create sub directory for output
try{
if(-not $AnalyzeOnly){
# Verify output directory path
$Time = Get-Date -UFormat "%m/%d/%Y %R"
$FolderDateTime = Get-Date -Format "MMddyyyyHHmmss"
$OutputDirectoryBase = "$OutputDirectory\SmbShareHunt-$FolderDateTime"
# Create sub directories
mkdir $OutputDirectoryBase | Out-Null
$SubDir = "Results"
mkdir "$OutputDirectoryBase\$SubDir" | Out-Null
$OutputDirectory = "$OutputDirectoryBase\Results"
Write-Output " [*][$Time] Output Directory: $OutputDirectoryBase"
}
}catch{
Write-Output " [x][$Time] The $OutputDirectory was not writable."
# good
}else{
$Time = Get-Date -UFormat "%m/%d/%Y %R"
Write-Output " [x][$Time] The $OutputDirectory was not writable or does not exist."
Write-Output " [!][$Time] Aborting operation."
break
}
}
# ----------------------------------------------------------------------