-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.txt
373 lines (325 loc) · 13.4 KB
/
help.txt
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
Help on module PiVault:
NAME
PiVault
DESCRIPTION
Very simply secrets vault.
- Takes in a string, encrypts it and stores the encrypted string.
- Then retrieves the encrypted string and decrypts it for use
Author Siggi Bjarnason AUG 2022
Copyright 2022
Encrypt/decrypt functions copied from https://stackoverflow.com/a/44212550/8549454
Following packages need to be installed for base functionality
pip install pycryptodome
pip install maskpass
If you want to use clipboard feature
pip install pyperclip
If you are using Redis also:
pip install redis
If you are using TOTP feature
pip install pyotp
FUNCTIONS
AddFileItem(strKey, strValue, bConf=True, strPass='')
Function that encrypts the string provided and
stores the key value pair in the file system data store
Parameters:
strKey: The name of the key part of the key value pair
strValue: The value part of the key value pair
bConf: Optional, defaults to True. If key updates should be confirmed
strPass: Optional, defaults to blank string. Use a password other than
that validated by login function
Returns:
True/false boolean to indicate if the was successful or not
AddItem(strKey, strValue, bConf=True, strPass='')
Function that calls the right function to encrypt and store the value depend on selected store
Parameters:
strKey: The name of the key part of the key value pair
strValue: The value part of the key value pair
bConf: Optional, defaults to True. If key updates should be confirmed
strPass: Optional, defaults to blank string. Use a password other than
that validated by login function
Returns:
True/false boolean to indicate if the was successful or not
AddRedisItem(strKey, strValue, bConf=True, strPass='')
Function that encrypts the string provided and
stores the key value pair in the Redis data store
Parameters:
strKey: The name of the key part of the key value pair
strValue: The value part of the key value pair
bConf: Optional, defaults to True. If key updates should be confirmed
strPass: Optional, defaults to blank string. Use a password other than
that validated by login function
Returns:
True/false boolean to indicate if the value was successful or not
AddSQLItem(strKey, strValue, bConf=True, strPass='')
Function that encrypts the string provided and
stores the key value pair in the selected database
Parameters:
strKey: The name of the key part of the key value pair
strValue: The value part of the key value pair
bConf: Optional, defaults to True. If key updates should be confirmed
strPass: Optional, defaults to blank string. Use a password other than
that validated by login function
Returns:
True/false boolean to indicate if the value was successful or not
ChangePWD(strNewPWD)
Function that loops through all items in the store, decrypts it then re-encrypts with new password.
Parameters:
none
Returns:
nothing
CheckDependency(Module)
Function that installs missing depedencies
Parameters:
Module : The name of the module that should be installed
Returns:
dictionary object without output from the installation.
if the module needed to be installed
code: Return code from the installation
stdout: output from the installation
stderr: errors from the installation
args: list object with the arguments used during installation
success: true/false boolean indicating success.
if module was already installed so no action was taken
code: -5
stdout: Simple String: {module} version {x.y.z} already installed
stderr: Nonetype
args: module name as passed in
success: True as a boolean
CheckVault()
Function used by login function to check the vault.
Parameters:
none
Returns:
true/false indicating if the vault is good or not
CreateConfig(dictOut)
Function that Creates a configuration file that can be customized
then used instead of environment variables
Parameters:
dictOut: Dictionary object of configuration items
Returns:
tru/false indicating success of failure
DBClean(strText)
Function that removes undesirables from a string to prevent SQL injection
Parameters:
strText: String to be cleaned
Returns:
Clean string that is safe to send to database query
DBConnect(*, DBType, Server, DBUser='', DBPWD='', Database='')
Function that handles establishing a connection to a specified database
imports the right module depending on database type
Parameters:
DBType : The type of database server to connect to
Supported server types are sqlite, mssql, mysql and postgres
Server : Hostname for the database server
DBUser : Database username
DBPWD : Password for the database user
Database : The name of the database to use
Returns:
Connection object to be used by query function, or an error string
DBQuery(*, SQL, dbConn)
Function that handles executing a SQL query using a predefined connection object
imports the right module depending on database type
Parameters:
SQL : The query to be executed
dbConn : The connection object to use
Returns:
NoneType for queries other than select, DBCursor object with the results from the select query
or error message as a string
DefineColors()
Simple function that loads the dictColor dictionary of colors
Parameters:
none
Returns:
Sets global variable dictColor but returns nothing
DefineMenu()
Simple function that loads the menu into a global dictionary dictMenu
Parameters:
none
Returns:
Sets global variable dictMenu but returns nothing
DelItem(strKey)
Function that removes a key from the datastore
Parameters:
strKey: The name of the key part of the key value pair
Returns:
Nothing
DisplayHelp()
Function that displays a help message.
Parameters:
none
Returns:
none
Fetch2Clip(strKey)
Function that fetches the specified key from the datastore and decrypts it.
Decrypted value is then placed on the clipboard and not shown.
Parameters:
strKey: The name of the key to be fetched
Returns:
nothing
FetchEnv(strVarName)
Function that fetches the specified content of specified environment variable,
converting nonetype to empty string.
Parameters:
strVarName: The name of the environment variable to be fetched
Returns:
The content of the environment or empty string
FetchFileItem(strKey)
Function that fetches the specified key from the file store and decrypts it.
Parameters:
strKey: The name of the key to be fetched
Returns:
Either the decrypted string or boolean false to indicate a failure
FetchItem(strKey)
Function that calls the right function to fetch and decrypt depend on selected store
Parameters:
strKey: The name of the key to be fetched
Returns:
Either the decrypted string or boolean false to indicate a failure
FetchRedisItem(strKey)
Function that fetches the specified key from Redis and decrypts it.
Parameters:
strKey: The name of the key to be fetched
Returns:
Either the decrypted string or boolean false to indicate a failure
FetchSQLItem(strKey)
Function that fetches the specified key from database and decrypts it.
Parameters:
strKey: The name of the key to be fetched
Returns:
Either the decrypted string or boolean false to indicate a failure
GetFileHandle(strFileName, strperm)
This wraps error handling around standard file open function
Parameters:
strFileName: Simple string with filename to be opened
strperm: single character string, usually w or r to indicate read vs write. other options such as "a" are valid too.
Returns:
File Handle object
ListCount()
Function that displays information about status of the vault and number of members.
Parameters:
none
Returns:
nothing
ListItems()
Function that just lists out all the keys in the store.
Parameters:
none
Returns:
nothing
MsgOut(strMsg)
Function that check quiet environment variable and only prints if it is false
Parameters:
strMsg: String to be printed
Returns:
Nothing
PrepConfig()
Function that Creates a dictionary of configuration items
for use by the configuration file creator
Parameters:
nothing
Returns:
dictionary object of all configuration items.
ProcessCMD(objCmd)
Function that process all the user commands, whether in the shell or from command arguments.
Parameters:
objCmd: The command string, either simple string or an array of strings
Returns:
nothing
ResetStore()
Function that completely resets the choosen store to a blank slate
Parameters:
none
Returns:
Nothing
SQLOp(strCmd, strKey='', strValue='')
This handles all database operations
Parameters:
strCmd: Which operation is needed
strkey: Optional, defaults to an empty string. The name of the key part of the key value pair
strValue: Optional, defaults to an empty string. The value part of the key value pair.
Returns:
Decrypted clear text simple string
ShowGUI()
Function that handles the whole GUI. All GUI functions and code are here
Parameters:
nothing
Returns:
nothing
ShowTOTP(strKey)
Function that fetches the specified key from the datastore and decrypts it.
Decrypted value is then used to generate a time based one time token.
Parameters:
strKey: The name of the key to be fetched
Returns:
A string with the generated token, or bolean false on failure
StringDecryptor(strPWD, strData, decode=True)
This handles decrypting a string encrypted with AES
Adopted from https://stackoverflow.com/a/44212550/8549454
Parameters:
strPWD: Simple string with encryption password
strData: Simple string with the encrypted data
encode: Optional, defaults to true. A boolean to indicate if the data is Base64 encoded.
Returns:
Decrypted clear text simple string
StringEncryptor(strPWD, strData, encode=True)
This handles encrypting a string using AES.
Adopted from https://stackoverflow.com/a/44212550/8549454
Parameters:
strPWD: Simple string with encryption password
strData: Simple string with the data to be encrypted
encode: Optional, defaults to true. A boolean to indicate the return should be Base64 encoded.
Returns:
Encrypted string, either raw or base64 encoded depending on the encode parameter
UserLogin()
Simple function that handles validating that password is valid across all items in the vault
Parameters:
none
Returns:
true/false boolean to indicate if password supplied is good or not
VaultInit()
Function that handles initial inititialization of the specified store.
Parameters:
none
Returns:
nothing returned. Applicable global variables are set.
isFloat(fValue)
Function checks if a value is a floating point number
Parameters:
fValue: String to be evaluated
Returns:
true/false
isInt(CheckValue)
Function checks if a value is an integer
Parameters:
CheckValue: String to be evaluated
Returns:
true/false
main()
Initial entry point where some of the initialization takes place.
Parameters:
none
Returns:
nothing
processConf(strConf_File)
Function that processes a configuration file that can be customized
then used instead of environment variables
Parameters:
nothing
Returns:
Nothing
DATA
bDefAutoHide = True
bDefHide = False
bLoggedIn = False
dictComponents = {'------------------': '-----------', 'aiofiles': '0....
iDefShowTime = 30
iTimer = 0
lstDBTypes = ['sqlite', 'mysql', 'postgres', 'mssql']
lstStoreTypes = ['files', 'redis']
strCheckKey = 'VaultInit'
strCheckValue = 'This is a simple secrets vault'
strDefStore = 'files'
strDefTable = 'tblVault'
strDefValueColor = 'red'
strDefVault = 'VaultData'
strICOFile = 'PieLock.ico'