|
| 1 | +import subprocess |
| 2 | +from pathlib import Path |
| 3 | + |
| 4 | +BASE = Path.cwd() |
| 5 | + |
| 6 | +def create_dirs(): |
| 7 | + folders = [ |
| 8 | + ".github/workflows", "src/edr_agent", "src/edr_kernel", |
| 9 | + "src/common", "cmake", "scripts", "policies" |
| 10 | + ] |
| 11 | + for folder in folders: |
| 12 | + Path(BASE / folder).mkdir(parents=True, exist_ok=True) |
| 13 | + |
| 14 | +def write(path, content): |
| 15 | + Path(BASE / path).write_text(content.strip() + "\n", encoding="utf-8") |
| 16 | + |
| 17 | +def git_init(): |
| 18 | + subprocess.run(["git", "init"], check=True) |
| 19 | + subprocess.run(["git", "add", "."], check=True) |
| 20 | + subprocess.run(["git", "commit", "-m", "Initial commit"], check=True) |
| 21 | + |
| 22 | +def main(): |
| 23 | + create_dirs() |
| 24 | + |
| 25 | + write("README.md", "# Chain_of_Trust\nOpen-source, kernel-backed, TPM-sealed EDR.") |
| 26 | + write("CMakeLists.txt", "cmake_minimum_required(VERSION 3.25)\nproject(Chain_of_Trust)") |
| 27 | + write("CMakePresets.json", """{ |
| 28 | + "version": 6, |
| 29 | + "configurePresets": [ |
| 30 | + { |
| 31 | + "name": "ci-windows", |
| 32 | + "generator": "Visual Studio 17 2022", |
| 33 | + "binaryDir": "${sourceDir}/out/build/${presetName}", |
| 34 | + "architecture": "x64", |
| 35 | + "cacheVariables": { |
| 36 | + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" |
| 37 | + } |
| 38 | + } |
| 39 | + ] |
| 40 | +}""") |
| 41 | + |
| 42 | + write("vcpkg.json", """{ |
| 43 | + "name": "chain-of-trust", |
| 44 | + "version": "1.0.0", |
| 45 | + "dependencies": [ |
| 46 | + "detours", |
| 47 | + "gtest" |
| 48 | + ] |
| 49 | +}""") |
| 50 | + |
| 51 | + write(".github/workflows/build.yml", """name: Build & Test |
| 52 | +on: |
| 53 | + push: |
| 54 | + branches: [ main ] |
| 55 | + pull_request: |
| 56 | + branches: [ main ] |
| 57 | +jobs: |
| 58 | + build: |
| 59 | + runs-on: windows-2022 |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + - run: vcpkg install detours:x64-windows gtest:x64-windows |
| 63 | + - run: cmake --preset=ci-windows |
| 64 | + - run: cmake --build --preset=ci-windows --config Release |
| 65 | + - run: ctest --preset=ci-windows -C Release --output-on-failure |
| 66 | +""") |
| 67 | + |
| 68 | + write("src/edr_agent/main.cpp", """#include <windows.h> |
| 69 | +int main() { |
| 70 | + return 0; |
| 71 | +} |
| 72 | +""") |
| 73 | + |
| 74 | + write("src/edr_kernel/edrdrv.c", """#include <ntddk.h> |
| 75 | +NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) { |
| 76 | + UNREFERENCED_PARAMETER(DriverObject); |
| 77 | + UNREFERENCED_PARAMETER(RegistryPath); |
| 78 | + return STATUS_SUCCESS; |
| 79 | +} |
| 80 | +""") |
| 81 | + |
| 82 | + write("src/edr_kernel/edrdrv.inf", """[Version] |
| 83 | +Signature="$WINDOWS NT$" |
| 84 | +Class=Sample |
| 85 | +ClassGuid={78A1C341-4539-11d3-B88D-00C04FAD5171} |
| 86 | +Provider=%ManufacturerName% |
| 87 | +DriverVer=09/20/2025,1.0.0.0 |
| 88 | +
|
| 89 | +[Manufacturer] |
| 90 | +%ManufacturerName%=Standard,NTx86,NTamd64 |
| 91 | +
|
| 92 | +[Standard.NTx86] |
| 93 | +%DeviceName%=Install, Root\\EDRDriver |
| 94 | +
|
| 95 | +[Standard.NTamd64] |
| 96 | +%DeviceName%=Install, Root\\EDRDriver |
| 97 | +
|
| 98 | +[Strings] |
| 99 | +ManufacturerName="Chain_of_Trust" |
| 100 | +DeviceName="EDR Kernel Driver" |
| 101 | +""") |
| 102 | + |
| 103 | + write("scripts/Build.ps1", """cmake --preset=ci-windows |
| 104 | +cmake --build --preset=ci-windows --config Release |
| 105 | +""") |
| 106 | + |
| 107 | + write("scripts/Install.ps1", """Write-Host "Installing EDR driver..." |
| 108 | +pnputil /add-driver src\\edr_kernel\\edrdrv.inf /install |
| 109 | +""") |
| 110 | + |
| 111 | + write("policies/WDAC_EDR.xml", """<SiPolicy xmlns="urn:schemas-microsoft-com:sipolicy"> |
| 112 | + <PolicyName>Chain_of_Trust_EDR</PolicyName> |
| 113 | + <Rules> |
| 114 | + <!-- Add WDAC rules here --> |
| 115 | + </Rules> |
| 116 | +</SiPolicy> |
| 117 | +""") |
| 118 | + |
| 119 | + git_init() |
| 120 | + print("[+] Chain_of_Trust Repo erfolgreich generiert und initialisiert.") |
| 121 | + |
| 122 | +if __name__ == "__main__": |
| 123 | + main() |
| 124 | + |
0 commit comments