Explicitly define the file directory
Osquery was not working with Fleet after deployment due to wrong directories. The following command installs the osqueryd service with --flagfile=\ProgramData\osquery\osquery.flags" however osquery.flags found at "C:\Program Files\osquery\osquery.flags" ``` "c:\Program Files\osquery\osqueryd\osqueryd.exe" -ArgumentList "--install" -Wait ``` The original osquery.flags defines the certfile.crt to be in "C:\programdata\osquery", it should be in "c:\Program Files\osquery\" instead.
This commit is contained in:
		| @@ -8,7 +8,8 @@ choco install -y --limit-output --no-progress osquery | Out-String  # Apparently | |||||||
| $service = Get-WmiObject -Class Win32_Service -Filter "Name='osqueryd'" | $service = Get-WmiObject -Class Win32_Service -Filter "Name='osqueryd'" | ||||||
| If (-not ($service)) { | If (-not ($service)) { | ||||||
|   Write-Host "Setting osquery to run as a service" |   Write-Host "Setting osquery to run as a service" | ||||||
|   Start-Process -FilePath "c:\Program Files\osquery\osqueryd\osqueryd.exe" -ArgumentList "--install" -Wait |   New-Service -Name "osqueryd" -BinaryPathName "C:\Program Files\osquery\osqueryd\osqueryd.exe --flagfile=`"C:\Program Files\osquery\osquery.flags`"" | ||||||
|  |  | ||||||
|   # Copy over the config and packs from the Palantir repo |   # Copy over the config and packs from the Palantir repo | ||||||
|   Copy-Item "c:\Users\vagrant\AppData\Local\Temp\osquery-configuration-master\Classic\Endpoints\Windows\*" "c:\Program Files\osquery" |   Copy-Item "c:\Users\vagrant\AppData\Local\Temp\osquery-configuration-master\Classic\Endpoints\Windows\*" "c:\Program Files\osquery" | ||||||
|   Copy-Item "c:\Users\vagrant\AppData\Local\Temp\osquery-configuration-master\Classic\Endpoints\packs" -Path "c:\Program Files\osquery" |   Copy-Item "c:\Users\vagrant\AppData\Local\Temp\osquery-configuration-master\Classic\Endpoints\packs" -Path "c:\Program Files\osquery" | ||||||
| @@ -27,12 +28,11 @@ If (-not ($service)) { | |||||||
|   (Get-Content "c:\Program Files\osquery\osquery.flags") -replace 'tls.endpoint.server.com', 'kolide:8412' | Set-Content "c:\Program Files\osquery\osquery.flags" |   (Get-Content "c:\Program Files\osquery\osquery.flags") -replace 'tls.endpoint.server.com', 'kolide:8412' | Set-Content "c:\Program Files\osquery\osquery.flags" | ||||||
|   ## Change path to secrets |   ## Change path to secrets | ||||||
|   (Get-Content "c:\Program Files\osquery\osquery.flags") -replace 'path\\to\\file\\containing\\secret.txt', 'Program Files\osquery\kolide_secret.txt' | Set-Content "c:\Program Files\osquery\osquery.flags" |   (Get-Content "c:\Program Files\osquery\osquery.flags") -replace 'path\\to\\file\\containing\\secret.txt', 'Program Files\osquery\kolide_secret.txt' | Set-Content "c:\Program Files\osquery\osquery.flags" | ||||||
|  |   ## Change path to certfile | ||||||
|  |   (Get-Content "c:\Program Files\osquery\osquery.flags") -replace 'c:\\ProgramData\\osquery\\certfile.crt', 'c:\Program Files\osquery\certfile.crt' | Set-Content "c:\Program Files\osquery\osquery.flags" | ||||||
|   ## Add certfile.crt |   ## Add certfile.crt | ||||||
|   Copy-Item "c:\vagrant\resources\fleet\server.crt" "c:\Program Files\osquery\certfile.crt" |   Copy-Item "c:\vagrant\resources\fleet\server.crt" "c:\Program Files\osquery\certfile.crt" | ||||||
|   ### --- TLS CONFIG ENDS --- |   ### --- TLS CONFIG ENDS --- | ||||||
|  |  | ||||||
|   Stop-service osqueryd |  | ||||||
|   Start-Sleep -s 5 |  | ||||||
|   Start-Service osqueryd |   Start-Service osqueryd | ||||||
| } | } | ||||||
| else { | else { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sunny Neo
					Sunny Neo