-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdiscovery_updatesettings.py
More file actions
63 lines (50 loc) · 2.72 KB
/
Copy pathdiscovery_updatesettings.py
File metadata and controls
63 lines (50 loc) · 2.72 KB
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
import requests
import json
import argparse
file = open("config.json", "r")
data = json.load(file)
file.close()
USER_ID = data['USER_ID']
API_TOKEN = data['API_TOKEN']
API_ROOT = data['API_ROOT']
AUTH = (USER_ID, API_TOKEN)
def discovery_updatesettings():
endpoint_url = API_ROOT % "discovery/update-settings"
parser = argparse.ArgumentParser(description='Updates discovery settings.')
parser.add_argument('-isl', '-islds', type=str, help='Gets or sets the included SLDS')
parser.add_argument('-ii', '-iiprng', type=str, help='Gets or sets the included ip ranges')
parser.add_argument('-io', '-iorgs', type=str, help='Gets or sets the included organizations')
parser.add_argument('-es', '-eslds', type=str, help='Gets or sets the excluded SLDS')
parser.add_argument('-et', '-etlds', type=str, help='Gets or sets the excluded TLDS')
parser.add_argument('-ei', '-eipadr', type=str, help='Gets or sets the excluded ip addresses')
parser.add_argument('-eo', '-eorgs', type=str, help='Gets or sets the excluded organizations')
parser.add_argument('-ord', '-onredo', type=str, choices=['true', 'false'], default = 'false', help='Gets or sets a value indicating whether [only registered domains]')
parser.add_argument('-sh', '-shhoma', type=str, choices=['true', 'false'], default = 'false', help='Gets or sets a value indicating whether [shared host matching]')
parser.add_argument('-on', '-ornmmt', type=str, choices=['true', 'false'], default = 'false', help='Gets or sets a value indicating whether [organization name matching]')
parser.add_argument('-em', '-emamt', type=str, choices=['true', 'false'], default = 'false', help='Gets or sets a value indicating whether [email matching]')
parser.add_argument('-wm', '-webmt', type=str, choices=['true', 'false'], default = 'false', help='Gets or sets a value indicating whether [websites matching]')
args = parser.parse_args()
json_object = {
"IncludedSlds": args.isl,
"IncludedIpRanges": args.ii,
"IncludedOrganizations": args.io,
"ExcludedSlds": args.es,
"ExcludedTlds": args.et,
"ExcludedIpAddresses": args.ei,
"ExcludedOrganizations": args.eo,
"OnlyRegisteredDomains": args.ord,
"SharedHostMatching": args.sh,
"OrganizationNameMatching": args.on,
"EmailMatching": args.em,
"WebsitesMatching": args.wm
}
response = requests.post(endpoint_url, json=json_object, auth=AUTH)
print("Response: %s - %s" % (response.status_code, response.reason))
if (response.status_code == 200):
print("The settings have been updated.")
else:
print(response.text)
def main():
discovery_updatesettings()
if __name__ == '__main__':
main()