diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..6f15b22 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,11 @@ +name: Linting +on: [push, pull_request] +jobs: + lint: + # Run per push for internal contributers. This isn't possible for forked pull requests, + # so we'll need to run on PR events for external contributers. + # String comparison below is case insensitive. + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + runs-on: ubuntu-latest + steps: + - uses: 'phantomcyber/dev-cicd-tools/github-actions/lint@main' diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml new file mode 100644 index 0000000..23d31c5 --- /dev/null +++ b/.github/workflows/semgrep.yml @@ -0,0 +1,28 @@ +name: Semgrep +on: + pull_request_target: + branches: + - next + - main + push: + branches: + - next + - main +jobs: + semgrep: + runs-on: ubuntu-latest + steps: + - if: github.event_name == 'push' + run: | + echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_ENV + echo "REF=${{ github.REF }}" >> $GITHUB_ENV + - if: github.event_name == 'pull_request_target' + run: | + echo "REPOSITORY=${{ github.event.pull_request.head.repo.full_name }}" >> $GITHUB_ENV + echo "REF=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV + - uses: 'phantomcyber/dev-cicd-tools/github-actions/semgrep@main' + with: + SEMGREP_DEPLOYMENT_ID: ${{ secrets.SEMGREP_DEPLOYMENT_ID }} + SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }} + REPOSITORY: ${{ github.repository }} + REF: ${{ github.ref }} diff --git a/.github/workflows/start-release.yml b/.github/workflows/start-release.yml new file mode 100644 index 0000000..7bbce79 --- /dev/null +++ b/.github/workflows/start-release.yml @@ -0,0 +1,13 @@ +name: Start Release +on: + workflow_dispatch: + push: + tags: + - '*-beta*' +jobs: + start-release: + runs-on: ubuntu-latest + steps: + - uses: 'phantomcyber/dev-cicd-tools/github-actions/start-release@main' + with: + GITHUB_TOKEN: ${{ secrets.SOAR_APPS_TOKEN }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 38e1594..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,3 +0,0 @@ -include: - - project: 'phantom/appscript' - file: 'gitlab-ci/.gitlab-ci.yml' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..43120b9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,11 @@ +repos: +- repo: https://github.com/phantomcyber/dev-cicd-tools + rev: v1.9 + hooks: + - id: org-hook + - id: package-app-dependencies +- repo: https://github.com/Yelp/detect-secrets + rev: v1.1.0 + hooks: + - id: detect-secrets + args: ['--no-verify', '--exclude-files', '^wmi.json$'] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b3cc507 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,2 @@ +# Contributing +For more information about contributing to Splunk SOAR Apps please take a look at our app [Contribution Guide](https://github.com/splunk-soar-connectors/.github/blob/main/.github/CONTRIBUTING.md)! diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e920929 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2016-2022 Splunk Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 7af3212..0000000 --- a/Makefile +++ /dev/null @@ -1,81 +0,0 @@ -# Makefile for Phantom apps CI -# created oct-2018 by michellel & jacobd at splunk -# -# Usage: -# make local - to bring up docker for local dev -# make - pipeline targets build / upload -# make secrets - list any required secret values -# -# Credentials can be passed as environment variables or docker secret files -# under /run/secrets - - -# Variables set by GitLab -WORKSPACE ?= $(shell grep WORKSPACE: docker-compose.yml | cut -d : -f 2) -CI_COMMIT_REF_NAME ?= $(shell git branch | grep "\*" | cut -d ' ' -f 2) - -# Git variables -GIT_SERVER ?= cd.splunkdev.com -RELEASE_GROUP ?= phantom -RELEASE_REPO ?= app_release -RELEASE_DIR := $(WORKSPACE)/$(RELEASE_REPO) - -# Docker variables -export IMAGE_TAG ?= $(shell grep ^image: .gitlab-ci.yml | cut -d : -f 3) - -# Variables sent to app_release for test/build/release scripts -export APP_DIR ?= $(shell pwd) -export APP_REPO_NAME ?= $(shell basename $(APP_DIR)) -export APP_BRANCH ?= $(CI_COMMIT_REF_NAME) -export TEST_BRANCH ?= master - -# Pipeline secrets -SECRETS = app_artf_token gitlab_api_token app_deploy_key -ifneq ($(wildcard /run/secrets/.),) - # Load secrets if specified in filesystem rather than variables - export GITLAB_API_TOKEN ?= $(shell cat /run/secrets/gitlab_api_token) - export APP_ARTF_TOKEN ?= $(shell cat /run/secrets/app_artf_token) - export APP_DEPLOY_KEY ?= $(shell cat /run/secrets/app_deploy_key) -endif - -APP_RELEASE_TARGETS = test upload build release -.PHONY: checkout local secrets list_secrets $(APP_RELEASE_TARGETS) - -checkout: $(RELEASE_DIR) -$(RELEASE_DIR): /tmp/ssh-agent - $(info Clone the $(RELEASE_REPO) repo into $(RELEASE_DIR)) - @git clone git@$(GIT_SERVER):$(RELEASE_GROUP)/$(RELEASE_REPO).git $(RELEASE_DIR) - $(info Checkout the test branch: $(TEST_BRANCH)) - @cd $(RELEASE_DIR) && git checkout $(TEST_BRANCH) - -$(APP_RELEASE_TARGETS): checkout - @cd $(RELEASE_DIR) && make $@ - -local: secrets - $(info Setting up local development instance) - $(info Make sure you have run:) - $(info docker login repo.splunk.com) - docker-compose up -d - $(info Working directory is mapped to $(DOCKER_WORK). To connect:) - $(info docker exec -it -w $(DOCKER_WORK) local_qa-local_1 bash) - -/tmp/ssh-agent: - $(info Starting ssh agent) - @mkdir -p -m 700 ~/.ssh - @ssh-keyscan -p 22 $(GIT_SERVER) >> ~/.ssh/known_hosts - @eval $(shell ssh-agent -s >$@) - @if [ -s /run/secrets/app_deploy_key ]; then \ - cp /run/secrets/app_deploy_key ~/.ssh/id_rsa && \ - source $@ && ssh-add ~/.ssh/id_rsa; \ - else \ - cp ~/.ssh/app_deploy_key ~/.ssh/id_rsa && \ - chmod 600 ~/.ssh/id_rsa && \ - cat $@ && \ - source $@ && ssh-add ~/.ssh/id_rsa; \ - fi - -SECRET_FILES = $(foreach I,$(SECRETS),~/.docker/secrets/$I) -secrets: list_secrets $(SECRET_FILES) -list_secrets: - $(info From .docker/secrets these files are loaded:) - $(info $(SECRETS)) diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..11c707c --- /dev/null +++ b/NOTICE @@ -0,0 +1,14 @@ +Splunk SOAR WMI +Copyright (c) 2016-2022 Splunk Inc. + +Third-party Software Attributions: + +Library: sh +Version: 1.12.14 +License: MIT +Copyright 2011-2012 by Andrew Moffat + +Library: wmi-client-wrapper-py3 +Version: 2018.3 +License: BSD +Edward Beech diff --git a/README.md b/README.md new file mode 100644 index 0000000..77a67b1 --- /dev/null +++ b/README.md @@ -0,0 +1,408 @@ +[comment]: # "Auto-generated SOAR connector documentation" +# WMI + +Publisher: Splunk +Connector Version: 2\.1\.7 +Product Vendor: Microsoft +Product Name: Windows Server +Product Version Supported (regex): "\.\*" +Minimum Product Version: 5\.1\.0 + +This App uses the WMI WQL to implement investigative actions that are executed on a Windows endpoint + +[comment]: # " File: README.md" +[comment]: # " Copyright (c) 2016-2022 Splunk Inc." +[comment]: # "" +[comment]: # "Licensed under the Apache License, Version 2.0 (the 'License');" +[comment]: # "you may not use this file except in compliance with the License." +[comment]: # "You may obtain a copy of the License at" +[comment]: # "" +[comment]: # " http://www.apache.org/licenses/LICENSE-2.0" +[comment]: # "" +[comment]: # "Unless required by applicable law or agreed to in writing, software distributed under" +[comment]: # "the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND," +[comment]: # "either express or implied. See the License for the specific language governing permissions" +[comment]: # "and limitations under the License." +[comment]: # "" +Windows Management Instrumentation (WMI) ports need to be opened up on the endpoint for the app to +run WMI commands remotely. Depending upon your setup, this configuration can be part of a Group +Policy Object (GPO) or carried out individually on the endpoint. + +This app does not support proxies, and it will ignore any proxy settings. + +## wmi-client-wrapper + +This app makes use of the Python wmi-client-wrapper module, which is licensed under the BSD License, +Copyright (c) 2013 + +## wmi-client-wrapper-py3 + +This app makes use of the Python wmi-client-wrapper-py3 module, which is licensed under the BSD +License, Copyright (c) 2018 + + +### Configuration Variables +The below configuration variables are required for this Connector to operate. These variables are specified when configuring a Windows Server asset in SOAR. + +VARIABLE | REQUIRED | TYPE | DESCRIPTION +-------- | -------- | ---- | ----------- +**server** | required | string | Server IP/Hostname +**username** | required | string | Administrator username +**password** | required | password | Administrator password +**force\_ntlmv2** | optional | boolean | Add option to force NTLMv2 \(Used only for WMI\) + +### Supported Actions +[test connectivity](#action-test-connectivity) - Validate the asset configuration for connectivity +[list services](#action-list-services) - Get the list of installed services on the system +[get system info](#action-get-system-info) - Get information about a system +[list users](#action-list-users) - List users configured on a system +[run query](#action-run-query) - Run an arbitrary query using WQL on the system + +## action: 'test connectivity' +Validate the asset configuration for connectivity + +Type: **test** +Read only: **True** + +#### Action Parameters +No parameters are required for this action + +#### Action Output +No Output + +## action: 'list services' +Get the list of installed services on the system + +Type: **investigate** +Read only: **True** + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**ip\_hostname** | required | Hostname/IP to list services running on | string | `ip` `host name` +**namespace** | optional | Namespace | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS +--------- | ---- | -------- +action\_result\.status | string | +action\_result\.parameter\.ip\_hostname | string | `ip` `host name` +action\_result\.parameter\.namespace | string | +action\_result\.data\.\*\.AcceptPause | boolean | +action\_result\.data\.\*\.AcceptStop | boolean | +action\_result\.data\.\*\.Caption | string | +action\_result\.data\.\*\.CheckPoint | string | +action\_result\.data\.\*\.CreationClassName | string | +action\_result\.data\.\*\.Description | string | +action\_result\.data\.\*\.DesktopInteract | boolean | +action\_result\.data\.\*\.DisconnectedSessions | string | +action\_result\.data\.\*\.DisplayName | string | +action\_result\.data\.\*\.ErrorControl | string | +action\_result\.data\.\*\.ExitCode | string | +action\_result\.data\.\*\.InstallDate | string | +action\_result\.data\.\*\.Name | string | +action\_result\.data\.\*\.PathName | string | `file path` `file name` +action\_result\.data\.\*\.ProcessId | string | `pid` +action\_result\.data\.\*\.ServiceSpecificExitCode | string | +action\_result\.data\.\*\.ServiceType | string | +action\_result\.data\.\*\.StartMode | string | +action\_result\.data\.\*\.StartName | string | +action\_result\.data\.\*\.Started | boolean | +action\_result\.data\.\*\.State | string | +action\_result\.data\.\*\.Status | string | +action\_result\.data\.\*\.SystemCreationClassName | string | +action\_result\.data\.\*\.SystemName | string | +action\_result\.data\.\*\.TagId | string | +action\_result\.data\.\*\.TotalSessions | string | +action\_result\.data\.\*\.WaitHint | string | +action\_result\.summary\.running\_services | numeric | +action\_result\.summary\.total\_services | numeric | +action\_result\.message | string | +summary\.total\_objects | numeric | +summary\.total\_objects\_successful | numeric | + +## action: 'get system info' +Get information about a system + +Type: **investigate** +Read only: **True** + +For information on Namespaces of Windows Management Instrumentation, refer to the 'Namespace Parameter' section in the documentation\. + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**ip\_hostname** | required | Hostname/IP address to get info of | string | `ip` `host name` +**namespace** | optional | Namespace | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS +--------- | ---- | -------- +action\_result\.status | string | +action\_result\.parameter\.ip\_hostname | string | `ip` `host name` +action\_result\.parameter\.namespace | string | +action\_result\.data\.\*\.boot\_config\_details\.BootDirectory | string | `file path` +action\_result\.data\.\*\.boot\_config\_details\.Caption | string | +action\_result\.data\.\*\.boot\_config\_details\.ConfigurationPath | string | `file path` +action\_result\.data\.\*\.boot\_config\_details\.Description | string | +action\_result\.data\.\*\.boot\_config\_details\.LastDrive | string | +action\_result\.data\.\*\.boot\_config\_details\.Name | string | +action\_result\.data\.\*\.boot\_config\_details\.ScratchDirectory | string | `file path` +action\_result\.data\.\*\.boot\_config\_details\.SettingID | string | +action\_result\.data\.\*\.boot\_config\_details\.TempDirectory | string | `file path` +action\_result\.data\.\*\.os\_details\.BootDevice | string | +action\_result\.data\.\*\.os\_details\.BuildNumber | string | +action\_result\.data\.\*\.os\_details\.BuildType | string | +action\_result\.data\.\*\.os\_details\.CSCreationClassName | string | +action\_result\.data\.\*\.os\_details\.CSDVersion | string | +action\_result\.data\.\*\.os\_details\.CSName | string | +action\_result\.data\.\*\.os\_details\.Caption | string | +action\_result\.data\.\*\.os\_details\.CodeSet | string | +action\_result\.data\.\*\.os\_details\.CountryCode | string | +action\_result\.data\.\*\.os\_details\.CreationClassName | string | +action\_result\.data\.\*\.os\_details\.CurrentTimeZone | string | +action\_result\.data\.\*\.os\_details\.DataExecutionPrevention\_32BitApplications | boolean | +action\_result\.data\.\*\.os\_details\.DataExecutionPrevention\_Available | boolean | +action\_result\.data\.\*\.os\_details\.DataExecutionPrevention\_Drivers | boolean | +action\_result\.data\.\*\.os\_details\.DataExecutionPrevention\_SupportPolicy | string | +action\_result\.data\.\*\.os\_details\.Debug | boolean | +action\_result\.data\.\*\.os\_details\.Description | string | +action\_result\.data\.\*\.os\_details\.Distributed | boolean | +action\_result\.data\.\*\.os\_details\.EncryptionLevel | string | +action\_result\.data\.\*\.os\_details\.ForegroundApplicationBoost | string | +action\_result\.data\.\*\.os\_details\.FreePhysicalMemory | string | +action\_result\.data\.\*\.os\_details\.FreeSpaceInPagingFiles | string | +action\_result\.data\.\*\.os\_details\.FreeVirtualMemory | string | +action\_result\.data\.\*\.os\_details\.InstallDate | string | +action\_result\.data\.\*\.os\_details\.LargeSystemCache | string | +action\_result\.data\.\*\.os\_details\.LastBootUpTime | string | +action\_result\.data\.\*\.os\_details\.LocalDateTime | string | +action\_result\.data\.\*\.os\_details\.Locale | string | +action\_result\.data\.\*\.os\_details\.MUILanguages | string | +action\_result\.data\.\*\.os\_details\.Manufacturer | string | +action\_result\.data\.\*\.os\_details\.MaxNumberOfProcesses | string | +action\_result\.data\.\*\.os\_details\.MaxProcessMemorySize | string | +action\_result\.data\.\*\.os\_details\.Name | string | +action\_result\.data\.\*\.os\_details\.NumberOfLicensedUsers | string | +action\_result\.data\.\*\.os\_details\.NumberOfProcesses | string | +action\_result\.data\.\*\.os\_details\.NumberOfUsers | string | +action\_result\.data\.\*\.os\_details\.OSArchitecture | string | +action\_result\.data\.\*\.os\_details\.OSLanguage | string | +action\_result\.data\.\*\.os\_details\.OSProductSuite | string | +action\_result\.data\.\*\.os\_details\.OSType | string | +action\_result\.data\.\*\.os\_details\.OperatingSystemSKU | string | +action\_result\.data\.\*\.os\_details\.Organization | string | +action\_result\.data\.\*\.os\_details\.OtherTypeDescription | string | +action\_result\.data\.\*\.os\_details\.PAEEnabled | boolean | +action\_result\.data\.\*\.os\_details\.PlusProductID | string | +action\_result\.data\.\*\.os\_details\.PlusVersionNumber | string | +action\_result\.data\.\*\.os\_details\.Primary | boolean | +action\_result\.data\.\*\.os\_details\.ProductType | string | +action\_result\.data\.\*\.os\_details\.RegisteredUser | string | +action\_result\.data\.\*\.os\_details\.SerialNumber | string | +action\_result\.data\.\*\.os\_details\.ServicePackMajorVersion | string | +action\_result\.data\.\*\.os\_details\.ServicePackMinorVersion | string | +action\_result\.data\.\*\.os\_details\.SizeStoredInPagingFiles | string | +action\_result\.data\.\*\.os\_details\.Status | string | +action\_result\.data\.\*\.os\_details\.SuiteMask | string | +action\_result\.data\.\*\.os\_details\.SystemDevice | string | +action\_result\.data\.\*\.os\_details\.SystemDirectory | string | `file path` +action\_result\.data\.\*\.os\_details\.SystemDrive | string | +action\_result\.data\.\*\.os\_details\.TotalSwapSpaceSize | string | +action\_result\.data\.\*\.os\_details\.TotalVirtualMemorySize | string | +action\_result\.data\.\*\.os\_details\.TotalVisibleMemorySize | string | +action\_result\.data\.\*\.os\_details\.Version | string | +action\_result\.data\.\*\.os\_details\.WindowsDirectory | string | `file path` +action\_result\.data\.\*\.system\_details\.AdminPasswordStatus | string | +action\_result\.data\.\*\.system\_details\.AutomaticManagedPagefile | boolean | +action\_result\.data\.\*\.system\_details\.AutomaticResetBootOption | boolean | +action\_result\.data\.\*\.system\_details\.AutomaticResetCapability | boolean | +action\_result\.data\.\*\.system\_details\.BootOptionOnLimit | string | +action\_result\.data\.\*\.system\_details\.BootOptionOnWatchDog | string | +action\_result\.data\.\*\.system\_details\.BootROMSupported | boolean | +action\_result\.data\.\*\.system\_details\.BootupState | string | +action\_result\.data\.\*\.system\_details\.Caption | string | +action\_result\.data\.\*\.system\_details\.ChassisBootupState | string | +action\_result\.data\.\*\.system\_details\.CreationClassName | string | +action\_result\.data\.\*\.system\_details\.CurrentTimeZone | string | +action\_result\.data\.\*\.system\_details\.DNSHostName | string | `host name` +action\_result\.data\.\*\.system\_details\.DaylightInEffect | boolean | +action\_result\.data\.\*\.system\_details\.Description | string | +action\_result\.data\.\*\.system\_details\.Domain | string | `domain` +action\_result\.data\.\*\.system\_details\.DomainRole | string | `domain` +action\_result\.data\.\*\.system\_details\.EnableDaylightSavingsTime | boolean | +action\_result\.data\.\*\.system\_details\.FrontPanelResetStatus | string | +action\_result\.data\.\*\.system\_details\.InfraredSupported | boolean | +action\_result\.data\.\*\.system\_details\.InitialLoadInfo | string | +action\_result\.data\.\*\.system\_details\.InstallDate | string | +action\_result\.data\.\*\.system\_details\.KeyboardPasswordStatus | string | +action\_result\.data\.\*\.system\_details\.LastLoadInfo | string | +action\_result\.data\.\*\.system\_details\.Manufacturer | string | +action\_result\.data\.\*\.system\_details\.Model | string | +action\_result\.data\.\*\.system\_details\.Name | string | +action\_result\.data\.\*\.system\_details\.NameFormat | string | +action\_result\.data\.\*\.system\_details\.NetworkServerModeEnabled | boolean | +action\_result\.data\.\*\.system\_details\.NumberOfLogicalProcessors | string | +action\_result\.data\.\*\.system\_details\.NumberOfProcessors | string | +action\_result\.data\.\*\.system\_details\.OEMLogoBitmap | string | +action\_result\.data\.\*\.system\_details\.OEMStringArray | string | +action\_result\.data\.\*\.system\_details\.PCSystemType | string | +action\_result\.data\.\*\.system\_details\.PartOfDomain | boolean | `domain` +action\_result\.data\.\*\.system\_details\.PauseAfterReset | string | +action\_result\.data\.\*\.system\_details\.PowerManagementCapabilities | string | +action\_result\.data\.\*\.system\_details\.PowerManagementSupported | boolean | +action\_result\.data\.\*\.system\_details\.PowerOnPasswordStatus | string | +action\_result\.data\.\*\.system\_details\.PowerState | string | +action\_result\.data\.\*\.system\_details\.PowerSupplyState | string | +action\_result\.data\.\*\.system\_details\.PrimaryOwnerContact | string | +action\_result\.data\.\*\.system\_details\.PrimaryOwnerName | string | +action\_result\.data\.\*\.system\_details\.ResetCapability | string | +action\_result\.data\.\*\.system\_details\.ResetCount | string | +action\_result\.data\.\*\.system\_details\.ResetLimit | string | +action\_result\.data\.\*\.system\_details\.Roles | string | +action\_result\.data\.\*\.system\_details\.Status | string | +action\_result\.data\.\*\.system\_details\.SupportContactDescription | string | +action\_result\.data\.\*\.system\_details\.SystemStartupDelay | string | +action\_result\.data\.\*\.system\_details\.SystemStartupOptions | string | +action\_result\.data\.\*\.system\_details\.SystemStartupSetting | string | +action\_result\.data\.\*\.system\_details\.SystemType | string | +action\_result\.data\.\*\.system\_details\.ThermalState | string | +action\_result\.data\.\*\.system\_details\.TotalPhysicalMemory | string | +action\_result\.data\.\*\.system\_details\.UserName | string | `user name` +action\_result\.data\.\*\.system\_details\.WakeUpType | string | +action\_result\.data\.\*\.system\_details\.Workgroup | string | +action\_result\.summary\.dns\_hostname | string | `host name` +action\_result\.summary\.domain | string | `domain` +action\_result\.summary\.memory | string | +action\_result\.summary\.version | string | +action\_result\.summary\.workgroup | string | +action\_result\.message | string | +summary\.total\_objects | numeric | +summary\.total\_objects\_successful | numeric | + +## action: 'list users' +List users configured on a system + +Type: **investigate** +Read only: **True** + +For information on Namespaces of Windows Management Instrumentation, refer to the 'Namespace Parameter' section in the documentation\. + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**ip\_hostname** | required | Hostname/IP address to get users of | string | `ip` `host name` +**namespace** | optional | Namespace | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS +--------- | ---- | -------- +action\_result\.status | string | +action\_result\.parameter\.ip\_hostname | string | `ip` `host name` +action\_result\.parameter\.namespace | string | +action\_result\.data\.\*\.AccountType | string | +action\_result\.data\.\*\.Caption | string | `user name` +action\_result\.data\.\*\.Description | string | +action\_result\.data\.\*\.Disabled | boolean | +action\_result\.data\.\*\.Domain | string | `domain` +action\_result\.data\.\*\.FullName | string | +action\_result\.data\.\*\.InstallDate | string | +action\_result\.data\.\*\.LocalAccount | boolean | +action\_result\.data\.\*\.Lockout | boolean | +action\_result\.data\.\*\.Name | string | +action\_result\.data\.\*\.PasswordChangeable | boolean | +action\_result\.data\.\*\.PasswordExpires | boolean | +action\_result\.data\.\*\.PasswordRequired | boolean | +action\_result\.data\.\*\.SID | string | +action\_result\.data\.\*\.SIDType | string | +action\_result\.data\.\*\.Status | string | +action\_result\.summary\.disabled\_users | numeric | +action\_result\.summary\.total\_users | numeric | +action\_result\.message | string | +summary\.total\_objects | numeric | +summary\.total\_objects\_successful | numeric | + +## action: 'run query' +Run an arbitrary query using WQL on the system + +Type: **investigate** +Read only: **True** + +For information on Namespaces of Windows Management Instrumentation, refer to the 'Namespace Parameter' section in the documentation\. + +#### Action Parameters +PARAMETER | REQUIRED | DESCRIPTION | TYPE | CONTAINS +--------- | -------- | ----------- | ---- | -------- +**ip\_hostname** | required | Hostname/IP to run WMI query on | string | `ip` `host name` +**query** | required | Query \(in WQL format\) | string | +**namespace** | optional | Namespace | string | + +#### Action Output +DATA PATH | TYPE | CONTAINS +--------- | ---- | -------- +action\_result\.status | string | +action\_result\.parameter\.ip\_hostname | string | `ip` `host name` +action\_result\.parameter\.namespace | string | +action\_result\.parameter\.query | string | +action\_result\.data\.\*\.\*\.AccountType | string | +action\_result\.data\.\*\.\*\.CSCreationClassName | string | +action\_result\.data\.\*\.\*\.CSName | string | +action\_result\.data\.\*\.\*\.Caption | string | `file name` +action\_result\.data\.\*\.\*\.CommandLine | string | `file name` `file path` +action\_result\.data\.\*\.\*\.CreationClassName | string | +action\_result\.data\.\*\.\*\.CreationDate | string | +action\_result\.data\.\*\.\*\.Description | string | `file name` +action\_result\.data\.\*\.\*\.Disabled | boolean | +action\_result\.data\.\*\.\*\.Domain | string | `domain` +action\_result\.data\.\*\.\*\.ExecutablePath | string | `file path` `file name` +action\_result\.data\.\*\.\*\.ExecutionState | string | +action\_result\.data\.\*\.\*\.FullName | string | +action\_result\.data\.\*\.\*\.GroupComponent | string | +action\_result\.data\.\*\.\*\.Handle | string | +action\_result\.data\.\*\.\*\.HandleCount | string | +action\_result\.data\.\*\.\*\.InstallDate | string | +action\_result\.data\.\*\.\*\.KernelModeTime | string | +action\_result\.data\.\*\.\*\.LocalAccount | boolean | +action\_result\.data\.\*\.\*\.Lockout | boolean | +action\_result\.data\.\*\.\*\.MaximumWorkingSetSize | string | +action\_result\.data\.\*\.\*\.MinimumWorkingSetSize | string | +action\_result\.data\.\*\.\*\.Name | string | `file name` +action\_result\.data\.\*\.\*\.OSCreationClassName | string | +action\_result\.data\.\*\.\*\.OSName | string | +action\_result\.data\.\*\.\*\.OtherOperationCount | string | +action\_result\.data\.\*\.\*\.OtherTransferCount | string | +action\_result\.data\.\*\.\*\.PageFaults | string | +action\_result\.data\.\*\.\*\.PageFileUsage | string | +action\_result\.data\.\*\.\*\.ParentProcessId | string | `pid` +action\_result\.data\.\*\.\*\.PartComponent | string | +action\_result\.data\.\*\.\*\.PasswordChangeable | boolean | +action\_result\.data\.\*\.\*\.PasswordExpires | boolean | +action\_result\.data\.\*\.\*\.PasswordRequired | boolean | +action\_result\.data\.\*\.\*\.PeakPageFileUsage | string | +action\_result\.data\.\*\.\*\.PeakVirtualSize | string | +action\_result\.data\.\*\.\*\.PeakWorkingSetSize | string | +action\_result\.data\.\*\.\*\.Priority | string | +action\_result\.data\.\*\.\*\.PrivatePageCount | string | +action\_result\.data\.\*\.\*\.ProcessId | string | `pid` +action\_result\.data\.\*\.\*\.QuotaNonPagedPoolUsage | string | +action\_result\.data\.\*\.\*\.QuotaPagedPoolUsage | string | +action\_result\.data\.\*\.\*\.QuotaPeakNonPagedPoolUsage | string | +action\_result\.data\.\*\.\*\.QuotaPeakPagedPoolUsage | string | +action\_result\.data\.\*\.\*\.ReadOperationCount | string | +action\_result\.data\.\*\.\*\.ReadTransferCount | string | +action\_result\.data\.\*\.\*\.SID | string | +action\_result\.data\.\*\.\*\.SIDType | string | +action\_result\.data\.\*\.\*\.SessionId | string | +action\_result\.data\.\*\.\*\.Status | string | +action\_result\.data\.\*\.\*\.TerminationDate | string | +action\_result\.data\.\*\.\*\.ThreadCount | string | +action\_result\.data\.\*\.\*\.UserModeTime | string | +action\_result\.data\.\*\.\*\.VirtualSize | string | +action\_result\.data\.\*\.\*\.WindowsVersion | string | +action\_result\.data\.\*\.\*\.WorkingSetSize | string | +action\_result\.data\.\*\.\*\.WriteOperationCount | string | +action\_result\.data\.\*\.\*\.WriteTransferCount | string | +action\_result\.summary | string | +action\_result\.message | string | +summary\.total\_objects | numeric | +summary\.total\_objects\_successful | numeric | \ No newline at end of file diff --git a/__init__.py b/__init__.py index deed66f..156a533 100644 --- a/__init__.py +++ b/__init__.py @@ -1,7 +1,14 @@ # File: __init__.py -# Copyright (c) 2016-2021 Splunk Inc. # -# SPLUNK CONFIDENTIAL - Use or disclosure of this material in whole or in part -# without a valid written license from Splunk Inc. is PROHIBITED. +# Copyright (c) 2016-2022 Splunk Inc. # -# -- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions +# and limitations under the License. diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 6150455..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: "3.2" - -services: - app_tester: - image: repo.splunk.com/splunk/infra/phantom_apps_tester:${IMAGE_TAG:-latest} - environment: - BUILD_USER_ID: ${USER:-localbuild} - TEST_BRANCH: ${TEST_BRANCH:-master} - WORKSPACE: /builds/phantom-apps - volumes: - - .:/builds/phantom-apps/${APP_REPO_NAME} - command: sleep 28800 - secrets: - - app_artf_token - - app_deploy_key - - gitlab_api_token - -secrets: - app_artf_token: - file: ~/.docker/secrets/app_artf_token - app_deploy_key: - file: ~/.docker/secrets/app_deploy_key - gitlab_api_token: - file: ~/.docker/secrets/gitlab_api_token diff --git a/readme.html b/readme.html index b7fc9ec..d6c877c 100644 --- a/readme.html +++ b/readme.html @@ -1,8 +1,16 @@

Windows Management Instrumentation (WMI) ports need to be opened up on the endpoint for the app to run WMI commands remotely. Depending upon your setup, this configuration can be part of a Group Policy Object (GPO) or carried out individually on the endpoint.

diff --git a/release_notes/1.2.14.md b/release_notes/1.2.14.md new file mode 100644 index 0000000..18dc713 --- /dev/null +++ b/release_notes/1.2.14.md @@ -0,0 +1,7 @@ +**WMI Release Notes - Published by Splunk October 14, 2016** + + +**Version 1.2.14 - Released October 14, 2016** + +* Made improvements to the datapath settings +* Minor app documentation corrections diff --git a/release_notes/1.2.15.md b/release_notes/1.2.15.md new file mode 100644 index 0000000..cec7a2e --- /dev/null +++ b/release_notes/1.2.15.md @@ -0,0 +1,6 @@ +**WMI Release Notes - Published by Splunk July 27, 2017** + + +**Version 1.2.15 - Released July 27, 2017** + +* 3.0 compatibility update release only diff --git a/release_notes/1.2.18.md b/release_notes/1.2.18.md new file mode 100644 index 0000000..a690871 --- /dev/null +++ b/release_notes/1.2.18.md @@ -0,0 +1,6 @@ +**WMI Release Notes - Published by Splunk February 05, 2018** + + +**Version 1.2.18 - Released February 05, 2018** + +* App action views and Logo updates diff --git a/release_notes/1.2.23.md b/release_notes/1.2.23.md new file mode 100644 index 0000000..e03e01b --- /dev/null +++ b/release_notes/1.2.23.md @@ -0,0 +1,7 @@ +**WMI Release Notes - Published by Splunk October 16, 2018** + + +**Version 1.2.23 - Released October 16, 2018** + +* Added support for passing --options +* Added support for Namespace Parameter diff --git a/release_notes/1.2.27.md b/release_notes/1.2.27.md new file mode 100644 index 0000000..71455bd --- /dev/null +++ b/release_notes/1.2.27.md @@ -0,0 +1,6 @@ +**WMI Release Notes - Published by Splunk February 05, 2019** + + +**Version 1.2.27 - Released February 05, 2019** + +* Compatibility changes for Phantom release 4.2 diff --git a/release_notes/1.2.9.md b/release_notes/1.2.9.md new file mode 100644 index 0000000..cf069ea --- /dev/null +++ b/release_notes/1.2.9.md @@ -0,0 +1,6 @@ +**WMI Release Notes - Published by Splunk September 26, 2016** + + +**Version 1.2.9 - Released September 26, 2016** + +* Fixed a datapath setting that could cause nulls to be returned diff --git a/release_notes/2.0.2.md b/release_notes/2.0.2.md new file mode 100644 index 0000000..070e9f8 --- /dev/null +++ b/release_notes/2.0.2.md @@ -0,0 +1,7 @@ +**WMI Release Notes - Published by Splunk April 16, 2021** + + +**Version 2.0.2 - Released April 16, 2021** + +* Compatibility changes for Python 3 support +* Added 'test connectivity' action diff --git a/release_notes/2.1.4.md b/release_notes/2.1.4.md new file mode 100644 index 0000000..d4dad71 --- /dev/null +++ b/release_notes/2.1.4.md @@ -0,0 +1,6 @@ +**WMI Release Notes - Published by Splunk September 09, 2021** + + +**Version 2.1.4 - Released September 09, 2021** + +* Updated the dependencies [PAPP-18762] diff --git a/release_notes/2.1.6.md b/release_notes/2.1.6.md new file mode 100644 index 0000000..b29ab92 --- /dev/null +++ b/release_notes/2.1.6.md @@ -0,0 +1,6 @@ +**WMI Release Notes - Published by Splunk October 15, 2021** + + +**Version 2.1.6 - Released October 15, 2021** + +* Removed unnecessary build artifacts diff --git a/release_notes/2.1.7.md b/release_notes/2.1.7.md new file mode 100644 index 0000000..75b6961 --- /dev/null +++ b/release_notes/2.1.7.md @@ -0,0 +1 @@ +* Marked the app as FIPS Compliant [PAPP-21867] \ No newline at end of file diff --git a/release_notes/release_notes.html b/release_notes/release_notes.html new file mode 100644 index 0000000..1773eb9 --- /dev/null +++ b/release_notes/release_notes.html @@ -0,0 +1,45 @@ +WMI Release Notes - Published by Splunk March 24, 2022 +

+Version 2.1.7 - Released March 24, 2022 + +Version 2.1.6 - Released October 15, 2021 + +Version 2.1.4 - Released September 09, 2021 + +Version 2.0.2 - Released April 16, 2021 + +Version 1.2.27 - Released February 05, 2019 + +Version 1.2.23 - Released October 16, 2018 + +Version 1.2.18 - Released February 05, 2018 + +Version 1.2.15 - Released July 27, 2017 + +Version 1.2.14 - Released October 14, 2016 + +Version 1.2.9 - Released September 26, 2016 + diff --git a/release_notes/unreleased.md b/release_notes/unreleased.md new file mode 100644 index 0000000..fbcb2fd --- /dev/null +++ b/release_notes/unreleased.md @@ -0,0 +1 @@ +**Unreleased** diff --git a/requirements.txt b/requirements.txt index 426f245..fe919a0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -wmi-client-wrapper==0.0.12 -wmi-client-wrapper-py3==2018.3 +sh==1.12.14 diff --git a/wheels/future-0.16.0-py3-none-any.whl b/wheels/future-0.16.0-py3-none-any.whl new file mode 100644 index 0000000..291f5a5 Binary files /dev/null and b/wheels/future-0.16.0-py3-none-any.whl differ diff --git a/wheels/sh-1.12.14-py2.py3-none-any.whl b/wheels/sh-1.12.14-py2.py3-none-any.whl new file mode 100644 index 0000000..0dcefa0 Binary files /dev/null and b/wheels/sh-1.12.14-py2.py3-none-any.whl differ diff --git a/wmi-client-wrapper-ntlmv2/wmi_client_wrapper-0.0.12-py2-none-any.whl b/wmi-client-wrapper-ntlmv2/wmi_client_wrapper-0.0.12-py2-none-any.whl deleted file mode 100644 index 6b7885f..0000000 Binary files a/wmi-client-wrapper-ntlmv2/wmi_client_wrapper-0.0.12-py2-none-any.whl and /dev/null differ diff --git a/wmi-client-wrapper-ntlmv2/wmi_client_wrapper_py3-2018.3-py3-none-any.whl b/wmi-client-wrapper-ntlmv2/wmi_client_wrapper_py3-2018.3-py3-none-any.whl deleted file mode 100644 index 0c65f61..0000000 Binary files a/wmi-client-wrapper-ntlmv2/wmi_client_wrapper_py3-2018.3-py3-none-any.whl and /dev/null differ diff --git a/wmi.json b/wmi.json index 3161cd9..112360e 100644 --- a/wmi.json +++ b/wmi.json @@ -6,32 +6,25 @@ "type": "endpoint", "main_module": "wmi_connector.py", "python_version": "3", - "app_version": "2.1.6", - "utctime_updated": "2021-10-15T18:03:12.000000Z", + "app_version": "2.1.7", + "utctime_updated": "2022-01-07T20:50:38.000000Z", "package_name": "phantom_wmi", "product_vendor": "Microsoft", "product_name": "Windows Server", "product_version_regex": ".*", - "min_phantom_version": "4.9.39220", + "min_phantom_version": "5.1.0", + "fips_compliant": true, "logo": "logo_microsoft_wmi.svg", "logo_dark": "logo_microsoft_wmi_dark.svg", - "license": "Copyright (c) 2016-2021 Splunk Inc.", + "license": "Copyright (c) 2016-2022 Splunk Inc.", "latest_tested_versions": [ "On-Prem on 20th August, 2021" ], "pip_dependencies": { "wheel": [ { - "module": "wmi-client-wrapper", - "input_file": "wmi-client-wrapper-ntlmv2/wmi_client_wrapper-0.0.12-py2-none-any.whl" - } - ] - }, - "pip3_dependencies": { - "wheel": [ - { - "module": "wmi-client-wrapper", - "input_file": "wmi-client-wrapper-ntlmv2/wmi_client_wrapper_py3-2018.3-py3-none-any.whl" + "module": "sh", + "input_file": "wheels/sh-1.12.14-py2.py3-none-any.whl" } ] }, diff --git a/wmi_client_wrapper/LICENSE b/wmi_client_wrapper/LICENSE new file mode 100644 index 0000000..ed0ec84 --- /dev/null +++ b/wmi_client_wrapper/LICENSE @@ -0,0 +1 @@ +https://github.com/ftpsolutions/python-wmi-client-wrapper/commit/0059accc6d24a5f551bcff21d6b4f2d02de839d2 diff --git a/wmi_client_wrapper/README.md b/wmi_client_wrapper/README.md new file mode 100644 index 0000000..c900ccd --- /dev/null +++ b/wmi_client_wrapper/README.md @@ -0,0 +1,3 @@ +Modified copy of https://github.com/ftpsolutions/python-wmi-client-wrapper to support Python 3.6+. + +See https://splunk.atlassian.net/browse/PAPP-18762 for more context. diff --git a/wmi_client_wrapper/__init__.py b/wmi_client_wrapper/__init__.py new file mode 100644 index 0000000..63fdb0b --- /dev/null +++ b/wmi_client_wrapper/__init__.py @@ -0,0 +1,9 @@ +from __future__ import absolute_import, division, print_function, unicode_literals + +from future import standard_library + +from .wmi_wrapper import WmiClientWrapper + +standard_library.install_aliases() + +_ = WmiClientWrapper diff --git a/wmi_client_wrapper/wmi_wrapper.py b/wmi_client_wrapper/wmi_wrapper.py new file mode 100644 index 0000000..22accd8 --- /dev/null +++ b/wmi_client_wrapper/wmi_wrapper.py @@ -0,0 +1,215 @@ +""" +Houses the wrapper for wmi-client. + +There are a handful of injection vulnerabilities in this, so don't expose it +directly to end-users. +""" +from __future__ import absolute_import, division, print_function, unicode_literals + +import csv +import sys +from io import StringIO + +import sh +from future import standard_library + +standard_library.install_aliases() + +if int(sys.version_info[0]) < 3: + from past.types.oldstr import oldstr as str + + +class WmiClientWrapper(object): + """ + Wrap wmi-client. Creating an instance of the wrapper will make a security + context through which all future queries will be executed. It's basically + just a convenient way to remember the username, password and host. + + There are a handful of injection vulnerabilities in this, so don't expose + it directly to end-users. + """ + + def __init__(self, + username="Administrator", + password=None, + host=None, + namespace='//./root/cimv2', + delimiter="\01", + force_ntlm_v2=False): + + assert username + assert password + assert host # assume host is up + + # store the credentials for later + self.username = username + self.password = password + self.host = host + self.force_ntlm_v2 = force_ntlm_v2 + + self.delimiter = delimiter + self.namespace = namespace + + def _make_credential_args(self): + """ + Makes credentials that get passed to wmic. This assembles a list of + arguments. + """ + arguments = [] + + # the format is user%pass + # NOTE: this is an injection vulnerability + userpass = "--user={username}%{password}".format( + username=self.username, + password=self.password, + ) + + arguments.append(userpass) + + # the format for ip addresses and host names is // + hostaddr = "//{host}".format(host=self.host) + + arguments.append(hostaddr) + # the format for namespace + space = "--namespace={namespace}".format(namespace=self.namespace) + + arguments.append(space) + return arguments + + def _setup_params(self): + """ + Makes extra configuration that gets passed to wmic. + """ + + params = [] + + if (self.force_ntlm_v2): + params.append('--option=client ntlmv2 auth=Yes') + + params.append("--delimiter={delimiter}".format(delimiter=self.delimiter)) + + return params + + def _construct_query(self, klass): + """ + Makes up a WMI query based on a given class. + """ + # NOTE: this is an injection vulnerability + queryx = "SELECT * FROM {klass}".format(klass=klass) + return queryx + + def query(self, klass): + """ + Executes a query using the wmi-client command. + """ + # i don't want to have to repeat the -U stuff + credentials = self._make_credential_args() + + # Let's make the query construction independent, but also if there's a + # space then it's probably just a regular query. + if " " not in klass: + queryx = self._construct_query(klass) + else: + queryx = klass + + # and these are just configuration + setup = self._setup_params() + + # construct the arguments to wmic + arguments = setup + credentials + [queryx] + + # execute the command + output = sh.wmic(*arguments) + + # just to be sure? sh is weird sometimes. + output = str(output) + + # and now parse the output + return WmiClientWrapper._parse_wmic_output(output, delimiter=self.delimiter) + + @classmethod + def _parse_wmic_output(cls, output, delimiter="\01"): + """ + Parses output from the wmic command and returns json. + """ + # remove newlines and whitespace from the beginning and end + output = output.strip() + + # Quick parser hack- make sure that the initial file or section is also + # counted in the upcoming split. + if output[:7] == "CLASS: ": + output = "\n" + output + + # There might be multiple files in the output. Track how many there + # should be so that errors can be raised later if something is + # inconsistent. + expected_sections_count = output.count("\nCLASS: ") + + # Split up the file into individual sections. Each one corresponds to a + # separate csv file. + sections = output.split("\nCLASS: ") + + # The split causes an empty string as the first member of the list and + # it should be removed because it's junk. + if sections[0] == "": + sections = sections[1:] + + assert len(sections) is expected_sections_count + + items = [] + + for section in sections: + # remove the first line because it has the query class + section = "\n".join(section.split("\n")[1:]) + section = section.replace('\r\n', '\\r\\n') + + strio = StringIO(section) + + moredata = list(csv.DictReader(strio, delimiter=str(delimiter))) + items.extend(moredata) + + # walk the dictionaries! + return WmiClientWrapper._fix_dictionary_output(items) + + @classmethod + def _fix_dictionary_output(cls, incoming): + """ + The dictionary doesn't exactly match the traditional python-wmi output. + For example, there's "True" instead of True. Integer values are also + quoted. Values that should be "None" are "(null)". + + This can be fixed by walking the tree. + + The Windows API is able to return the types, but here we're just + guessing randomly. But guessing should work in most cases. There are + some instances where a value might happen to be an integer but has + other situations where it's a string. In general, the rule of thumb + should be to cast to whatever you actually need, instead of hoping that + the output will always be an integer or will always be a string.. + """ + + if isinstance(incoming, list): + output = [] + + for each in incoming: + output.append(cls._fix_dictionary_output(each)) + + elif isinstance(incoming, dict): + output = dict() + + for (key, value) in list(incoming.items()): + if value == "(null)": + output[key] = None + elif value == "True": + output[key] = True + elif value == "False": + output[key] = False + elif isinstance(value, str) and len(value) > 1 and value[0] == "(" and value[-1] == ")": + # convert to a list with a single entry + output[key] = [value[1:-1]] + elif isinstance(value, str): + output[key] = value + elif isinstance(value, dict): + output[key] = cls._fix_dictionary_output(value) + + return output diff --git a/wmi_connector.py b/wmi_connector.py index 94951fa..2ac0d1f 100644 --- a/wmi_connector.py +++ b/wmi_connector.py @@ -1,21 +1,27 @@ # File: wmi_connector.py -# Copyright (c) 2016-2021 Splunk Inc. # -# SPLUNK CONFIDENTIAL - Use or disclosure of this material in whole or in part -# without a valid written license from Splunk Inc. is PROHIBITED. +# Copyright (c) 2016-2022 Splunk Inc. # -# -- +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions +# and limitations under the License. +# +# +import re -# Phantom imports import phantom.app as phantom -from phantom.base_connector import BaseConnector from phantom.action_result import ActionResult +from phantom.base_connector import BaseConnector -# THIS Connector imports -from wmi_consts import * - -import re import wmi_client_wrapper as wmi +from wmi_consts import * class WmiConnector(BaseConnector): @@ -75,6 +81,8 @@ def _modify_exception_message(self, e): def _run_query(self, query, wmic, action_result): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + try: ret_data = wmic.query(query) except Exception as e: @@ -183,12 +191,15 @@ def _get_processes(self, wmic, action_result): def _get_services(self, wmic, action, action_result): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + query = "select * from Win32_Service" if action == self.ACTION_ID_GET_RUNNING_SERVICES: query = "select * from Win32_Service where State = 'Running'" ret_data = self._run_query(query, wmic, action_result) + self.debug_print("query_results", ret_data) if phantom.is_success(action_result.get_status()) and len(ret_data): action_result.update_summary({WMI_JSON_TOTAL_SERVICES: len(ret_data)}) @@ -205,9 +216,12 @@ def _get_services(self, wmic, action, action_result): def _get_users(self, wmic, action_result): + self.save_progress("In action handler for: {0}".format(self.get_action_identifier())) + query = "select * from Win32_Account where SIDType = 1" ret_data = self._run_query(query, wmic, action_result) + self.debug_print("query_results", ret_data) if phantom.is_success(action_result.get_status()) and len(ret_data): action_result.update_summary({WMI_JSON_TOTAL_USERS: len(ret_data)}) @@ -303,9 +317,10 @@ def handle_action(self, param): if __name__ == '__main__': + import json import sys + import pudb - import json pudb.set_trace() @@ -320,4 +335,4 @@ def handle_action(self, param): print(result) - exit(0) + sys.exit(0) diff --git a/wmi_consts.py b/wmi_consts.py index 9a46e49..1a4be06 100644 --- a/wmi_consts.py +++ b/wmi_consts.py @@ -1,11 +1,19 @@ # File: wmi_consts.py -# Copyright (c) 2016-2021 Splunk Inc. # -# SPLUNK CONFIDENTIAL - Use or disclosure of this material in whole or in part -# without a valid written license from Splunk Inc. is PROHIBITED. +# Copyright (c) 2016-2022 Splunk Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under +# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific language governing permissions +# and limitations under the License. +# # -# -- - # Json keys specific to wmi app's input parameters/config and the output result WMI_JSON_QUERY = "query" WMI_JSON_TOTAL_SERVICES = "total_services"