Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit ad32d6c

Browse files
committed
For ./Recon/ :
-(More) PSScriptAnalyzering -Tweaking of synopsis blocks in order to support platyPS -Code standardization -Generated docs
1 parent 59e6f94 commit ad32d6c

14 files changed

+177
-189
lines changed

Recon/Get-ComputerDetails.ps1 renamed to Recon/Get-ComputerDetail.ps1

+53-53
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
function Get-ComputerDetails
1+
function Get-ComputerDetail
22
{
33
<#
44
.SYNOPSIS
55
66
This script is used to get useful information from a computer.
77
8-
Function: Get-ComputerDetails
9-
Author: Joe Bialek, Twitter: @JosephBialek
10-
Required Dependencies: None
11-
Optional Dependencies: None
8+
Function: Get-ComputerDetail
9+
Author: Joe Bialek, Twitter: @JosephBialek
10+
Required Dependencies: None
11+
Optional Dependencies: None
1212
1313
.DESCRIPTION
1414
@@ -25,14 +25,14 @@ Switch: Outputs the data as text instead of objects, good if you are using this
2525
2626
.EXAMPLE
2727
28-
Get-ComputerDetails
28+
Get-ComputerDetail
2929
Gets information about the computer and outputs it as PowerShell objects.
3030
31-
Get-ComputerDetails -ToString
31+
Get-ComputerDetail -ToString
3232
Gets information about the computer and outputs it as raw text.
3333
3434
.NOTES
35-
This script is useful for fingerprinting a server to see who connects to this server (from where), and where users on this server connect to.
35+
This script is useful for fingerprinting a server to see who connects to this server (from where), and where users on this server connect to.
3636
You can also use it to find Powershell scripts and executables which are typically run, and then use this to backdoor those files.
3737
3838
.LINK
@@ -42,6 +42,7 @@ Github repo: https://github.com/clymb3r/PowerShell
4242
4343
#>
4444

45+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
4546
Param(
4647
[Parameter(Position=0)]
4748
[Switch]
@@ -50,14 +51,12 @@ Github repo: https://github.com/clymb3r/PowerShell
5051

5152
Set-StrictMode -Version 2
5253

53-
54-
5554
$SecurityLog = Get-EventLog -LogName Security
56-
$Filtered4624 = Find-4624Logons $SecurityLog
57-
$Filtered4648 = Find-4648Logons $SecurityLog
58-
$AppLockerLogs = Find-AppLockerLogs
55+
$Filtered4624 = Find-4624Logon $SecurityLog
56+
$Filtered4648 = Find-4648Logon $SecurityLog
57+
$AppLockerLogs = Find-AppLockerLog
5958
$PSLogs = Find-PSScriptsInPSAppLog
60-
$RdpClientData = Find-RDPClientConnections
59+
$RdpClientData = Find-RDPClientConnection
6160

6261
if ($ToString)
6362
{
@@ -88,29 +87,29 @@ Github repo: https://github.com/clymb3r/PowerShell
8887
}
8988

9089

91-
function Find-4648Logons
90+
function Find-4648Logon
9291
{
9392
<#
9493
.SYNOPSIS
9594
96-
Retrieve the unique 4648 logon events. This will often find cases where a user is using remote desktop to connect to another computer. It will give the
95+
Retrieve the unique 4648 logon events. This will often find cases where a user is using remote desktop to connect to another computer. It will give the
9796
the account that RDP was launched with and the account name of the account being used to connect to the remote computer. This is useful
9897
for identifying normal authenticaiton patterns. Other actions that will trigger this include any runas action.
9998
100-
Function: Find-4648Logons
101-
Author: Joe Bialek, Twitter: @JosephBialek
102-
Required Dependencies: None
103-
Optional Dependencies: None
99+
Function: Find-4648Logon
100+
Author: Joe Bialek, Twitter: @JosephBialek
101+
Required Dependencies: None
102+
Optional Dependencies: None
104103
105104
.DESCRIPTION
106105
107-
Retrieve the unique 4648 logon events. This will often find cases where a user is using remote desktop to connect to another computer. It will give the
106+
Retrieve the unique 4648 logon events. This will often find cases where a user is using remote desktop to connect to another computer. It will give the
108107
the account that RDP was launched with and the account name of the account being used to connect to the remote computer. This is useful
109108
for identifying normal authenticaiton patterns. Other actions that will trigger this include any runas action.
110109
111110
.EXAMPLE
112111
113-
Find-4648Logons
112+
Find-4648Logon
114113
Gets the unique 4648 logon events.
115114
116115
.NOTES
@@ -120,11 +119,12 @@ Gets the unique 4648 logon events.
120119
Blog: http://clymb3r.wordpress.com/
121120
Github repo: https://github.com/clymb3r/PowerShell
122121
#>
122+
123123
Param(
124124
$SecurityLog
125125
)
126126

127-
$ExplicitLogons = $SecurityLog | Where {$_.InstanceID -eq 4648}
127+
$ExplicitLogons = $SecurityLog | Where-Object {$_.InstanceID -eq 4648}
128128
$ReturnInfo = @{}
129129

130130
foreach ($ExplicitLogon in $ExplicitLogons)
@@ -216,18 +216,18 @@ Github repo: https://github.com/clymb3r/PowerShell
216216
return $ReturnInfo
217217
}
218218

219-
function Find-4624Logons
219+
function Find-4624Logon
220220
{
221221
<#
222222
.SYNOPSIS
223223
224224
Find all unique 4624 Logon events to the server. This will tell you who is logging in and how. You can use this to figure out what accounts do
225225
network logons in to the server, what accounts RDP in, what accounts log in locally, etc...
226226
227-
Function: Find-4624Logons
228-
Author: Joe Bialek, Twitter: @JosephBialek
229-
Required Dependencies: None
230-
Optional Dependencies: None
227+
Function: Find-4624Logon
228+
Author: Joe Bialek, Twitter: @JosephBialek
229+
Required Dependencies: None
230+
Optional Dependencies: None
231231
232232
.DESCRIPTION
233233
@@ -236,7 +236,7 @@ network logons in to the server, what accounts RDP in, what accounts log in loca
236236
237237
.EXAMPLE
238238
239-
Find-4624Logons
239+
Find-4624Logon
240240
Find unique 4624 logon events.
241241
242242
.NOTES
@@ -250,7 +250,7 @@ Github repo: https://github.com/clymb3r/PowerShell
250250
$SecurityLog
251251
)
252252

253-
$Logons = $SecurityLog | Where {$_.InstanceID -eq 4624}
253+
$Logons = $SecurityLog | Where-Object {$_.InstanceID -eq 4624}
254254
$ReturnInfo = @{}
255255

256256
foreach ($Logon in $Logons)
@@ -362,25 +362,25 @@ Github repo: https://github.com/clymb3r/PowerShell
362362
}
363363

364364

365-
function Find-AppLockerLogs
365+
function Find-AppLockerLog
366366
{
367367
<#
368368
.SYNOPSIS
369369
370370
Look through the AppLocker logs to find processes that get run on the server. You can then backdoor these exe's (or figure out what they normally run).
371371
372-
Function: Find-AppLockerLogs
373-
Author: Joe Bialek, Twitter: @JosephBialek
374-
Required Dependencies: None
375-
Optional Dependencies: None
372+
Function: Find-AppLockerLog
373+
Author: Joe Bialek, Twitter: @JosephBialek
374+
Required Dependencies: None
375+
Optional Dependencies: None
376376
377377
.DESCRIPTION
378378
379379
Look through the AppLocker logs to find processes that get run on the server. You can then backdoor these exe's (or figure out what they normally run).
380380
381381
.EXAMPLE
382382
383-
Find-AppLockerLogs
383+
Find-AppLockerLog
384384
Find process creations from AppLocker logs.
385385
386386
.NOTES
@@ -390,9 +390,10 @@ Find process creations from AppLocker logs.
390390
Blog: http://clymb3r.wordpress.com/
391391
Github repo: https://github.com/clymb3r/PowerShell
392392
#>
393+
393394
$ReturnInfo = @{}
394395

395-
$AppLockerLogs = Get-WinEvent -LogName "Microsoft-Windows-AppLocker/EXE and DLL" -ErrorAction SilentlyContinue | Where {$_.Id -eq 8002}
396+
$AppLockerLogs = Get-WinEvent -LogName "Microsoft-Windows-AppLocker/EXE and DLL" -ErrorAction SilentlyContinue | Where-Object {$_.Id -eq 8002}
396397

397398
foreach ($Log in $AppLockerLogs)
398399
{
@@ -434,10 +435,10 @@ Function Find-PSScriptsInPSAppLog
434435
Go through the PowerShell operational log to find scripts that run (by looking for ExecutionPipeline logs eventID 4100 in PowerShell app log).
435436
You can then backdoor these scripts or do other malicious things.
436437
437-
Function: Find-AppLockerLogs
438-
Author: Joe Bialek, Twitter: @JosephBialek
439-
Required Dependencies: None
440-
Optional Dependencies: None
438+
Function: Find-AppLockerLog
439+
Author: Joe Bialek, Twitter: @JosephBialek
440+
Required Dependencies: None
441+
Optional Dependencies: None
441442
442443
.DESCRIPTION
443444
@@ -456,12 +457,12 @@ Find unique PowerShell scripts being executed from the PowerShell operational lo
456457
Blog: http://clymb3r.wordpress.com/
457458
Github repo: https://github.com/clymb3r/PowerShell
458459
#>
460+
459461
$ReturnInfo = @{}
460-
$Logs = Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" -ErrorAction SilentlyContinue | Where {$_.Id -eq 4100}
462+
$Logs = Get-WinEvent -LogName "Microsoft-Windows-PowerShell/Operational" -ErrorAction SilentlyContinue | Where-Object {$_.Id -eq 4100}
461463

462464
foreach ($Log in $Logs)
463465
{
464-
$ContainsScriptName = $false
465466
$LogDetails = $Log.Message -split "`r`n"
466467

467468
$FoundScriptName = $false
@@ -506,27 +507,26 @@ Github repo: https://github.com/clymb3r/PowerShell
506507
}
507508

508509

509-
Function Find-RDPClientConnections
510+
Function Find-RDPClientConnection
510511
{
511512
<#
512513
.SYNOPSIS
513514
514-
Search the registry to find saved RDP client connections. This shows you what connections an RDP client has remembered, indicating what servers the user
515+
Search the registry to find saved RDP client connections. This shows you what connections an RDP client has remembered, indicating what servers the user
515516
usually RDP's to.
516517
517-
Function: Find-RDPClientConnections
518-
Author: Joe Bialek, Twitter: @JosephBialek
519-
Required Dependencies: None
520-
Optional Dependencies: None
518+
Function: Find-RDPClientConnection
519+
Author: Joe Bialek, Twitter: @JosephBialek
520+
Required Dependencies: None
521+
Optional Dependencies: None
521522
522523
.DESCRIPTION
523524
524-
Search the registry to find saved RDP client connections. This shows you what connections an RDP client has remembered, indicating what servers the user
525-
usually RDP's to.
525+
Search the registry to find saved RDP client connections. This shows you what connections an RDP client has remembered, indicating what servers the user usually RDP's to.
526526
527527
.EXAMPLE
528528
529-
Find-RDPClientConnections
529+
Find-RDPClientConnection
530530
Find unique saved RDP client connections.
531531
532532
.NOTES
@@ -550,7 +550,7 @@ Github repo: https://github.com/clymb3r/PowerShell
550550
{
551551
$Server = $Server.PSChildName
552552
$UsernameHint = (Get-ItemProperty -Path "HKU:\$($UserSid)\Software\Microsoft\Terminal Server Client\Servers\$($Server)").UsernameHint
553-
553+
554554
$Key = $UserSid + "::::" + $Server + "::::" + $UsernameHint
555555

556556
if (!$ReturnInfo.ContainsKey($Key))

0 commit comments

Comments
 (0)