Skip to content

Commit dd48d2b

Browse files
Add basic event generator and 2022 CI
1 parent 24a668d commit dd48d2b

File tree

4 files changed

+94
-1
lines changed

4 files changed

+94
-1
lines changed

.github/workflows/ci.yml/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: ci-build
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
7+
jobs:
8+
build-image:
9+
runs-on: windows-2022
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Build Image
15+
shell: bash
16+
env:
17+
GITHUB_HEAD_REF: ${{ github.head_ref }}
18+
run: |
19+
export IMAGE_TAG=$(echo "${GITHUB_HEAD_REF}" | sed "s/\//-/g")-2022
20+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
21+
docker build -t windows-event-gen:${IMAGE_TAG} .

Dockerfile.2022

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mcr.microsoft.com/powershell:7.4-windowsservercore-ltsc2022
2+
3+
LABEL maintainer="Paul Crooks <[email protected]>"
4+
5+
RUN mkdir EventGen
6+
7+
COPY Entrypoint.ps1 EventGen/
8+
9+
ENTRYPOINT ["powershell", "C:/EventGen/Entrypoint.ps1"]

Entrypoint.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Write-Host "Windows Event Generator"
2+
3+
function LogIfNotEmpty() {
4+
param (
5+
$logFile
6+
)
7+
$fileSize = (Get-Item -Path $logFile).Length
8+
if ($fileSize -ne 0) {
9+
Write-Host "START $logFile"
10+
Get-Content $logFile
11+
Write-Host "END $logFile"
12+
}
13+
}
14+
15+
$eventList = @(
16+
[PSCustomObject]@{name = "SAM Read"; cmd="esentutl.exe"; args="/y /vss %SystemRoot%/system32/config/SAM_ps /d %temp%/SAM_ps"}
17+
[PSCustomObject]@{name = "Clear Windows Event Log"; cmd="powershell"; args="Clear-EventLog -LogName System"}
18+
[PSCustomObject]@{name = "Encoded Powershell Execution"; cmd="powershell"; args="-enc bABzAA=="}
19+
[PSCustomObject]@{name = "Enumerate Logged-on Users"; cmd="powershell"; args="query user"}
20+
)
21+
22+
$stdoutFile = "Output.txt"
23+
$stderrFile = "Error.txt"
24+
25+
while ($true) {
26+
foreach ( $event in $eventList ) {
27+
Write-Host "Running" $event.name
28+
29+
$processOptions = @{
30+
ArgumentList = $event.args
31+
FilePath = $event.cmd
32+
NoNewWindow = $true
33+
RedirectStandardOutput = $stdoutFile
34+
RedirectStandardError = $stderrFile
35+
}
36+
Start-Process @processOptions
37+
38+
LogIfNotEmpty($stdoutFile)
39+
LogIfNotEmpty($stderrFile)
40+
41+
Start-Sleep 10
42+
43+
Remove-Item Output.txt
44+
Remove-Item Error.txt
45+
46+
Write-Host "**********************************************"
47+
}
48+
}

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
# windows-event-generator
1+
# Windows Event Generator
2+
3+
Very basic Event Generator for Windows. This is intended only for Agent developers to make some event noise.
4+
5+
## Versions
6+
- Windows Server 2022
7+
8+
## Build
9+
```powershell
10+
PS > docker build -t win-event-gen:latest-2022 -f .\Dockerfile.2022 .
11+
```
12+
13+
## Run
14+
```powershell
15+
PS > docker run -t --rm win-event-gen:latest-2022
16+
```

0 commit comments

Comments
 (0)