Skip to content

uditgaurav/windows-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

windows-service

Command to run the scripts

  • For install.ps1
powershell -Command "& { Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/uditgaurav/windows-service/master/bin/install.ps1' -OutFile 'install.ps1' -UseBasicParsing; .\install.ps1 -AdminPass 'Your Password' -InfraId 'YourInfraId' -AccessKey 'YourAccessKey' -ServerUrl 'YourServerUrl' -LogDirectory 'YourLogDirectory' -TaskPollIntervalSeconds 5 -TaskUpdateIntervalSeconds 5 -UpdateRetries 5 -UpdateRetryIntervalSeconds 5 -ChaosInfraLivenessUpdateIntervalSeconds 5 -ChaosInfraLogFileMaxSizeMb 5 -ChaosInfraLogFileMaxBackups 2 -CustomTlsCertificate 'YourCustomTlsCertificate' -HttpProxy 'YourHttpProxy' -HttpClientTimeout '30s' }"
  • For uninstall.ps1
powershell -Command "& { Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/uditgaurav/windows-service/master/bin/uninstall.ps1' -OutFile 'uninstall.ps1' -UseBasicParsing; .\uninstall.ps1 -ServiceName 'WindowsChaosInfrastructure' -TimeoutSeconds 180 -ChaosBaseDirectory 'C:\HCE' -CheckIntervalSeconds 10 }"

Create Binary

GOOS=windows GOARCH=amd64 go build

windows-service.exe*

Launch Service On Windows

C:\Users\Administrator\Downloads>sc create WindowsChaosAgent binPath= "C:\Users\Administrator\Downloads\windows-chaos-agent.exe"
[SC] CreateService SUCCESS

C:\Users\Administrator\Downloads>sc start WindowsChaosAgent

SERVICE_NAME: WindowsChaosAgent
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 2  START_PENDING
                                (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x7d0
        PID                : 1980
        FLAGS              :
Screenshot 2024-01-11 at 8 05 44 PM

Get the status of the service

C:\Users\Administrator\Downloads>sc query WindowsChaosAgent

SERVICE_NAME: WindowsChaosAgent
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Delete the service

C:\Users\Administrator\Downloads>sc delete WindowsChaosAgent
[SC] DeleteService SUCCESS

TBD

  • Batch script for installation of the service in Administrator mode.
  • Pass flags to the service for input or override the chaos parameters.
  • Proper event logging in windows eventviewer.
  • Service Management - that is via manual trigger or system trigger.
  • Once the agent is running it should be able to run the powershell script in administrator mode.
  • Cleanup script.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published