-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision_msp.py
73 lines (60 loc) · 3.18 KB
/
provision_msp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# This script provides an example of how to use the Deep Instinct REST API
# Wrapper published at https://github.com/pvz01/deepinstinct_rest_api_wrapper
# to provision new MSPs on a multi-tenancy server, including pre-populating
# them with a set of policies based upon a template MSP.
# This script is provided as-is and with no warranty. Use at your own risk, and
# please test in a non-production environment first.
# PREREQUISITES
# 1. Python 3.8 or later
# 2. Deep Instinct REST API Wrapper
# 3. Third-party libraries (strongly recommend to install Anaconda)
# 4. Network access to management server on port 443
# 5. Multi-tenancy enabled D-Appliance (management server)
# 6. A Full Access API key for all MSPs
# KNOWN LIMITATIONS AND USAGE NOTES
# Only policy settings that are available to read and write via the
# DI REST API are migrated. Any settings not visible via the API remain
# at their defailts in the destination policies. As of December 2021, the
# non-visible fields in Windows policies are:
# 1. Enable D-Cloud services
# 2. Embedded DDE object in Microsoft Office document
# 3. Suspicious Script Execution
# 4. Malicious PowerShell Command Execution
# 5. Suspicious Activity Detection
# 6. Suspicious PowerShell Command Execution
# 7. Integrate D-Client with Windows Security Center
# 8. Permitted connections for network isolated devices
# 9. Gradual Deployment
# For up-to-date information, reference the WindowsPolicyData model in the API
# documentation on your DI server. If/when additional fields are added, this
# script will automatically migrate them.
# USAGE
# 1. Save the latest version of both this file (provision_msp.py) and
# the DI API Wrapper (deepinstinct30.py) to the same folder on disk.
# 2. Edit this file to provide the customer name, license count, server, api
# key, and the id of the template msp in-line below.
# 3. Execute the script with this command: python provision_msp.py
import deepinstinct3 as di
import json
#define details of the new customer
customer_name = 'Mos Eisley Cantina'
license_count = 327
#define which already-existing MSP on the server is the template (to copy policies from)
template_msp_id = 1
#set server name (must be a MULTI-TENANCY enabled D-Appliance)
di.fqdn = 'foobar.customers.deepinstinctweb.com'
#define API keys to use (both must be created in DI Hub and have access to All MSPSs)
full_access_key = 'alice'
account_management_key = 'bob'
#create new msp for the customer and one tenant within it
di.key = full_access_key
new_msp = di.create_msp(customer_name, license_count)
new_tenant = di.create_tenant(customer_name, license_count, new_msp['name'])
#pretty-print the new Tenant information, which includes activation tokens
print(json.dumps(new_tenant, indent=4))
#create a user within the new MSP
di.key = account_management_key
di.create_user(username='wuher', password='NoDroids1!', first_name='Wuher', last_name='The Bartender', email='wuher@tatooine.is', role='MASTER_ADMINISTRATOR', msp_id=new_msp['id'])
#copy the policy data from the template to the new MSP
di.key = full_access_key
di.migrate_policies(source_msp_id=template_msp_id, destination_msp_id=new_msp['id'])