From d351ea3a664cde655077e1c3d08a6e03ff604211 Mon Sep 17 00:00:00 2001 From: Scott Sutherland Date: Wed, 20 Apr 2022 16:52:11 -0500 Subject: [PATCH] Update PowerHuntShares.psm1 --- PowerHuntShares.psm1 | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/PowerHuntShares.psm1 b/PowerHuntShares.psm1 index 76d8614..9d7a65e 100644 --- a/PowerHuntShares.psm1 +++ b/PowerHuntShares.psm1 @@ -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 - } } # ----------------------------------------------------------------------