1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
|
Param( [String]$OutputFilename = "" )
function JAWS-ENUM { write-output "`nRunning J.A.W.S. Enumeration" $output = "" $output = $output + "############################################################`r`n" $output = $output + "## J.A.W.S. (Just Another Windows Enum Script) ##`r`n" $output = $output + "## ##`r`n" $output = $output + "## https://github.com/411Hall/JAWS ##`r`n" $output = $output + "## ##`r`n" $output = $output + "############################################################`r`n" $output = $output + "`r`n" $win_version = (Get-WmiObject -class Win32_OperatingSystem) $output = $output + "Windows Version: " + (($win_version.caption -join $win_version.version) + "`r`n") $output = $output + "Architecture: " + (($env:processor_architecture) + "`r`n") $output = $output + "Hostname: " + (($env:ComputerName) + "`r`n") $output = $output + "Current User: " + (($env:username) + "`r`n") $output = $output + "Current Time\Date: " + (get-date) $output = $output + "`r`n" $output = $output + "`r`n" write-output " - Gathering User Information" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Users`r`n" $output = $output + "-----------------------------------------------------------`r`n" $adsi = [ADSI]"WinNT://$env:COMPUTERNAME" $adsi.Children | where {$_.SchemaClassName -eq 'user'} | Foreach-Object { $groups = $_.Groups() | Foreach-Object {$_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)} $output = $output + "----------`r`n" $output = $output + "Username: " + $_.Name + "`r`n" $output = $output + "Groups: " + $groups + "`r`n" } $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Network Information`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (ipconfig | out-string) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Arp`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (arp -a | out-string) $output = $output + "`r`n" $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " NetStat`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (netstat -ano | out-string) $output = $output + "`r`n" $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Firewall Status`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + "`r`n" $Firewall = New-Object -com HNetCfg.FwMgr $FireProfile = $Firewall.LocalPolicy.CurrentProfile if ($FireProfile.FirewallEnabled -eq $False) { $output = $output + ("Firewall is Disabled" + "`r`n") } else { $output = $output + ("Firwall is Enabled" + "`r`n") } $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " FireWall Rules`r`n" $output = $output + "-----------------------------------------------------------`r`n" Function Get-FireWallRule {Param ($Name, $Direction, $Enabled, $Protocol, $profile, $action, $grouping) $Rules=(New-object -comObject HNetCfg.FwPolicy2).rules If ($name) {$rules= $rules | where-object {$_.name -like $name}} If ($direction) {$rules= $rules | where-object {$_.direction -eq $direction}} If ($Enabled) {$rules= $rules | where-object {$_.Enabled -eq $Enabled}} If ($protocol) {$rules= $rules | where-object {$_.protocol -eq $protocol}} If ($profile) {$rules= $rules | where-object {$_.Profiles -bAND $profile}} If ($Action) {$rules= $rules | where-object {$_.Action -eq $Action}} If ($Grouping) {$rules= $rules | where-object {$_.Grouping -like $Grouping}} $rules} $output = $output + (Get-firewallRule -enabled $true | sort direction,applicationName,name | format-table -property Name , localPorts,applicationname | out-string) $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Hosts File Content`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + "`r`n" $output = $output + ((get-content $env:windir\System32\drivers\etc\hosts | out-string) + "`r`n") $output = $output + "`r`n" write-output " - Gathering Processes, Services and Scheduled Tasks" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Processes`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + ((Get-WmiObject win32_process | Select-Object Name,ProcessID,@{n='Owner';e={$_.GetOwner().User}},CommandLine | sort name | format-table -wrap -autosize | out-string) + "`r`n") $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Scheduled Tasks`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + "Current System Time: " + (get-date) $output = $output + (schtasks /query /FO CSV /v | convertfrom-csv | where { $_.TaskName -ne "TaskName" } | select "TaskName","Run As User", "Task to Run" | fl | out-string) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Services`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (get-service | Select Name,DisplayName,Status | sort status | Format-Table -Property * -AutoSize | Out-String -Width 4096) $output = $output + "`r`n" write-output " - Gathering Installed Software" $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Installed Programs`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (get-wmiobject -Class win32_product | select Name, Version, Caption | ft -hidetableheaders -autosize| out-string -Width 4096) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Installed Patches`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (Get-Wmiobject -class Win32_QuickFixEngineering -namespace "root\cimv2" | select HotFixID, InstalledOn| ft -autosize | out-string ) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Program Folders`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + "`n`rC:\Program Files`r`n" $output = $output + "-------------" $output = $output + (get-childitem "C:\Program Files" -EA SilentlyContinue | select Name | ft -hidetableheaders -autosize| out-string) $output = $output + "C:\Program Files (x86)`r`n" $output = $output + "-------------------" $output = $output + (get-childitem "C:\Program Files (x86)" -EA SilentlyContinue | select Name | ft -hidetableheaders -autosize| out-string) $output = $output + "`r`n" write-output " - Gathering File System Information" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Files with Full Control and Modify Access`r`n" $output = $output + "-----------------------------------------------------------`r`n" $files = get-childitem C:\ foreach ($file in $files){ try { $output = $output + (get-childitem "C:\$file" -include *.ps1,*.bat,*.com,*.vbs,*.txt,*.html,*.conf,*.rdp,.*inf,*.ini -recurse -EA SilentlyContinue | get-acl -EA SilentlyContinue | select path -expand access | where {$_.identityreference -notmatch "BUILTIN|NT AUTHORITY|EVERYONE|CREATOR OWNER|NT SERVICE"} | where {$_.filesystemrights -match "FullControl|Modify"} | ft @{Label="";Expression={Convert-Path $_.Path}} -hidetableheaders -autosize | out-string -Width 4096) } catch { $output = $output + "`nFailed to read more files`r`n" } }
$output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Folders with Full Control and Modify Access`r`n" $output = $output + "-----------------------------------------------------------`r`n" $folders = get-childitem C:\ foreach ($folder in $folders){ try { $output = $output + (Get-ChildItem -Recurse "C:\$folder" -EA SilentlyContinue | ?{ $_.PSIsContainer} | get-acl | select path -expand access | where {$_.identityreference -notmatch "BUILTIN|NT AUTHORITY|CREATOR OWNER|NT SERVICE"} | where {$_.filesystemrights -match "FullControl|Modify"} | select path,filesystemrights,IdentityReference | ft @{Label="";Expression={Convert-Path $_.Path}} -hidetableheaders -autosize | out-string -Width 4096) } catch { $output = $output + "`nFailed to read more folders`r`n" } } $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Mapped Drives`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (Get-WmiObject -Class Win32_LogicalDisk | select DeviceID, VolumeName | ft -hidetableheaders -autosize | out-string -Width 4096) $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Unquoted Service Paths`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (cmd /c 'wmic service get name,displayname,pathname,startmode |findstr /i "auto" |findstr /i /v "c:\windows\\" |findstr /i /v """') $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Recent Documents`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (get-childitem "C:\Users\$env:username\AppData\Roaming\Microsoft\Windows\Recent" -EA SilentlyContinue | select Name | ft -hidetableheaders | out-string ) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Potentially Interesting Files in Users Directory `r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (get-childitem "C:\Users\" -recurse -Include *.zip,*.rar,*.7z,*.gz,*.conf,*.rdp,*.kdbx,*.crt,*.pem,*.ppk,*.txt,*.xml,*.vnc.*.ini,*.vbs,*.bat,*.ps1,*.cmd -EA SilentlyContinue | %{$_.FullName } | out-string) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " 10 Last Modified Files in C:\User`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (Get-ChildItem 'C:\Users' -recurse -EA SilentlyContinue | Sort {$_.LastWriteTime} | %{$_.FullName } | select -last 10 | ft -hidetableheaders | out-string) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " MUICache Files`r`n" $output = $output + "-----------------------------------------------------------`r`n" get-childitem "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\" -EA SilentlyContinue | foreach { $CurrentKey = (Get-ItemProperty -Path $_.PsPath) if ($CurrentKey -match "C:\\") { $output = $output + ($_.Property -join "`r`n") } } $output = $output + "`r`n" $output = $output + "`r`n" write-output " - Looking for Simple Priv Esc Methods" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " System Files with Passwords`r`n" $output = $output + "-----------------------------------------------------------`r`n" $files = ("unattended.xml", "sysprep.xml", "autounattended.xml","unattended.inf", "sysprep.inf", "autounattended.inf","unattended.txt", "sysprep.txt", "autounattended.txt") $output = $output + (get-childitem C:\ -recurse -include $files -EA SilentlyContinue | Select-String -pattern "<Value>" | out-string) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " AlwaysInstalledElevated Registry Key`r`n" $output = $output + "-----------------------------------------------------------`r`n" $HKLM = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer" $HKCU = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Installer" if (($HKLM | test-path) -eq "True") { if (((Get-ItemProperty -Path $HKLM -Name AlwaysInstallElevated).AlwaysInstallElevated) -eq 1) { $output = $output + "AlwaysInstallElevated enabled on this host!" } } if (($HKCU | test-path) -eq "True") { if (((Get-ItemProperty -Path $HKCU -Name AlwaysInstallElevated).AlwaysInstallElevated) -eq 1) { $output = $output + "AlwaysInstallElevated enabled on this host!" } } $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Stored Credentials`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + (cmdkey /list | out-string) $output = $output + "`r`n" $output = $output + "-----------------------------------------------------------`r`n" $output = $output + " Checking for AutoAdminLogon `r`n" $output = $output + "-----------------------------------------------------------`r`n" $Winlogon = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" if (get-itemproperty -path $Winlogon -Name AutoAdminLogon -ErrorAction SilentlyContinue) { if ((get-itemproperty -path $Winlogon -Name AutoAdminLogon).AutoAdminLogon -eq 1) { $Username = (get-itemproperty -path $Winlogon -Name DefaultUserName).DefaultUsername $output = $output + "The default username is $Username `r`n" $Password = (get-itemproperty -path $Winlogon -Name DefaultPassword).DefaultPassword $output = $output + "The default password is $Password `r`n" $DefaultDomainName = (get-itemproperty -path $Winlogon -Name DefaultDomainName).DefaultDomainName $output = $output + "The default domainname is $DefaultDomainName `r`n" } } $output = $output + "`r`n" if ($OutputFilename.length -gt 0) { $output | Out-File -FilePath $OutputFileName -encoding utf8 } else { clear-host write-output $output } }
if ($OutputFilename.length -gt 0) { Try { [io.file]::OpenWrite($OutputFilename).close() JAWS-ENUM } Catch { Write-Warning "`nUnable to write to output file $OutputFilename, Check path and permissions" } } else { JAWS-ENUM }
|