-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathpy_thiccer.py
130 lines (71 loc) · 2.29 KB
/
py_thiccer.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import suds
from suds import client
from suds.transport.http import HttpAuthenticated
class NoThyiccForYou(Exception):
pass
class Thyiccer(object):
__endpoint = "http://<yourdomain>/webservices/SSWebservice.asmx?wsdl"
__token = None
__client = None
def __init__(self, domain, username, password):
try:
self.__client = suds.client.Client(self.__endpoint)
except:
raise NoThyiccForYou('Could not reach the endpoint!')
try:
self.__token = self.__client.service.Authenticate(username,password,"",domain)
except:
raise NoThyiccForYou("The specified credentials were invalid!")
def getFolders(self):
try:
TMP = self.__client.service.SearchFolders(self.__token,"*")
except:
try:
Results = []
for folder in TMP.Folders.Folder:
Results.append(folder)
return Results
except:
raise NoThyiccForYou('We could not query the folders')
def getChildFolders(self, Id):
try:
TMP = self.__client.service.FolderGetAllChildren(self.__token, Id)
except:
raise NoThyiccForYou('We could not get the child folders!')
try:
Results = []
for folder in TMP.Folders.Folder:
Results.append(folder)
return Results
except:
raise NoThyiccForYou('We could not get the cild folders!')
def getSecrets(self):
try:
TMP = self.__client.service.SearchSecrets(self.__token,"*")
except:
raise NoThyiccForYou('We could not get the secrets!')
try:
Results = []
for secret in TMP.SecretSummaries.SecretSummary:
Results.append(secret)
return Results
except:
raise NoThyiccForYou('We could not get the secrets!')
def getSecret(self, Id):
try:
TMP = self.__client.service.GetSecret(self.__token,Id)
except:
raise NoThyiccForYou('We could not get the secret!')
try:
Results = []
for secret in TMP.Secret.Items.SecretItem:
Results.append(secret)
return Results
except:
raise NoThyiccForYou('We could not get the secrets!')
if __name__ == '__main__':
THY = Thyiccer(domain = 'mydomain', username = 'myuser', password = 'mypassword')
print(THY.getSecrets())
print(THY.getSecret(Id = 182918))
print(THY.getFolders())
print(THY.getChildFolders(Id = 101))