diff --git a/.gitignore b/.gitignore index 9986deadf..1d3937df2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ .idea/ venv/ config.json* -dist -build -keeper.egg-info diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index d2385e49a..000000000 --- a/MANIFEST +++ /dev/null @@ -1,2 +0,0 @@ -# file GENERATED by distutils, do NOT edit -setup.py diff --git a/README.md b/README.md index 368da2393..6c9c6534c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ - + ---- #### The Password Management SDK for IT Admins & Developers Keeper Commander is a command-line and SDK interface to [Keeper® Password Manager](https://keepersecurity.com). Keeper Commander can be used to interactively access your Keeper Vault via a standard terminal or SSH console, or it can be used as an SDK for integrating your back-end into Keeper's zero-knowledge Cloud Security Vault™. -Commander can securely rotate passwords in your Keeper vault and then automatically synchronize the change to all users with privileged access to the record. Using our connector [plugins](https://github.com/Keeper-Security/commander/tree/master/keeper/plugins), you can then perform the password reset directly on the source (e.g. database, active directory, unix/pc login, etc...). Using Commander to rotate passwords, combined with the flexibility of Keeper's secure record sharing features provides you with the most secure and flexible way to grant and revoke access to extremely confidential data. +Commander can securely rotate passwords in your Keeper vault and then automatically synchronize the change to all users with privileged access to the record. Using our connector [plugins](https://github.com/Keeper-Security/commander/tree/master/src/plugins), you can then perform the password reset directly on the source (e.g. database, active directory, unix/pc login, etc...). Using Commander to rotate passwords, combined with the flexibility of Keeper's secure record sharing features provides you with the most secure and flexible way to grant and revoke access to extremely confidential data. [Here's a Video](https://youtu.be/p50OKRiaxl8) demonstrating Commander. @@ -20,7 +20,7 @@ Commander can securely rotate passwords in your Keeper vault and then automatica * Control record and user permissions * Automate everything - + Keeper Commander provides deep integration of privileged password management into back-end systems to securely access credentials, elevate permissions and rotate passwords. With Keeper Commander you can automate key security features on any platform. @@ -28,147 +28,8 @@ Changes made through Keeper Commander instantly propagate to the users who have When you grant and revoke access or rotate a password, it instantly updates to users on their mobile and desktop devices. Control access to highly secure systems by rotating passwords and pushing those credentials to users - all within the Keeper ecosystem. -### Installation - -You can install Keeper Commander with pip (the only requirement for this type of install is python 3. -You can install python3 by going to [python.org](https://www.python.org) and following the instructions): - -``` -pip3 install keeper -``` -Or, if you would like to make modifications, clone the repository and follow the instructions in the README within the keeper/ and keeper/plugins/ folder. - -#### Logging in - - -#### Listing available commands - - -#### Searching for records - - -#### Getting record details - - -#### Rotating a password - - -The above screenshots are using the terminal version. You can make the necessary hooks in the Commander source code to meet your integration needs. - -### Command line usage - -./keeper - -### Optional parameters - -./keeper --email=email@company.com - -### Auto-configuration file - -To automate the use of Commander, create a file called config.json and place the file in your install folder. If you don't provide a config file, Commander will just prompt you for the information. - -Here's an example config.json file: - -``` -{ - "server":"https://keeperapp.com/v2/", - "email":"your_email_here", - "password":"your_password_here", - "debug":false, - "commands":[] -} -``` - -You can also tell Commander which config file to use. By default, we look at the config.json file. Example: - -./keeper --config=foo.json - -In this case, Commander will start up using foo.json as the configuration. - -### Auto-command execution - -You can provide Commander a set of commands to run without having to type them manually. This is the easiest way to automate password resets. - -Example: - -``` -{ - "debug":false, - "server":"https://keeperapp.com/v2/", - "email":"admin@company.com", - "password":"somereallystrongpassword", - "commands":["d", "r 3PMqasi9hohmyLWJkgxCWg", "r tlCK0x1chKH8keW8-NOraA"] -} -``` - -In this example, we are telling Commander to first download and decrypt records, then reset 2 passwords. As you can see, each unique password record in the Keeper system is represented by a unique record UID. Use the "l" or "s" command in Commander's interactive mode to display the record UIDs in your account. - -### Two-Factor Authentication and Device Token - -If you have Two-Factor Authentication enabled on your Keeper account (highly recommended), Keeper Commander will prompt you for the one-time passcode the first time you login. After successfully logging in, you will be provided a device token. This device token needs to be saved for subsequent calls. Copy-paste this device token into your config.json file. For example: - -``` -{ - "debug":false, - "server":"https://keeperapp.com/v2/", - "email":"email@company.com", - "password":"123456", - "mfa_token":"vFcl44TdjQcgTVfCMlUw0O9DIw8mOg8fJypGOlS_Rw0WfXbCD9iw", - "mfa_type":"device_token", - "commands":["d", "r 3PMqasi9hohmyLWJkgxCWg", "r tlCK0x1chKH8keW8-NOraA"] -} -``` - -### Plugins - -Keeper Commander can talk to external systems for the purpose of resetting a password and synchronizing the change inside the Keeper Vault. For example, you might want to rotate your MySQL password and Active Directory password automatically. To support a plugin, simply add a custom field to the record to specify which plugin Keeper Commander should use when changing passwords. Example: - -``` -Name: cmdr:plugin -Value: mysql -``` -``` -Name: cmdr:plugin -Value: adpasswd -``` - -When a plugin is specified in a record, Commander will search in the plugins/ folder to load the module based on the name provided (e.g. mysql.py and active_directory.py). - -Keeper's team is expanding the number of plugins on an ongoing basis. If you need a particular plugin created, just let us know. - -### Commands - -To see a list of supported commands, simply type '?': - -``` -Keeper > ? - -Commands: - - d ... download & decrypt data - l ... list folders and titles - s ... search with regular expression - g ... get record details for uid - r ... rotate password for uid - b ... rotate password for matches of regular expression - a ... add a new record interactively - c ... clear the screen - h ... show command history - q ... quit - -``` - -* d (download): Downloads all records from the account, decrypts the data key, private key, decrypts records and shared folders. - -* l (list): Displays the Record UID, Folder and Title for all records. - -* s (search): search across all record data and display the Record UID, Folder and Title for matching records. - -* g (get): displays the full record details for a specified Record UID. The Record UID can be determined by looking at the response from the "l" or "s" commands. - -* r (rotate): rotates the password field of a specified Keeper record. The new password generated is by default set to a very strong 64-byte ASCII-based string. The previous password is also backed up and stored as a custom field in the record, saved with the timestamp of the change. - -* b (batch rotate): search across all record data and rotate the password for matching records. +### Installation +Follow the instructions in the README within the src/ and src/plugins/ folder. ### Support We're here to help. If you need help integrating Keeper into your environment, contact us at ops@keepersecurity.com. diff --git a/keeper/README.md b/keeper/README.md deleted file mode 100644 index e281842d3..000000000 --- a/keeper/README.md +++ /dev/null @@ -1,52 +0,0 @@ -Keeper Commander for Python 3 ----- - -This is the codebase for a Python 3 interface to Keeper. - -### Installation - -This type of installation assumes you want to view/modify the source code. Using the instructions below, -you will be able to have more than one copy of keeper commander installed without conflicting with each other. - -1) Install Python3 from [python.org](https://www.python.org) - -2) Install virtualenv: - -``` -sudo pip3 install virtualenv -``` - -3) Create and activate the virtual environment for your keeper project (you need to be in the keeper root folder): - -``` -virtualenv -p python3 venv -source venv/bin/activate -``` - -4) Install the required modules - -``` -pip install -r requirements.txt -``` - -5) Install the keeper package in development mode - -``` -pip install -e . -``` - -NOTE: Keeper Commander is only compatible with Python 3.4+ - -Keeper supports plugins for various 3rd party systems for password reset integration. Depending on the plugin, you will need to install the modules required. For example, to support our MySQL plugin: - -``` -pip3 install PyMySQL -``` - -6) Set up a Keeper account from https://keepersecurity.com if you don't already have one. - -7) Execute command line program as described below or use a config.json file to streamline usage. Command line arguments will override the configuration file. - -### Help - -If you need help, found a bug, or you're interesting in contributing, email us at ops@keepersecurity.com. \ No newline at end of file diff --git a/keeper/__init__.py b/keeper/__init__.py deleted file mode 100644 index 7a7ce403f..000000000 --- a/keeper/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -from keeper.cli import loop - - -def main(): - loop() - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/keeper/cli.py b/keeper/cli.py deleted file mode 100755 index c42abc520..000000000 --- a/keeper/cli.py +++ /dev/null @@ -1,226 +0,0 @@ -# _ __ -# | |/ /___ ___ _ __ ___ _ _ ® -# | ' ... search with regular expression') - print(' g ... get record details for uid') - print(' r ... rotate password for uid') - print(' b ... rotate password for matches of regular expression') - print(' a ... add a new record interactively') - print(' c ... clear the screen') - print(' h ... show command history') - print(' q ... quit') - print('') - - if params.command: - if params.command != 'h': - stack.append(params.command) - stack.reverse() - - return True - - -def loop(): - params = KeeperParams() - params.config_filename = 'config.json' - - display.welcome() - - # Parse command line options - # email, config, debug are optional - parser = argparse.ArgumentParser(usage='keeper [options]', - description='Keeper Commander') - parser.add_argument('--email', help='Email address for the account') - parser.add_argument('--config', help='Config file to use') - parser.add_argument('--debug', help='Turn on debug mode', action='store_true') - - args = parser.parse_args() - - if args.debug: - params.debug = args.debug - if args.email: - params.email = args.email - if args.config: - params.config_filename = args.config - - try: - with open(params.config_filename) as config_file: - - try: - params.config = json.load(config_file) - - if 'email' in params.config: - params.email = params.config['email'] - - if 'server' in params.config: - params.server = params.config['server'] - - if 'password' in params.config: - params.password = params.config['password'] - - if 'challenge' in params.config: - import yubikey.yubikey - challenge = params.config['challenge'] - params.password = yubikey.yubikey.get_response(challenge) - - if 'mfa_token' in params.config: - params.mfa_token = params.config['mfa_token'] - - if 'mfa_type' in params.config: - params.mfa_type = params.config['mfa_type'] - - if 'commands' in params.config: - params.commands = params.config['commands'] - - if 'plugins' in params.config: - params.plugins = params.config['plugins'] - - if 'debug' in params.config: - params.debug = params.config['debug'] - - except: - print('Error: Unable to parse JSON file ' + params.config_filename) - goodbye() - - except IOError: - if args.config: - print('Error: Unable to open config file ' + args.config) - pass - - try: - - if not params.server: - params.server = 'https://keeperapp.com/v2/' - - while not params.email: - params.email = getpass.getpass(prompt='Email: ', stream=None) - - # only prompt for password when no device token - while not params.password: - params.password = getpass.getpass(prompt='Password: ', stream=None) - - # if commands are provided, execute those then exit - if params.commands: - for c in params.commands: - params.command = c - print('Executing [' + params.command + ']...') - try: - if not do_command(params): - print('Command ' + params.command + ' failed.') - except CommunicationError as e: - print("Communication Error:" + str(e.message)) - except AuthenticationError as e: - print("AuthenticationError Error: " + str(e.message)) - except: - print('An unexpected error occurred: ' + str(sys.exc_info()[0])) - - params.command = '' - - goodbye() - - if params.debug: print('Params: ' + str(params)) - - # start with a sync download - if not params.command: - params.command = 'd' - - # go into interactive mode - while True: - if not params.command: - try: - params.command = input("Keeper > ") - except KeyboardInterrupt: - print('') - except EOFError: - raise KeyboardInterrupt - - try: - if not do_command(params): - raise KeyboardInterrupt - except CommunicationError as e: - print("Communication Error:" + str(e.message)) - except AuthenticationError as e: - print("AuthenticationError Error: " + str(e.message)) - except KeyboardInterrupt as e: - raise - except: - print('An unexpected error occurred: ' + str(sys.exc_info()[0])) - raise - - params.command = '' - - except KeyboardInterrupt: - goodbye() \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index bb9b02be2..000000000 --- a/setup.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup - -from os import path - -LICENSE = open("LICENSE").read() - -# strip links from the descripton on the PyPI -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the README file -with open(path.join(here, 'keeper', 'README.md'), encoding='utf-8') as f: - long_description = f.read() - -install_requires = [ - 'colorama', - 'pycrypto', - 'requests', - 'tabulate' -] - -setup(name='keeper', - version='0.2.5', - description='Keeper Commander for Python 3', - long_description=long_description, - author='Craig Lurey', - author_email='craig@keepersecurity.com', - url='https://github.com/Keeper-Security/Commander', - license=LICENSE, - classifiers=["Development Status :: 4 - Beta", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.4", - "Topic :: Security"], - keywords='security password', - - packages=['keeper'], - - entry_points={ - "console_scripts": [ - "keeper=keeper:main", - ], - }, - install_requires=install_requires - ) diff --git a/keeper/.gitignore b/src/.gitignore similarity index 100% rename from keeper/.gitignore rename to src/.gitignore diff --git a/src/README.md b/src/README.md new file mode 100644 index 000000000..e05101c27 --- /dev/null +++ b/src/README.md @@ -0,0 +1,173 @@ +Keeper Commander for Python 3 +---- + +This is the codebase for a Python 3 interface to Keeper. + +Here's a preview of what Keeper Commander can do: + +#### Logging in + + +#### Listing available commands + + +#### Searching for records + + +#### Getting record details + + +#### Rotating a password + + +The above screenshots are using the terminal version. You can make the necessary hooks in the Commander source code to meet your integration needs. + +### Installation + +1) Install Python3 from [python.org](https://www.python.org) + +2) Install the below modules + +``` +requests +pycrypto +colorama +``` + +For Mac/Linux users you would type: +``` +pip3 install requests +pip3 install pycrypto +pip3 install colorama +``` + +NOTE: Keeper Commander is only compatible with Python 3.4+ + +Keeper supports plugins for various 3rd party systems for password reset integration. Depending on the plugin, you will need to install the modules required. For example, to support our MySQL plugin: + +``` +pip3 install PyMySQL +``` + +3) Set up a Keeper account from https://keepersecurity.com if you don't already have one. + +4) Execute command line program as described below or use a config.json file to streamline usage. Command line arguments will override the configuration file. + +### Command line usage + +./keeper + +### Optional parameters + +./keeper --email=email@company.com + +### Auto-configuration file + +To automate the use of Commander, create a file called config.json and place the file in your install folder. If you don't provide a config file, Commander will just prompt you for the information. + +Here's an example config.json file: + +``` +{ + "server":"https://keeperapp.com/v2/", + "email":"your_email_here", + "password":"your_password_here", + "debug":false, + "commands":[] +} +``` + +You can also tell Commander which config file to use. By default, we look at the config.json file. Example: + +./keeper --config=foo.json + +In this case, Commander will start up using foo.json as the configuration. + +### Auto-command execution + +You can provide Commander a set of commands to run without having to type them manually. This is the easiest way to automate password resets. + +Example: + +``` +{ + "debug":false, + "server":"https://keeperapp.com/v2/", + "email":"admin@company.com", + "password":"somereallystrongpassword", + "commands":["d", "r 3PMqasi9hohmyLWJkgxCWg", "r tlCK0x1chKH8keW8-NOraA"] +} +``` + +In this example, we are telling Commander to first download and decrypt records, then reset 2 passwords. As you can see, each unique password record in the Keeper system is represented by a unique record UID. Use the "l" or "s" command in Commander's interactive mode to display the record UIDs in your account. + +### Two-Factor Authentication and Device Token + +If you have Two-Factor Authentication enabled on your Keeper account (highly recommended), Keeper Commander will prompt you for the one-time passcode the first time you login. After successfully logging in, you will be provided a device token. This device token needs to be saved for subsequent calls. Copy-paste this device token into your config.json file. For example: + +``` +{ + "debug":false, + "server":"https://keeperapp.com/v2/", + "email":"email@company.com", + "password":"123456", + "mfa_token":"vFcl44TdjQcgTVfCMlUw0O9DIw8mOg8fJypGOlS_Rw0WfXbCD9iw", + "mfa_type":"device_token", + "commands":["d", "r 3PMqasi9hohmyLWJkgxCWg", "r tlCK0x1chKH8keW8-NOraA"] +} +``` + +### Plugins + +Keeper Commander can talk to external systems for the purpose of resetting a password and synchronizing the change inside the Keeper Vault. For example, you might want to rotate your MySQL password and Active Directory password automatically. To support a plugin, simply add a custom field to the record to specify which plugin Keeper Commander should use when changing passwords. Example: + +``` +Name: cmdr:plugin +Value: mysql +``` +``` +Name: cmdr:plugin +Value: adpasswd +``` + +When a plugin is specified in a record, Commander will search in the plugins/ folder to load the module based on the name provided (e.g. mysql.py and active_directory.py). + +Keeper's team is expanding the number of plugins on an ongoing basis. If you need a particular plugin created, just let us know. + +### Commands + +To see a list of supported commands, simply type '?': + +``` +Keeper > ? + +Commands: + + d ... download & decrypt data + l ... list folders and titles + s ... search with regular expression + g ... get record details for uid + r ... rotate password for uid + b ... rotate password for matches of regular expression + a ... add a new record interactively + c ... clear the screen + h ... show command history + q ... quit + +``` + +* d (download): Downloads all records from the account, decrypts the data key, private key, decrypts records and shared folders. + +* l (list): Displays the Record UID, Folder and Title for all records. + +* s (search): search across all record data and display the Record UID, Folder and Title for matching records. + +* g (get): displays the full record details for a specified Record UID. The Record UID can be determined by looking at the response from the "l" or "s" commands. + +* r (rotate): rotates the password field of a specified Keeper record. The new password generated is by default set to a very strong 64-byte ASCII-based string. The previous password is also backed up and stored as a custom field in the record, saved with the timestamp of the change. + +* b (batch rotate): search across all record data and rotate the password for matching records. + +### Help + +If you need help, found a bug, or you're interesting in contributing, email us at ops@keepersecurity.com. diff --git a/keeper/api.py b/src/api.py similarity index 99% rename from keeper/api.py rename to src/api.py index 73f874cc7..0d4fd940a 100644 --- a/keeper/api.py +++ b/src/api.py @@ -17,11 +17,13 @@ import getpass import time import os -from keeper import generator +import generator import datetime -from keeper import plugin_manager, params -from keeper.record import Record -from keeper.error import AuthenticationError, CommunicationError, CryptoError +import plugin_manager +from record import Record +from error import AuthenticationError +from error import CommunicationError +from error import CryptoError from Crypto import Random from Crypto.Hash import SHA256, HMAC, SHA from Crypto.Protocol.KDF import PBKDF2 diff --git a/src/config.json.sample b/src/config.json.sample new file mode 100644 index 000000000..fca5bca3f --- /dev/null +++ b/src/config.json.sample @@ -0,0 +1,10 @@ +{ + "server":"https://keeperapp.com/v2/", + "email":"", + "password":"", + "mfa_token":"", + "mfa_type":"", + "debug":false, + "plugins":[], + "commands":[] +} diff --git a/keeper/display.py b/src/display.py similarity index 96% rename from keeper/display.py rename to src/display.py index 95c011171..017c12c8a 100644 --- a/keeper/display.py +++ b/src/display.py @@ -9,6 +9,10 @@ # Contact: ops@keepersecurity.com # +import sys +import json +import base64 +from record import Record from colorama import init from tabulate import tabulate diff --git a/keeper/error.py b/src/error.py similarity index 100% rename from keeper/error.py rename to src/error.py diff --git a/keeper/generator.py b/src/generator.py similarity index 100% rename from keeper/generator.py rename to src/generator.py diff --git a/keeper/images/commander_logo_512x205.png b/src/images/commander_logo_512x205.png similarity index 100% rename from keeper/images/commander_logo_512x205.png rename to src/images/commander_logo_512x205.png diff --git a/keeper/images/download_command.png b/src/images/download_command.png similarity index 100% rename from keeper/images/download_command.png rename to src/images/download_command.png diff --git a/keeper/images/mac.png b/src/images/mac.png similarity index 100% rename from keeper/images/mac.png rename to src/images/mac.png diff --git a/keeper/images/plugin_mysql_get.png b/src/images/plugin_mysql_get.png similarity index 100% rename from keeper/images/plugin_mysql_get.png rename to src/images/plugin_mysql_get.png diff --git a/keeper/images/plugin_screen1.png b/src/images/plugin_screen1.png similarity index 100% rename from keeper/images/plugin_screen1.png rename to src/images/plugin_screen1.png diff --git a/keeper/images/screenshot1.png b/src/images/screenshot1.png similarity index 100% rename from keeper/images/screenshot1.png rename to src/images/screenshot1.png diff --git a/keeper/images/screenshot2.png b/src/images/screenshot2.png similarity index 100% rename from keeper/images/screenshot2.png rename to src/images/screenshot2.png diff --git a/keeper/images/screenshot3.png b/src/images/screenshot3.png similarity index 100% rename from keeper/images/screenshot3.png rename to src/images/screenshot3.png diff --git a/keeper/images/screenshot4.png b/src/images/screenshot4.png similarity index 100% rename from keeper/images/screenshot4.png rename to src/images/screenshot4.png diff --git a/keeper/images/screenshot5.png b/src/images/screenshot5.png similarity index 100% rename from keeper/images/screenshot5.png rename to src/images/screenshot5.png diff --git a/keeper/images/vault_screen1.png b/src/images/vault_screen1.png similarity index 100% rename from keeper/images/vault_screen1.png rename to src/images/vault_screen1.png diff --git a/keeper/keeper b/src/keeper similarity index 100% rename from keeper/keeper rename to src/keeper diff --git a/keeper/keeper.cmd b/src/keeper.cmd similarity index 100% rename from keeper/keeper.cmd rename to src/keeper.cmd diff --git a/src/keeper.py b/src/keeper.py new file mode 100755 index 000000000..e5cf8bf58 --- /dev/null +++ b/src/keeper.py @@ -0,0 +1,225 @@ +# _ __ +# | |/ /___ ___ _ __ ___ _ _ ® +# | ' ... search with regular expression') + print(' g ... get record details for uid') + print(' r ... rotate password for uid') + print(' b ... rotate password for matches of regular expression') + print(' a ... add a new record interactively') + print(' c ... clear the screen') + print(' h ... show command history') + print(' q ... quit') + print('') + + if params.command: + if params.command != 'h': + stack.append(params.command) + stack.reverse() + + return True + +# Parse command line options +# email, config, debug are optional +parser = argparse.ArgumentParser(usage='keeper [options]', + description='Keeper Commander') +parser.add_argument('--email', help='Email address for the account') +parser.add_argument('--config', help='Config file to use') +parser.add_argument('--debug', help='Turn on debug mode', action='store_true') + +args = parser.parse_args() + +if args.debug: + params.debug = args.debug +if args.email: + params.email = args.email +if args.config: + params.config_filename = args.config + +try: + with open(params.config_filename) as config_file: + + try: + params.config = json.load(config_file) + + if 'email' in params.config: + params.email = params.config['email'] + + if 'server' in params.config: + params.server = params.config['server'] + + if 'password' in params.config: + params.password = params.config['password'] + + if 'challenge' in params.config: + import yubikey.yubikey + challenge = params.config['challenge'] + params.password = yubikey.yubikey.get_response(challenge) + + if 'mfa_token' in params.config: + params.mfa_token = params.config['mfa_token'] + + if 'mfa_type' in params.config: + params.mfa_type = params.config['mfa_type'] + + if 'commands' in params.config: + params.commands = params.config['commands'] + + if 'plugins' in params.config: + params.plugins = params.config['plugins'] + + if 'debug' in params.config: + params.debug = params.config['debug'] + + except: + print('Error: Unable to parse JSON file ' + params.config_filename) + goodbye() + +except IOError: + pass + +try: + + if not params.server: + params.server = 'https://keeperapp.com/v2/' + + while not params.email: + params.email = getpass.getpass(prompt='Email: ', stream=None) + + # only prompt for password when no device token + while not params.password: + params.password = getpass.getpass(prompt='Password: ', stream=None) + + # if commands are provided, execute those then exit + if params.commands: + for c in params.commands: + params.command = c + print('Executing [' + params.command + ']...') + try: + if not do_command(params): + print('Command ' + params.command + ' failed.') + except CommunicationError as e: + print ("Communication Error:" + str(e.message)) + except AuthenticationError as e: + print ("AuthenticationError Error: " + str(e.message)) + except: + print('An unexpected error occurred: ' + str(sys.exc_info()[0])) + + params.command = '' + + goodbye() + + if params.debug: print('Params: ' + str(params)) + + # start with a sync download + if not params.command: + params.command = 'd' + + # go into interactive mode + while True: + if not params.command: + try: + params.command = input("Keeper > ") + except KeyboardInterrupt: + print('') + except EOFError: + raise KeyboardInterrupt + + try: + if not do_command(params): + raise KeyboardInterrupt + except CommunicationError as e: + print ("Communication Error:" + str(e.message)) + except AuthenticationError as e: + print ("AuthenticationError Error: " + str(e.message)) + except KeyboardInterrupt as e: + raise + except: + print('An unexpected error occurred: ' + str(sys.exc_info()[0])) + raise + + params.command = '' + +except KeyboardInterrupt: + goodbye() + diff --git a/keeper/params.py b/src/params.py similarity index 100% rename from keeper/params.py rename to src/params.py diff --git a/keeper/plugin_manager.py b/src/plugin_manager.py similarity index 98% rename from keeper/plugin_manager.py rename to src/plugin_manager.py index f4e151216..66528e4b9 100644 --- a/keeper/plugin_manager.py +++ b/src/plugin_manager.py @@ -9,6 +9,7 @@ # Contact: ops@keepersecurity.com # +import sys import importlib imported_plugins = {} diff --git a/keeper/plugins/.gitignore b/src/plugins/.gitignore similarity index 100% rename from keeper/plugins/.gitignore rename to src/plugins/.gitignore diff --git a/keeper/plugins/README.md b/src/plugins/README.md similarity index 100% rename from keeper/plugins/README.md rename to src/plugins/README.md diff --git a/keeper/plugins/adpasswd/README.md b/src/plugins/adpasswd/README.md similarity index 100% rename from keeper/plugins/adpasswd/README.md rename to src/plugins/adpasswd/README.md diff --git a/keeper/plugins/adpasswd/adpasswd.py b/src/plugins/adpasswd/adpasswd.py similarity index 100% rename from keeper/plugins/adpasswd/adpasswd.py rename to src/plugins/adpasswd/adpasswd.py diff --git a/keeper/plugins/mssql/README.md b/src/plugins/mssql/README.md similarity index 100% rename from keeper/plugins/mssql/README.md rename to src/plugins/mssql/README.md diff --git a/keeper/plugins/mssql/mssql.py b/src/plugins/mssql/mssql.py similarity index 100% rename from keeper/plugins/mssql/mssql.py rename to src/plugins/mssql/mssql.py diff --git a/keeper/plugins/mysql/README.md b/src/plugins/mysql/README.md similarity index 100% rename from keeper/plugins/mysql/README.md rename to src/plugins/mysql/README.md diff --git a/keeper/plugins/mysql/mysql.py b/src/plugins/mysql/mysql.py similarity index 100% rename from keeper/plugins/mysql/mysql.py rename to src/plugins/mysql/mysql.py diff --git a/keeper/plugins/oracle/README.md b/src/plugins/oracle/README.md similarity index 100% rename from keeper/plugins/oracle/README.md rename to src/plugins/oracle/README.md diff --git a/keeper/plugins/oracle/oracle.py b/src/plugins/oracle/oracle.py similarity index 100% rename from keeper/plugins/oracle/oracle.py rename to src/plugins/oracle/oracle.py diff --git a/keeper/plugins/postgresql/README.md b/src/plugins/postgresql/README.md similarity index 100% rename from keeper/plugins/postgresql/README.md rename to src/plugins/postgresql/README.md diff --git a/keeper/plugins/postgresql/postgresql.py b/src/plugins/postgresql/postgresql.py similarity index 100% rename from keeper/plugins/postgresql/postgresql.py rename to src/plugins/postgresql/postgresql.py diff --git a/keeper/plugins/ssh/README.md b/src/plugins/ssh/README.md similarity index 100% rename from keeper/plugins/ssh/README.md rename to src/plugins/ssh/README.md diff --git a/keeper/plugins/ssh/ssh.py b/src/plugins/ssh/ssh.py similarity index 100% rename from keeper/plugins/ssh/ssh.py rename to src/plugins/ssh/ssh.py diff --git a/keeper/plugins/unixpasswd/README.md b/src/plugins/unixpasswd/README.md similarity index 100% rename from keeper/plugins/unixpasswd/README.md rename to src/plugins/unixpasswd/README.md diff --git a/keeper/plugins/unixpasswd/unixpasswd.py b/src/plugins/unixpasswd/unixpasswd.py similarity index 100% rename from keeper/plugins/unixpasswd/unixpasswd.py rename to src/plugins/unixpasswd/unixpasswd.py diff --git a/keeper/plugins/windows/README.md b/src/plugins/windows/README.md similarity index 100% rename from keeper/plugins/windows/README.md rename to src/plugins/windows/README.md diff --git a/keeper/plugins/windows/windows.py b/src/plugins/windows/windows.py similarity index 100% rename from keeper/plugins/windows/windows.py rename to src/plugins/windows/windows.py diff --git a/keeper/record.py b/src/record.py similarity index 100% rename from keeper/record.py rename to src/record.py diff --git a/keeper/requirements.txt b/src/requirements.txt similarity index 100% rename from keeper/requirements.txt rename to src/requirements.txt diff --git a/keeper/yubikey/README.md b/src/yubikey/README.md similarity index 100% rename from keeper/yubikey/README.md rename to src/yubikey/README.md diff --git a/keeper/yubikey/images/screen1.png b/src/yubikey/images/screen1.png similarity index 100% rename from keeper/yubikey/images/screen1.png rename to src/yubikey/images/screen1.png diff --git a/keeper/yubikey/images/screen2.png b/src/yubikey/images/screen2.png similarity index 100% rename from keeper/yubikey/images/screen2.png rename to src/yubikey/images/screen2.png diff --git a/keeper/yubikey/images/screen3.png b/src/yubikey/images/screen3.png similarity index 100% rename from keeper/yubikey/images/screen3.png rename to src/yubikey/images/screen3.png diff --git a/keeper/yubikey/images/screen4.png b/src/yubikey/images/screen4.png similarity index 100% rename from keeper/yubikey/images/screen4.png rename to src/yubikey/images/screen4.png diff --git a/keeper/yubikey/images/screen5.png b/src/yubikey/images/screen5.png similarity index 100% rename from keeper/yubikey/images/screen5.png rename to src/yubikey/images/screen5.png diff --git a/keeper/yubikey/images/screen6.png b/src/yubikey/images/screen6.png similarity index 100% rename from keeper/yubikey/images/screen6.png rename to src/yubikey/images/screen6.png diff --git a/keeper/yubikey/images/screen7.png b/src/yubikey/images/screen7.png similarity index 100% rename from keeper/yubikey/images/screen7.png rename to src/yubikey/images/screen7.png diff --git a/keeper/yubikey/yubikey.py b/src/yubikey/yubikey.py similarity index 100% rename from keeper/yubikey/yubikey.py rename to src/yubikey/yubikey.py