Notices: This section not yet converted to new layout. Download stats are rolling back out.

osquery

3.3.1

Package test results are passing.

This package was approved as a trusted package on 10/2/2018.

osquery allows you to easily ask questions about your Linux, OSX, and
Windows infrastructure. Whether your goal is intrusion detection,
infrastructure reliability, or compliance, osquery gives you the ability
to empower and inform a broad set of organizations within your company.

### Package Parameters
* /InstallService - This creates a new windows service that will auto-start the daemon.

These parameters can be passed to the installer with the user of -params.
For example: -params '"/InstallService"'.

To install osquery, run the following command from the command line or from PowerShell:

C:\> choco install osquery

To upgrade osquery, run the following command from the command line or from PowerShell:

C:\> choco upgrade osquery

Files

Hide
  • tools\bin\osquery.zip Show
    md5: F43D7951288A73D5316308F52978998C | sha1: 0BCE8BA6DDDE1D1EC6BB6DBC3989E97DCB9F6939 | sha256: 39ADD1D8C021F2B6A1F834772EB821338ABC0C601F1C5A96CCAD5560C3B2F717 | sha512: 8F2B8C6FB7ADDE45BC50AC9C7A51690F7067E614B4D9EF7F1B7D9AC079990CAFCDAFCE7F67CC43E8E623AE40C315EEB43690423C6BCB2DE159D11ABB69C8DD87
  • tools\chocolateyBeforeModify.ps1 Show
    #  Copyright (c) 2014-present, Facebook, Inc.
    #  All rights reserved.
    #
    #  This source code is licensed under both the Apache 2.0 license (found in the
    #  LICENSE file in the root directory of this source tree) and the GPLv2 (found
    #  in the COPYING file in the root directory of this source tree).
    #  You may select, at your option, one of the above-listed licenses.
    . "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)\\osquery_utils.ps1"
    
    $serviceName = 'osqueryd'
    $progData = [System.Environment]::GetEnvironmentVariable('ProgramData')
    $targetFolder = Join-Path $progData "osquery"
    $daemonFolder = Join-Path $targetFolder $serviceName
    $extensionsFolder = Join-Path $targetFolder 'extensions'
    
    # Ensure the service is stopped and processes are not running if exists.
    if ((Get-Service $serviceName -ErrorAction SilentlyContinue) -and `
      (Get-Service $serviceName).Status -eq 'Running') {
      Stop-Service $serviceName
      # If we find zombie processes, ensure they're termintated
      $proc = Get-Process | Where-Object { $_.ProcessName -eq 'osqueryd' }
      if ($proc -ne $null) {
        Stop-Process -Force $proc -ErrorAction SilentlyContinue
      }
    }
    
    # Lastly, ensure that the Deny Write ACLs have been removed before modifying
    if (Test-Path $daemonFolder) {
      Set-DenyWriteAcl $daemonFolder 'Remove'
    }
    if (Test-Path $extensionsFolder) {
      Set-DenyWriteAcl $extensionsFolder 'Remove'
    }
    
  • tools\chocolateyinstall.ps1 Show
    #  Copyright (c) 2014-present, Facebook, Inc.
    #  All rights reserved.
    #
    #  This source code is licensed under both the Apache 2.0 license (found in the
    #  LICENSE file in the root directory of this source tree) and the GPLv2 (found
    #  in the COPYING file in the root directory of this source tree).
    #  You may select, at your option, one of the above-listed licenses.
    . "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)\\osquery_utils.ps1"
    
    $serviceName = 'osqueryd'
    $serviceDescription = 'osquery daemon service'
    $progData = [System.Environment]::GetEnvironmentVariable('ProgramData')
    $targetFolder = Join-Path $progData 'osquery'
    $daemonFolder = Join-Path $targetFolder 'osqueryd'
    $extensionsFolder = Join-Path $targetFolder 'extensions'
    $logFolder = Join-Path $targetFolder 'log'
    $targetDaemonBin = Join-Path $targetFolder 'osqueryd.exe'
    $destDaemonBin = Join-Path $daemonFolder 'osqueryd.exe'
    $packageParameters = $env:chocolateyPackageParameters
    $arguments = @{}
    
    # Ensure the service is stopped and processes are not running if exists.
    if ((Get-Service $serviceName -ErrorAction SilentlyContinue) -and `
      (Get-Service $serviceName).Status -eq 'Running') {
      Stop-Service $serviceName
      # If we find zombie processes, ensure they're termintated
      $proc = Get-Process | Where-Object { $_.ProcessName -eq 'osqueryd' }
      if ($proc -ne $null) {
        Stop-Process -Force $proc -ErrorAction SilentlyContinue
      }
    }
    
    # Lastly, ensure that the Deny Write ACLs have been removed before modifying
    if (Test-Path $daemonFolder) {
      Set-DenyWriteAcl $daemonFolder 'Remove'
    }
    if (Test-Path $extensionsFolder) {
      Set-DenyWriteAcl $extensionsFolder 'Remove'
    }
    
    # Now parse the packageParameters using good old regular expression
    if ($packageParameters) {
      $match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
      $option_name = 'option'
      $value_name = 'value'
    
      if ($packageParameters -match $match_pattern ) {
        $results = $packageParameters | Select-String $match_pattern -AllMatches
        $results.matches | ForEach-Object {
          $arguments.Add(
            $_.Groups[$option_name].Value.Trim(),
            $_.Groups[$value_name].Value.Trim())
        }
      } else {
        Throw "Package Parameters were found but were invalid (REGEX Failure)"
      }
      if ($arguments.ContainsKey("InstallService")) {
        $installService = $true
      }
    } else {
      Write-Debug "No Package Parameters Passed in"
    }
    
    New-Item -Force -Type directory -Path $daemonFolder
    New-Item -Force -Type directory -Path $logFolder
    $packagePath = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)\\bin\\osquery.zip"
    Get-ChocolateyUnzip -FileFullPath $packagePath -Destination $targetFolder
    
    # In order to run osqueryd as a service, we need to have a folder that has a
    # Deny Write ACL to everyone.
    Move-Item -Force -Path $targetDaemonBin -Destination $destDaemonBin
    Set-SafePermissions $daemonFolder
    
    if ($installService) {
      if (-not (Get-Service $serviceName -ErrorAction SilentlyContinue)) {
        Write-Debug 'Installing osquery daemon service.'
        # If the 'install' parameter is passed, we create a Windows service with
        # the flag file in the default location in \ProgramData\osquery\
        New-Service -Name $serviceName -BinaryPathName "$destDaemonBin --flagfile=\ProgramData\osquery\osquery.flags" -DisplayName $serviceName -Description $serviceDescription -StartupType Automatic
    
        # If the osquery.flags file doesn't exist, we create a blank one.
        if (-not (Test-Path "$targetFolder\osquery.flags")) {
          Add-Content "$targetFolder\osquery.flags" $null
        }
      }
      Start-Service $serviceName
    }
    
    # Add osquery binary path to machines path for ease of use.
    Add-ToSystemPath $targetFolder
    
  • tools\chocolateyuninstall.ps1 Show
    #  Copyright (c) 2014-present, Facebook, Inc.
    #  All rights reserved.
    #
    #  This source code is licensed under both the Apache 2.0 license (found in the
    #  LICENSE file in the root directory of this source tree) and the GPLv2 (found
    #  in the COPYING file in the root directory of this source tree).
    #  You may select, at your option, one of the above-listed licenses.
    $progData = [System.Environment]::GetEnvironmentVariable('ProgramData')
    $targetFolder = Join-Path $progData "osquery"
    $serviceName = 'osqueryd'
    
    # Remove the osquery path from the System PATH variable. Note: Here
    # we don't make use of our local vars, as Regex requires escaping the '\'
    $oldPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
    if ($oldPath -imatch [regex]::escape($targetFolder)) {
      $newPath = $oldPath -replace [regex]::escape($targetFolder), $NULL
      [System.Environment]::SetEnvironmentVariable('Path', $newPath, 'Machine')
    }
    
    if ((Get-Service $serviceName -ErrorAction SilentlyContinue)) {
      Stop-Service $serviceName
      
      # If we find zombie processes, ensure they're termintated
      $proc = Get-Process | Where-Object { $_.ProcessName -eq 'osqueryd' }
      if ($proc -ne $null) {
        Stop-Process -Force $proc -ErrorAction SilentlyContinue
      }
    
      Set-Service $serviceName -startuptype 'manual'
      Get-CimInstance -ClassName Win32_Service -Filter "Name='osqueryd'" | Invoke-CimMethod -methodName Delete
    }
    
    if (Test-Path $targetFolder) {
      Remove-Item -Force -Recurse $targetFolder
    } else {
      Write-Debug 'osquery was not found on the system. Nothing to do.'
    }
    
  • tools\LICENSE.txt Show
    # License
    
    By contributing to osquery you agree that your contributions will be licensed
    under the terms of both the [LICENSE-Apache-2.0](LICENSE-Apache-2.0) and the
    [LICENSE-GPL-2.0](LICENSE-GPL-2.0) files in the root of this source tree.
    
    If you're using osquery you are free to choose one of the provided licenses.
    
    `SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-only`
    
  • tools\osquery_utils.ps1 Show
    #  Copyright (c) 2014-present, Facebook, Inc.
    #  All rights reserved.
    #
    #  This source code is licensed under both the Apache 2.0 license (found in the
    #  LICENSE file in the root directory of this source tree) and the GPLv2 (found
    #  in the COPYING file in the root directory of this source tree).
    #  You may select, at your option, one of the above-listed licenses.
    
    # Force Powershell to use TLS 1.2
    [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
    
    # Helper function to add an explicit Deny-Write ACE for the Everyone group
    function Set-DenyWriteAcl {
      [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium")]
      [OutputType('System.Boolean')]
      param(
        [string] $targetDir = '',
        [string] $action = ''
      )
      if (($action -ine 'Add') -and ($action -ine 'Remove')) {
        Write-Debug '[-] Invalid action in Set-DenyWriteAcl.'
        return $false
      }
      if ($PSCmdlet.ShouldProcess($targetDir)) {
        $acl = Get-Acl $targetDir
        $inheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
        $propagationFlag = [System.Security.AccessControl.PropagationFlags]::None
        $permType = [System.Security.AccessControl.AccessControlType]::Deny
    
        $worldSIDObj = New-Object System.Security.Principal.SecurityIdentifier ('S-1-1-0')
        $worldUser = $worldSIDObj.Translate([System.Security.Principal.NTAccount])
        $permission = $worldUser.Value, "write", $inheritanceFlag, $propagationFlag, $permType
        $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
        # We only support adding or removing the ACL
        if ($action -ieq 'add') {
          $acl.SetAccessRule($accessRule)
        } else {
          $acl.RemoveAccessRule($accessRule)
        }
        Set-Acl $targetDir $acl
        return $true
      }
      return $false
    }
    
    # A helper function to set "safe" permissions for osquery binaries
    function Set-SafePermissions {
      [CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium")]
      [OutputType('System.Boolean')]
      param(
        [string] $target = ''
      )
      if ($PSCmdlet.ShouldProcess($target)) {
        $acl = Get-Acl $target
    
        # First, to ensure success, we remove the entirety of the ACL
        $acl.SetAccessRuleProtection($true, $false)
        foreach ($access in $acl.Access) {
          $acl.RemoveAccessRule($access)
        }
        Set-Acl $target $acl
    
        $acl = Get-Acl $target
        $inheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
        $propagationFlag = [System.Security.AccessControl.PropagationFlags]::None
        $permType = [System.Security.AccessControl.AccessControlType]::Allow
    
        # "Safe" permissions in osquery entail the containing folder and binary both
        # are owned by the Administrators group, as well as no account has Write
        # permissions except for the Administrators group and SYSTEM account
        $systemSid = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-18')
        $systemUser = $systemSid.Translate([System.Security.Principal.NTAccount])
    
        $adminsSid = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544')
        $adminsGroup = $adminsSid.Translate([System.Security.Principal.NTAccount])
    
        $usersSid = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-545')
        $usersGroup = $usersSid.Translate([System.Security.Principal.NTAccount])
    
        $permGroups = @($systemUser, $adminsGroup, $usersGroup)
        foreach ($accnt in $permGroups) {
          $grantedPerm = ''
          if ($accnt -eq $usersGroup) {
            $grantedPerm = 'ReadAndExecute'
          } else {
            $grantedPerm = 'FullControl'
          }
          $permission = $accnt.Value, $grantedPerm, $inheritanceFlag, $propagationFlag, $permType
          $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
          $acl.SetAccessRule($accessRule)
        }
        $acl.SetOwner($adminsGroup)
        Set-Acl $target $acl
    
        # Finally set the Administrators group as the owner for all items
        $items = Get-ChildItem -Recurse -Path $target
        foreach ($item in $items) {
          $acl = Get-Acl -Path $item.FullName
          $acl.SetOwner($adminsGroup)
          Set-Acl $item.FullName $acl
        }
    
        return $true
      }
      return $false
    }
    
    # Helper function for running a .bat file from powershell
    function Invoke-BatchFile {
      param(
        [string]$path,
        [string]$parameters
      )
      $tempFile = [IO.Path]::GetTempFileName()
      cmd.exe /c " `"$path`" $parameters && set > `"$tempFile`" "
      Get-Content $tempFile | Foreach-Object {
        if ($_ -match '^(.*?)=(.*)$') {
          Set-Content "env:\$($matches[1])" $matches[2]
        }
      }
      Remove-Item $tempFile
    }
    
    # Constructs a chocolatey .nuspec file in the current directory
    function Write-NuSpec {
      param(
        [string] $packageName,
        [string] $version,
        [string] $authors,
        [string] $owners,
        [string] $projectSource,
        [string] $packageSourceUrl,
        [string] $copyright,
        [string] $license
      )
      $nuspec = @"
    <?xml version="1.0" encoding="utf-8"?>
    <!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
    <package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
      <metadata>
        <id>$packageName</id>
        <title>$packageName</title>
        <version>$version</version>
        <authors>$authors</authors>
        <owners>$owners</owners>
        <summary>$packageName</summary>
        <description>$packageName</description>
        <projectUrl>$projectSource</projectUrl>
        <packageSourceUrl>$packageSourceUrl</packageSourceUrl>
        <tags>$packageName</tags>
        <copyright>$copyright</copyright>
        <licenseUrl>$license</licenseUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
      </metadata>
      <files>
        <file src="local\**" target="local" />
      </files>
    </package>
    "@
      Out-File -Encoding "UTF8" -FilePath "$packageName.nuspec" -InputObject $nuspec
    }
    
    # Derive the location of the osquery build location
    function Get-OsqueryBuildPath {
      [OutputType('System.String')]
      param()
      $loc = Get-Location
      $toks = $loc -Split '\\'
      $ret = ''
      0..$toks.length | ForEach-Object {
        if (Test-Path "$($toks[0..$_] -Join '\')\tools\provision.ps1") {
          $ret = "$($toks[0..$_] -Join '\')\build"
        }
      }
      return $ret
    }
    
    # Helper function to add to the SYSTEM path
    function Add-ToSystemPath {
      param(
        [string] $targetFolder = ''
      )
    
      $oldPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine')
      if (-not ($oldPath -imatch [regex]::escape($targetFolder))) {
        $newPath = $oldPath
        if ($oldPath[-1] -eq ';') {
          $newPath = $newPath + $targetFolder
        } else {
          $newPath = $newPath + ';' + $targetFolder
        }
        [System.Environment]::SetEnvironmentVariable('Path', $newPath, 'Machine')
      }
    }
    
    # A helper function for starting and waiting on processes in powershell
    function Start-OsqueryProcess {
      param(
        [string] $binaryPath = '',
        [array] $binaryArgs = @(),
        [bool] $redirectOutput = $true
      )
      $pinfo = New-Object System.Diagnostics.ProcessStartInfo
      $pinfo.FileName = $binaryPath
      $pinfo.RedirectStandardError = $redirectOutput
      $pinfo.RedirectStandardOutput = $redirectOutput
      $pinfo.UseShellExecute = $false
      $pinfo.Arguments = $binaryArgs
      $pinfo.WorkingDirectory = Get-Location
      $p = New-Object System.Diagnostics.Process
      $p.StartInfo = $pinfo
      $p.Start()
      $p.WaitForExit()
    
      if ($redirectOutput) {
        $stdout = $p.StandardOutput.ReadToEnd()
        $stderr = $p.StandardError.ReadToEnd()
        $exit = $p.ExitCode
        [PSCustomObject] @{
          stdout = $stdout
          stderr = $stderr
          exitcode = $exit
        }
      } else {
        $exit = $p.ExitCode
        [PSCustomObject] @{
          exitcode = $exit
        }
      }
    }
    
    # A helper function to derive the latest VS install
    function Get-VSInfo {
    
      # Attempt to make use of vswhere to derive the build tools scripts
      $vswhere = (Get-Command 'vswhere').Source
      $vswhereArgs = @('-latest', '-legacy')
      $vswhereOut = (Start-OsqueryProcess $vswhere $vswhereArgs).stdout
      $vsinfo = New-Object -TypeName psobject
      $vsinfo | Add-Member -MemberType NoteProperty -Name version -Value ''
      $vsinfo | Add-Member -MemberType NoteProperty -Name location -Value ''
      foreach ($l in $vswhereOut.split([environment]::NewLine)) {
        $toks = $l.split(":")
        if ($toks.Length -lt 2) {
          continue
        }
        if ($toks[0].trim() -like 'installationVersion') {
          $vsinfo.version = $toks[1].Split(".")[0]
        }
        if ($toks[0].trim() -like 'installationPath') {
          $vsinfo.location = [System.String]::Join(":", $toks[1..$toks.Length])
        }
      }
      $vsinfo.location = $vsinfo.location.trim()
      $vsinfo.version = $vsinfo.version.trim()
      return $vsinfo
    }
    
    # A helper function to derive the latest VS install and call vcvarsall.bat
    function Invoke-VcVarsAll {
      $vsinfo = Get-VSInfo
      $vsLoc = $vsinfo.location
      $vsVersion = $vsinfo.version
    
      if ($vsLoc -ne '') {
        $vcvarsall = Join-Path $vsLoc 'VC'
        if ($vsVersion -eq '15') {
          $vcvarsall = Join-Path $vcvarsall '\Auxiliary\Build\vcvarsall.bat'
        } else {
          $vcvarsall = Join-Path $vcvarsall 'vcvarsall.bat'
        }
      
        # Lastly invoke the environment provisioning script
        $null = Invoke-BatchFile "$vcvarsall" "amd64"
        return $true
      }
    
      # As a last ditch effort, attempt to find the env variables set by VS2015
      # in order to derive the location of vcvarsall
      $vsComnTools = [environment]::GetEnvironmentVariable("VS140COMNTOOLS")
      if ($vsComnTools -eq '') {
        return $false
      }
      $vcvarsall = Resolve-Path $(Join-Path "$vsComnTools" "..\..\VC")
      $vcvarsall = Join-Path $vcvarsall 'vcvarsall.bat'
      $null = Invoke-BatchFile "$vcvarsall" "amd64"
      return $true
    }
  • tools\VERIFICATION.txt Show
    To verify the osquery binaries are valid and not corrupted, one can run one of the following:
    
    C:\Users\> Get-FileHash -Algorithm SHA256 .\build\windows10\osquery\Release\osqueryd.exe
    C:\Users\> Get-FileHash -Algorithm SHA1 .\build\windows10\osquery\Release\osqueryd.exe
    C:\Users\> Get-FileHash -Algorithm MD5 .\build\windows10\osquery\Release\osqueryd.exe
    
    And verify that the digests match one of the below values:
    SHA256: DF3EF9522C86ACB971536AE9780AD3DDBDE7E4F794C513377FCF2B4F68F36E38
    SHA1: 9714C075217EB95C33A18947374353A2C52EED3A
    MD5: D322885A2C5D3AE0B4CA70514125C644
    
    

Virus Scan Results

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Dependencies

This package has no dependencies.

Package Maintainer(s)

Software Author(s)

  • Facebook

Copyright

Copyright (c) 2014-present, Facebook, Inc. All rights reserved.

Tags

Release Notes

https://github.com/facebook/osquery/releases/tag/3.3.1

Version History

Version Downloads Last updated Status
osquery 3.3.0 2638 Monday, August 20, 2018 approved
osquery 3.2.9 74497 Monday, July 2, 2018 approved
osquery 3.2.6 30049 Monday, July 2, 2018 approved
osquery 3.2.4 2854 Friday, May 4, 2018 approved
osquery 2.11.2 5464 Monday, February 5, 2018 approved
osquery 2.11.0 1795 Friday, January 12, 2018 approved
osquery 2.10.4 1608 Sunday, December 3, 2017 approved
osquery 2.10.2 806 Thursday, November 16, 2017 approved
osquery 2.9.0 2237 Friday, October 20, 2017 approved
Show More

Discussion for the osquery Package

Ground rules:

  • This discussion is only about osquery and the osquery package. If you have feedback for Chocolatey, please contact the google group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or osquery, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.

comments powered by Disqus
Chocolatey.org uses cookies to enhance the user experience of the site.
Ok