-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entrypoint.ps1
48 lines (39 loc) · 1.37 KB
/
Entrypoint.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
Write-Host "Windows Event Generator"
function LogIfNotEmpty() {
param (
$logFile
)
$fileSize = (Get-Item -Path $logFile).Length
if ($fileSize -ne 0) {
Write-Host "START $logFile"
Get-Content $logFile
Write-Host "END $logFile"
}
}
$eventList = @(
[PSCustomObject]@{name = "SAM Read"; cmd="esentutl.exe"; args="/y /vss %SystemRoot%/system32/config/SAM_ps /d %temp%/SAM_ps"}
[PSCustomObject]@{name = "Clear Windows Event Log"; cmd="powershell"; args="Clear-EventLog -LogName System"}
[PSCustomObject]@{name = "Encoded Powershell Execution"; cmd="powershell"; args="-enc bABzAA=="}
[PSCustomObject]@{name = "Enumerate Logged-on Users"; cmd="powershell"; args="query user"}
)
$stdoutFile = "Output.txt"
$stderrFile = "Error.txt"
while ($true) {
foreach ( $event in $eventList ) {
Write-Host "Running" $event.name
$processOptions = @{
ArgumentList = $event.args
FilePath = $event.cmd
NoNewWindow = $true
RedirectStandardOutput = $stdoutFile
RedirectStandardError = $stderrFile
}
Start-Process @processOptions
LogIfNotEmpty($stdoutFile)
LogIfNotEmpty($stderrFile)
Start-Sleep 10
Remove-Item Output.txt
Remove-Item Error.txt
Write-Host "**********************************************"
}
}