falcon-toolkit 3.3.0__tar.gz → 3.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. falcon_toolkit-3.3.0/README.md → falcon_toolkit-3.4.0/PKG-INFO +122 -13
  2. falcon_toolkit-3.3.0/PKG-INFO → falcon_toolkit-3.4.0/README.md +83 -50
  3. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/auth_backends/public_mssp.py +6 -13
  4. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/auth_backends/utils.py +21 -12
  5. falcon_toolkit-3.4.0/falcon_toolkit/common/utils.py +113 -0
  6. falcon_toolkit-3.4.0/falcon_toolkit/containment/__init__.py +4 -0
  7. falcon_toolkit-3.4.0/falcon_toolkit/containment/cli.py +206 -0
  8. falcon_toolkit-3.4.0/falcon_toolkit/containment/perform_containment.py +112 -0
  9. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/falcon.py +36 -34
  10. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/hosts/host_search.py +12 -8
  11. falcon_toolkit-3.4.0/falcon_toolkit/maintenance_token/__init__.py +4 -0
  12. falcon_toolkit-3.4.0/falcon_toolkit/maintenance_token/cli.py +179 -0
  13. falcon_toolkit-3.4.0/falcon_toolkit/maintenance_token/device_tokens.py +49 -0
  14. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/policies/cli.py +15 -7
  15. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/prompt.py +5 -0
  16. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/pyproject.toml +11 -10
  17. falcon_toolkit-3.3.0/falcon_toolkit/common/utils.py +0 -66
  18. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/LICENSE.md +0 -0
  19. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/__init__.py +0 -0
  20. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/__init__.py +0 -0
  21. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/auth.py +0 -0
  22. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/auth_backends/__init__.py +0 -0
  23. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/auth_backends/default.py +0 -0
  24. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/auth_backends/public_single_cid.py +0 -0
  25. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/cli.py +0 -0
  26. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/config.py +0 -0
  27. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/console_utils.py +0 -0
  28. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/constants.py +0 -0
  29. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/logging_config.py +0 -0
  30. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/meta.py +0 -0
  31. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/common/namespace.py +0 -0
  32. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/hosts/__init__.py +0 -0
  33. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/hosts/cli.py +0 -0
  34. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/policies/__init__.py +0 -0
  35. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/policies/constants.py +0 -0
  36. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/policies/container.py +0 -0
  37. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/policies/describe.py +0 -0
  38. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/__init__.py +0 -0
  39. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/cli.py +0 -0
  40. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/cmd_generators/__init__.py +0 -0
  41. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/cmd_generators/common.py +0 -0
  42. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/cmd_generators/reg.py +0 -0
  43. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/parsers.py +0 -0
  44. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/refresh.py +0 -0
  45. {falcon_toolkit-3.3.0 → falcon_toolkit-3.4.0}/falcon_toolkit/shell/utils.py +0 -0
@@ -1,3 +1,41 @@
1
+ Metadata-Version: 2.1
2
+ Name: falcon-toolkit
3
+ Version: 3.4.0
4
+ Summary: Toolkit to interface with CrowdStrike Falcon via the API
5
+ Home-page: http://github.com/CrowdStrike/Falcon-Toolkit
6
+ License: MIT
7
+ Keywords: automation,cli,crowdstrike,endpoint-protection,falcon,falcon-platform
8
+ Author: Chris Hammond
9
+ Author-email: chris.hammond@crowdstrike.com
10
+ Requires-Python: >=3.9,<4.0
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: MacOS
14
+ Classifier: Operating System :: Microsoft :: Windows
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: System :: Shells
24
+ Classifier: Topic :: Terminals
25
+ Requires-Dist: caracara (>=0.7.0,<0.8.0)
26
+ Requires-Dist: click (>=8.1.3,<9.0.0)
27
+ Requires-Dist: click-option-group (>=0.5.6,<0.6.0)
28
+ Requires-Dist: click-spinner (>=0.1.10,<0.2.0)
29
+ Requires-Dist: cmd2 (>=2.4,<3.0)
30
+ Requires-Dist: colorama (>=0.4.5,<0.5.0)
31
+ Requires-Dist: keyring (>=24,<26)
32
+ Requires-Dist: platformdirs (>=4.2.0,<5.0.0)
33
+ Requires-Dist: prompt-toolkit (>=3.0.43,<4.0.0)
34
+ Requires-Dist: setuptools (>=69.0,<70.0)
35
+ Requires-Dist: tabulate (>=0.9.0,<0.10.0)
36
+ Project-URL: Repository, http://github.com/CrowdStrike/Falcon-Toolkit
37
+ Description-Content-Type: text/markdown
38
+
1
39
  <!--markdownlint-disable MD033-->
2
40
  # Falcon Toolkit
3
41
 
@@ -21,8 +59,9 @@ The toolkit provides:
21
59
  - Multiple profile support, including support for MSSP / Falcon Flight Control configurations.
22
60
  - A shell allowing you to interface with many hosts via RTR at once, and get the output via CSV.
23
61
  - Scriptability! You can program the shell by providing pre-written routines via a file on disk, and a full Python extensibility API is provided.
24
- - Prevention policy import and export
25
- - Response policy import and export
62
+ - Prevention policy import and export.
63
+ - Response policy import and export.
64
+ - Contain and uncontain systems in bulk, according to filters or a list of device IDs.
26
65
  - More functionality is coming soon! Want more functionality? Open an [Issue](https://github.com/CrowdStrike/Falcon-Toolkit/issues/new)!
27
66
 
28
67
  Since this is built on top of Caracara, you get a bunch of great functionality and flexibility free, including the ability to filter hosts using dynamically generated FQL queries, full debug logging where desired, Falcon Flight Control integration, and more! Plus, the tool is lightning quick as it leverages Caracara's parallelisation tricks to pull more information quickly.
@@ -182,17 +221,19 @@ Two types of configuration backends are provided out of the box: the default, wh
182
221
 
183
222
  Your API keys should have the following scopes enabled in the Falcon dashboard:
184
223
 
185
- | &darr; API Scopes // Commands &rarr; | `host_search` | `shell` | `policies`<br>(Prevention) | `policies`<br>(Response) |
186
- |--------------------------------------|:-------------:|:-------:|:--------------------------:|:-------------------------:|
187
- | **Falcon Flight Control: Read** | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* |
188
- | **Hosts: Read** | X | X | | |
189
- | **Prevention Policies: Read** | | | X<br>`describe` / `export` sub-commands | |
190
- | **Prevention Policies: Write** | | | X<br>`import` sub-command | |
191
- | **Real Time Response: Read** | | X | | |
192
- | **Real Time Response: Write** | | X | | |
193
- | **Real Time Response: Admin** | | X<br>*for admin commands* | | |
194
- | **Response Policies: Read** | | | | X<br>`describe` / `export` sub-commands |
195
- | **Response Policies: Write** | | | | X<br>`import` sub-command |
224
+ | &darr; API Scopes // Commands &rarr; | `host_search` | `shell` | `policies`<br>(Prevention) | `policies`<br>(Response) | `containment`<br>Host Containment | `maintenance_token`<br>Maintenance Tokens |
225
+ |--------------------------------------|:-------------:|:-------:|:--------------------------:|:-------------------------:|:---------------------------------:|:-----------------------------------------:|
226
+ | **Falcon Flight Control: Read** | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | | |
227
+ | **Hosts: Read** | X | X | | | X | X |
228
+ | **Hosts: Write** | | | | | X | |
229
+ | **Prevention Policies: Read** | | | X<br>`describe` / `export` sub-commands | | | |
230
+ | **Prevention Policies: Write** | | | X<br>`import` sub-command | | | |
231
+ | **Real Time Response: Read** | | X | | | | |
232
+ | **Real Time Response: Write** | | X | | | | |
233
+ | **Real Time Response: Admin** | | X<br>*for admin commands* | | | | |
234
+ | **Response Policies: Read** | | | | X<br>`describe` / `export` sub-commands | | |
235
+ | **Response Policies: Write** | | | | X<br>`import` sub-command | | |
236
+ | **Sensor Update Policies: Write** | | | | | | X |
196
237
 
197
238
  ### Showing Your Profiles
198
239
 
@@ -355,6 +396,73 @@ Some example usages of this functionality are as follows:
355
396
 
356
397
  </details>
357
398
 
399
+ ## Maintenance Tokens
400
+
401
+ You can fetch maintenance tokens for systems within your Falcon tenant, or retrieve the bulk maintenance token.
402
+
403
+ ### Examples
404
+
405
+ Show the bulk maintenance token:
406
+
407
+ ```shell
408
+ $ falcon -p MyCompany maintenance_token -b
409
+ Getting the bulk maintenance token
410
+ Bulk maintenance token: redactedexample12345
411
+ WARNING: this token must be kept safe, as it can uninstall all Falcon sensors!
412
+ ```
413
+
414
+ Show a token for a specific system located by hostname:
415
+
416
+ ```shell
417
+ $ falcon -p MyCompany maintenance_token -f Hostname=MY-TEST-BOX-1
418
+ ```
419
+
420
+ Show maintenance tokens for a list of device IDs provided on the command line:
421
+
422
+ ```shell
423
+ $ falcon -p MyCompany maintenance_token -d aid1,aid2,...
424
+ ```
425
+
426
+ ## Network Containment
427
+
428
+ You can `contain` and `uncontain` systems through Falcon Toolkit. Network containment restricts the network connectivity of matching systems to just the Falcon Platform.
429
+
430
+ The containment functionality accepts the same command line parameters as `host_search` and `shell` (`-d`, `-df`, or multiple instances of `-f` to apply Falcon filters).
431
+
432
+ ### Examples
433
+
434
+ Network contain all systems that match the FQL hostname pattern `DEVTEST*`:
435
+
436
+ ```shell
437
+ $ falcon -p MyCompany containment -f Hostname=DEVTEST\* contain
438
+ ...
439
+ ```
440
+
441
+ Lift the containment status on the same machines:
442
+
443
+ ```shell
444
+ $ falcon -p MyCompany containment -f Hostname=DEVTEST\* uncontain
445
+ ...
446
+ ```
447
+
448
+ Network contain specific systems by AID:
449
+
450
+ ```shell
451
+ $ falcon -p MyCompany containment -d aid1,aid2,aid3 contain
452
+ ...
453
+ ```
454
+
455
+ Network contain all systems in a CID:
456
+
457
+ ```shell
458
+ $ falcon -p MyCompany containment contain
459
+ You did not specify any parameters. This command will manage the containment status of ALL devices in the Falcon tenant!
460
+ You must enter the string "I AM SURE!" to proceed.
461
+ Are you sure? I AM SURE!
462
+ ...
463
+ ```
464
+
465
+
358
466
  ## Policy Manipulation
359
467
 
360
468
  You can `describe`, `import` and `export` two types of policies: Prevention and Response. The three verbs are applied to the `falcon policies` command to specify what you would like to do with policies, and a command line switch is used to specify the policy type to work with. Exported policies are written to disk as JSON with some Falcon Toolkit-specific data needed to import a policy back again.
@@ -408,3 +516,4 @@ Furthermore, GitHub Discussions provide the community with means to communicate.
408
516
  *Security issues should be raised to our [Security team](mailto:security@crowdstrike.com) and [Chris Hammond](mailto:Chris.Hammond@crowdstrike.com).*
409
517
 
410
518
  Thank you for using the Falcon Toolkit! We hope it is as useful to the Falcon user community as it is to us.
519
+
@@ -1,39 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: falcon-toolkit
3
- Version: 3.3.0
4
- Summary: Toolkit to interface with CrowdStrike Falcon via the API
5
- Home-page: http://github.com/CrowdStrike/Falcon-Toolkit
6
- License: MIT
7
- Keywords: automation,cli,crowdstrike,endpoint-protection,falcon,falcon-platform
8
- Author: Chris Hammond
9
- Author-email: chris.hammond@crowdstrike.com
10
- Requires-Python: >=3.9,<4.0
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Natural Language :: English
13
- Classifier: Operating System :: MacOS
14
- Classifier: Operating System :: Microsoft :: Windows
15
- Classifier: Operating System :: POSIX :: Linux
16
- Classifier: Programming Language :: Python :: 3
17
- Classifier: Programming Language :: Python :: 3.9
18
- Classifier: Programming Language :: Python :: 3.10
19
- Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3 :: Only
21
- Classifier: Topic :: Security
22
- Classifier: Topic :: System :: Shells
23
- Classifier: Topic :: Terminals
24
- Requires-Dist: caracara (>=0.5.1,<0.6.0)
25
- Requires-Dist: click (>=8.1.3,<9.0.0)
26
- Requires-Dist: click-option-group (>=0.5.3,<0.6.0)
27
- Requires-Dist: click-spinner (>=0.1.10,<0.2.0)
28
- Requires-Dist: cmd2 (>=2.4,<3.0)
29
- Requires-Dist: colorama (>=0.4.5,<0.5.0)
30
- Requires-Dist: keyring (>=23,<25)
31
- Requires-Dist: pick (>=2.0.2,<3.0.0)
32
- Requires-Dist: platformdirs (>=3.5.1,<4.0.0)
33
- Requires-Dist: tabulate (>=0.9.0,<0.10.0)
34
- Project-URL: Repository, http://github.com/CrowdStrike/Falcon-Toolkit
35
- Description-Content-Type: text/markdown
36
-
37
1
  <!--markdownlint-disable MD033-->
38
2
  # Falcon Toolkit
39
3
 
@@ -57,8 +21,9 @@ The toolkit provides:
57
21
  - Multiple profile support, including support for MSSP / Falcon Flight Control configurations.
58
22
  - A shell allowing you to interface with many hosts via RTR at once, and get the output via CSV.
59
23
  - Scriptability! You can program the shell by providing pre-written routines via a file on disk, and a full Python extensibility API is provided.
60
- - Prevention policy import and export
61
- - Response policy import and export
24
+ - Prevention policy import and export.
25
+ - Response policy import and export.
26
+ - Contain and uncontain systems in bulk, according to filters or a list of device IDs.
62
27
  - More functionality is coming soon! Want more functionality? Open an [Issue](https://github.com/CrowdStrike/Falcon-Toolkit/issues/new)!
63
28
 
64
29
  Since this is built on top of Caracara, you get a bunch of great functionality and flexibility free, including the ability to filter hosts using dynamically generated FQL queries, full debug logging where desired, Falcon Flight Control integration, and more! Plus, the tool is lightning quick as it leverages Caracara's parallelisation tricks to pull more information quickly.
@@ -218,17 +183,19 @@ Two types of configuration backends are provided out of the box: the default, wh
218
183
 
219
184
  Your API keys should have the following scopes enabled in the Falcon dashboard:
220
185
 
221
- | &darr; API Scopes // Commands &rarr; | `host_search` | `shell` | `policies`<br>(Prevention) | `policies`<br>(Response) |
222
- |--------------------------------------|:-------------:|:-------:|:--------------------------:|:-------------------------:|
223
- | **Falcon Flight Control: Read** | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* |
224
- | **Hosts: Read** | X | X | | |
225
- | **Prevention Policies: Read** | | | X<br>`describe` / `export` sub-commands | |
226
- | **Prevention Policies: Write** | | | X<br>`import` sub-command | |
227
- | **Real Time Response: Read** | | X | | |
228
- | **Real Time Response: Write** | | X | | |
229
- | **Real Time Response: Admin** | | X<br>*for admin commands* | | |
230
- | **Response Policies: Read** | | | | X<br>`describe` / `export` sub-commands |
231
- | **Response Policies: Write** | | | | X<br>`import` sub-command |
186
+ | &darr; API Scopes // Commands &rarr; | `host_search` | `shell` | `policies`<br>(Prevention) | `policies`<br>(Response) | `containment`<br>Host Containment | `maintenance_token`<br>Maintenance Tokens |
187
+ |--------------------------------------|:-------------:|:-------:|:--------------------------:|:-------------------------:|:---------------------------------:|:-----------------------------------------:|
188
+ | **Falcon Flight Control: Read** | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | X<br>*When using parent<br>CID API Keys* | | |
189
+ | **Hosts: Read** | X | X | | | X | X |
190
+ | **Hosts: Write** | | | | | X | |
191
+ | **Prevention Policies: Read** | | | X<br>`describe` / `export` sub-commands | | | |
192
+ | **Prevention Policies: Write** | | | X<br>`import` sub-command | | | |
193
+ | **Real Time Response: Read** | | X | | | | |
194
+ | **Real Time Response: Write** | | X | | | | |
195
+ | **Real Time Response: Admin** | | X<br>*for admin commands* | | | | |
196
+ | **Response Policies: Read** | | | | X<br>`describe` / `export` sub-commands | | |
197
+ | **Response Policies: Write** | | | | X<br>`import` sub-command | | |
198
+ | **Sensor Update Policies: Write** | | | | | | X |
232
199
 
233
200
  ### Showing Your Profiles
234
201
 
@@ -391,6 +358,73 @@ Some example usages of this functionality are as follows:
391
358
 
392
359
  </details>
393
360
 
361
+ ## Maintenance Tokens
362
+
363
+ You can fetch maintenance tokens for systems within your Falcon tenant, or retrieve the bulk maintenance token.
364
+
365
+ ### Examples
366
+
367
+ Show the bulk maintenance token:
368
+
369
+ ```shell
370
+ $ falcon -p MyCompany maintenance_token -b
371
+ Getting the bulk maintenance token
372
+ Bulk maintenance token: redactedexample12345
373
+ WARNING: this token must be kept safe, as it can uninstall all Falcon sensors!
374
+ ```
375
+
376
+ Show a token for a specific system located by hostname:
377
+
378
+ ```shell
379
+ $ falcon -p MyCompany maintenance_token -f Hostname=MY-TEST-BOX-1
380
+ ```
381
+
382
+ Show maintenance tokens for a list of device IDs provided on the command line:
383
+
384
+ ```shell
385
+ $ falcon -p MyCompany maintenance_token -d aid1,aid2,...
386
+ ```
387
+
388
+ ## Network Containment
389
+
390
+ You can `contain` and `uncontain` systems through Falcon Toolkit. Network containment restricts the network connectivity of matching systems to just the Falcon Platform.
391
+
392
+ The containment functionality accepts the same command line parameters as `host_search` and `shell` (`-d`, `-df`, or multiple instances of `-f` to apply Falcon filters).
393
+
394
+ ### Examples
395
+
396
+ Network contain all systems that match the FQL hostname pattern `DEVTEST*`:
397
+
398
+ ```shell
399
+ $ falcon -p MyCompany containment -f Hostname=DEVTEST\* contain
400
+ ...
401
+ ```
402
+
403
+ Lift the containment status on the same machines:
404
+
405
+ ```shell
406
+ $ falcon -p MyCompany containment -f Hostname=DEVTEST\* uncontain
407
+ ...
408
+ ```
409
+
410
+ Network contain specific systems by AID:
411
+
412
+ ```shell
413
+ $ falcon -p MyCompany containment -d aid1,aid2,aid3 contain
414
+ ...
415
+ ```
416
+
417
+ Network contain all systems in a CID:
418
+
419
+ ```shell
420
+ $ falcon -p MyCompany containment contain
421
+ You did not specify any parameters. This command will manage the containment status of ALL devices in the Falcon tenant!
422
+ You must enter the string "I AM SURE!" to proceed.
423
+ Are you sure? I AM SURE!
424
+ ...
425
+ ```
426
+
427
+
394
428
  ## Policy Manipulation
395
429
 
396
430
  You can `describe`, `import` and `export` two types of policies: Prevention and Response. The three verbs are applied to the `falcon policies` command to specify what you would like to do with policies, and a command line switch is used to specify the policy type to work with. Exported policies are written to disk as JSON with some Falcon Toolkit-specific data needed to import a policy back again.
@@ -444,4 +478,3 @@ Furthermore, GitHub Discussions provide the community with means to communicate.
444
478
  *Security issues should be raised to our [Security team](mailto:security@crowdstrike.com) and [Chris Hammond](mailto:Chris.Hammond@crowdstrike.com).*
445
479
 
446
480
  Thank you for using the Falcon Toolkit! We hope it is as useful to the Falcon user community as it is to us.
447
-
@@ -5,17 +5,16 @@ user which child CID to authenticate against.
5
5
  """
6
6
  import os
7
7
 
8
- from typing import Dict, List, Optional
8
+ from typing import Dict, Optional
9
9
 
10
10
  import keyring
11
- import pick
12
11
 
13
12
  from caracara import Client
14
13
 
15
14
  from falcon_toolkit.common.auth import AuthBackend
16
15
  from falcon_toolkit.common.auth_backends.utils import advanced_options_wizard
17
16
  from falcon_toolkit.common.constants import KEYRING_SERVICE_NAME
18
- from falcon_toolkit.common.utils import fancy_input
17
+ from falcon_toolkit.common.utils import fancy_input, choose_cid
19
18
 
20
19
 
21
20
  class PublicCloudFlightControlParentCIDBackend(AuthBackend):
@@ -118,16 +117,10 @@ class PublicCloudFlightControlParentCIDBackend(AuthBackend):
118
117
  )[chosen_cid_str]
119
118
  else:
120
119
  child_cids_data = parent_client.flight_control.get_child_cid_data(cids=child_cids)
121
-
122
- options: List[pick.Option] = []
123
- for child_cid_str, child_cid_data in child_cids_data.items():
124
- child_cid_name = child_cid_data['name']
125
- option_text = f"{child_cid_str}: {child_cid_name}"
126
- option = pick.Option(label=option_text, value=child_cid_str)
127
- options.append(option)
128
-
129
- chosen_option, _ = pick.pick(options, "Please select a CID to connect to")
130
- chosen_cid_str = chosen_option.value
120
+ chosen_cid_str = choose_cid(
121
+ cids=child_cids_data,
122
+ prompt_text="MSSP Child CID Search"
123
+ )
131
124
  chosen_cid = child_cids_data[chosen_cid_str]
132
125
 
133
126
  chosen_cid_name = chosen_cid['name']
@@ -5,16 +5,17 @@ provide out of the box, as well as any that developers may write in the future.
5
5
  designed to avoid excessive code-reuse between similar implementations of auth backend.
6
6
  This file provides:
7
7
  - A list of all public CrowdStrike clouds
8
- - A cloud selection function to allow a user to choose a cloud via pick
8
+ - A cloud selection function to allow a user to choose a cloud via Prompt Toolkit
9
9
  - Advanced options configuration for overriding cloud, TLS validation, etc.
10
10
  """
11
11
  from typing import (
12
12
  Dict,
13
13
  List,
14
14
  NamedTuple,
15
+ Tuple,
15
16
  )
16
17
 
17
- import pick
18
+ from caracara.common.csdialog import csradiolist_dialog
18
19
 
19
20
  from falcon_toolkit.common.utils import fancy_input
20
21
 
@@ -29,13 +30,17 @@ CLOUDS = {
29
30
 
30
31
 
31
32
  def cloud_choice() -> str:
32
- """Configure a selection of clouds and allow the user to choose one via pick."""
33
- cloud_choices: List[pick.Option] = []
33
+ """Configure a selection of clouds and allow the user to choose one via Prompt Toolkit."""
34
+ cloud_choices: List[Tuple] = []
34
35
  for cloud_id, cloud_description in CLOUDS.items():
35
- cloud_choices.append(pick.Option(cloud_description, cloud_id))
36
+ cloud_choices.append((cloud_id, cloud_description))
36
37
 
37
- chosen_option, _ = pick.pick(cloud_choices, title="Please choose a Falcon cloud")
38
- chosen_falcon_cloud: str = chosen_option.value
38
+ chosen_falcon_cloud: str = csradiolist_dialog(
39
+ title="Falcon Cloud Selection",
40
+ text="Please choose a Falcon cloud",
41
+ cancel_text=None,
42
+ values=cloud_choices,
43
+ ).run()
39
44
 
40
45
  return chosen_falcon_cloud
41
46
 
@@ -56,12 +61,16 @@ def advanced_options_wizard() -> AdvancedOptionsType:
56
61
 
57
62
  cloud_name = cloud_choice()
58
63
 
59
- tls_verify_options: List[pick.Option] = [
60
- pick.Option("Verify SSL/TLS certificates (recommended!)", value=True),
61
- pick.Option("Do not verify SSL/TLS certificates (not recommended)", False),
64
+ tls_verify_options = [
65
+ (True, "Verify SSL/TLS certificates (recommended!)"),
66
+ (False, "Do not verify SSL/TLS certificates (not recommended)"),
62
67
  ]
63
- chosen_ssl_verify, _ = pick.pick(tls_verify_options, title="Verify SSL/TLS certificates?")
64
- ssl_verify: bool = chosen_ssl_verify.value
68
+ ssl_verify: bool = csradiolist_dialog(
69
+ title="Connection Security",
70
+ text="Enable SSL/TLS certificate verification?",
71
+ cancel_text=None,
72
+ values=tls_verify_options,
73
+ ).run()
65
74
 
66
75
  proxy_dict = None
67
76
  proxy_url_input = fancy_input("HTTPS proxy URL (leave blank if not needed): ", loop=False)
@@ -0,0 +1,113 @@
1
+ """Falcon Toolkit: Common Utils.
2
+
3
+ This file is a catch-all for small code snippets that can be shared across the various sub-modules
4
+ of the application.
5
+ """
6
+ import os
7
+
8
+ from typing import Dict, Iterable
9
+
10
+ from colorama import (
11
+ Fore,
12
+ Style,
13
+ )
14
+ from prompt_toolkit import prompt
15
+ from prompt_toolkit.completion import CompleteEvent, Completer, Completion
16
+ from prompt_toolkit.document import Document
17
+
18
+ from falcon_toolkit.common.constants import LOG_SUB_DIR
19
+
20
+
21
+ def fancy_input(prompt_text: str, loop: bool = True):
22
+ """Request user input (with colour). Optionally loop until the input is not blank."""
23
+ inputted = False
24
+ colour_prompt = Style.BRIGHT + Fore.BLUE + \
25
+ prompt_text + Fore.RESET + Style.RESET_ALL
26
+
27
+ while not inputted:
28
+ data = input(colour_prompt)
29
+ if data or not loop:
30
+ inputted = True
31
+
32
+ return data
33
+
34
+
35
+ def fancy_input_int(prompt_text: str) -> int:
36
+ """Request an integer from the user (with colour), and loop until the input is valid."""
37
+ valid_input = False
38
+ while not valid_input:
39
+ typed_input = fancy_input(prompt_text, loop=True)
40
+ if typed_input.isdigit():
41
+ valid_input = True
42
+
43
+ return int(typed_input)
44
+
45
+
46
+ def configure_data_dir(config_dir: str):
47
+ """Configure the Falcon Toolkit data directory with a directory skeleton."""
48
+ if os.path.exists(config_dir):
49
+ if not os.path.isdir(config_dir):
50
+ raise ValueError("Specified configuration directory path is already a file")
51
+ else:
52
+ os.makedirs(config_dir)
53
+
54
+ logs_path = os.path.join(config_dir, LOG_SUB_DIR)
55
+ if not os.path.exists(logs_path):
56
+ os.makedirs(logs_path)
57
+
58
+
59
+ def filename_safe_string(unsafe_string: str) -> str:
60
+ """Convert an unsafe string to one that can be included in a filename.
61
+
62
+ This function is heavily inspired by https://stackoverflow.com/a/7406369.
63
+ """
64
+ safe_string = "".join(
65
+ [c for c in unsafe_string if c.isalpha() or c.isdigit() or c == ' ']
66
+ ).rstrip()
67
+
68
+ # Replace spaces with underscores to match the general format of the log filename
69
+ clean_string = safe_string.replace(' ', '_')
70
+
71
+ return clean_string
72
+
73
+
74
+ class CIDCompleter(Completer):
75
+ """Prompt Toolkit Completer that provides a searchable list of CIDs."""
76
+
77
+ def __init__(self, data_dict: Dict[str, Dict]):
78
+ """Create a new CID completer based on a dictionary that maps CIDs to meta strings."""
79
+ self.data_dict = data_dict
80
+
81
+ def get_completions(
82
+ self,
83
+ document: Document,
84
+ complete_event: CompleteEvent,
85
+ ) -> Iterable[Completion]:
86
+ """Yield CIDs that match the entered search string."""
87
+ for cid, cid_data in self.data_dict.items():
88
+ cid_name = cid_data["name"]
89
+ cloud_name = cid_data.get("cloud_name")
90
+ if cloud_name:
91
+ display_meta = f"{cid_name} [{cloud_name}]"
92
+ else:
93
+ display_meta = cid_name
94
+
95
+ word_lower = document.current_line.lower()
96
+ if word_lower in cid or word_lower in display_meta.lower():
97
+ yield Completion(
98
+ cid,
99
+ start_position=-len(document.current_line),
100
+ display=cid,
101
+ display_meta=display_meta,
102
+ )
103
+
104
+
105
+ def choose_cid(cids: Dict[str, Dict], prompt_text="CID Search") -> str:
106
+ """Choose a CID from a dictionary of CIDs via Prompt Toolkit and return the CID string."""
107
+ cid_completer = CIDCompleter(data_dict=cids)
108
+ chosen_cid = None
109
+ while chosen_cid not in cids:
110
+ chosen_cid = prompt(f"{prompt_text} >", completer=cid_completer)
111
+
112
+ print(chosen_cid)
113
+ return chosen_cid
@@ -0,0 +1,4 @@
1
+ """Falcon Toolkit: Host Containment.
2
+
3
+ This sub-module contains the implementation of the falcon containment commands.
4
+ """