def main(args=sys.argv[1:]): args = parse_args(args) if args.version: print(__version__) sys.exit(0) error, help_message = validate_args(args) if args.help: print_help(help_message, long=True) sys.exit(0) if error: print_help(help_message) sys.exit(0) profile, master_password = create_profile(args) if not master_password: master_password = getpass.getpass("Master Password: "******"Copied to clipboard") except Exception as e: print("Copy failed, we are sorry") print("Can you send us an email at [email protected]\n") print("-" * 80) print("Object: [LessPass][cli] Copy issue on %s" % platform.system()) print("Hello,") print("I got an issue with LessPass cli software.\n") traceback.print_exc() print("-" * 80) else: print(generated_password)
def main(args=sys.argv[1:]): args = parse_args(args) if args.clipboard and not get_system_copy_command(): print( "error: To use the option -c (--copy) you need pbcopy on OSX, " + "xsel, xclip, or wl-clipboard on Linux, and clip on Windows" ) sys.exit(3) if args.save_path: return save_password_profiles(args.config_home_path, args.url, args.save_path) if args.load_path: return load_password_profiles(args.config_home_path, args.url, args.load_path) if args.prompt: if not args.site: args.site = getpass.getpass("Site: ") if not args.login: args.login = getpass.getpass("Login: "******"error: argument SITE is required but was not provided.") sys.exit(4) if not args.master_password: prompt = "Master Password: "******"error: argument MASTER_PASSWORD is required but was not provided") sys.exit(5) profile, master_password = create_profile(args) try: generated_password = generate_password(profile, master_password) except exceptions.ExcludeAllCharsAvailable: print("error: you can't exclude all chars available") sys.exit(6) if args.clipboard: try: copy(generated_password) print("Copied to clipboard") except Exception: print("Copy failed, we are sorry") print("Can you send us an email at [email protected]\n") print("-" * 80) print("Object: [LessPass][cli] Copy issue on %s" % platform.system()) print("Hello,") print("I got an issue with LessPass cli software.\n") traceback.print_exc() print("-" * 80) else: print(generated_password)
def _login(config_home_path, url): os.makedirs(config_home_path, exist_ok=True) config_path = os.path.join(config_home_path, "config.json") tokens = None if os.path.exists(config_path): with open(config_path, encoding="utf-8") as f: tokens = json.load(f) if tokens: refresh_tokens = requests.post( f"{url}auth/jwt/refresh/", json=tokens, ) if refresh_tokens.status_code == 200: token_refreshed = refresh_tokens.json() with open(config_path, "w", encoding="utf-8") as f: json.dump(token_refreshed, f, ensure_ascii=False, indent=4) return token_refreshed["access"] print("LessPass login") email = input("Email: ") master_password = getpass.getpass("Master Password: "******"Email and Master Password are mandatory") sys.exit(1) default_lesspass_profile = { "site": "lesspass.com", "login": email, "lowercase": True, "uppercase": True, "digits": True, "symbols": True, "length": 16, "counter": 1, } encrypted_password = generate_password(default_lesspass_profile, master_password) r = requests.post( f"{url}auth/jwt/create/", json={ "email": email, "password": encrypted_password }, ) if r.status_code != 200: print("Wrong email and/or master password") sys.exit(1) tokens = r.json() with open(config_path, "w", encoding="utf-8") as f: json.dump(tokens, f, ensure_ascii=False, indent=4) print(f"Access and refresh tokens saved in {config_path}") return tokens["access"]
def test_generate_password_2(self): profile = { "site": "example.org", "login": "******", "lowercase": True, "uppercase": True, "digits": True, "symbols": False, "length": 14, "counter": 2, } master_password = "******" self.assertEqual(generate_password(profile, master_password), "MBAsB7b1Prt8Sl")
def test_generate_password(self): profile = { "site": "example.org", "login": "******", "lowercase": True, "uppercase": True, "digits": True, "symbols": True, "length": 16, "counter": 1, } master_password = "******" self.assertEqual(generate_password(profile, master_password), "WHLpUL)e00[iHR+w")
def test_generate_password_nrt_328(self): profile = { "site": "site", "login": "******", "lowercase": True, "uppercase": True, "digits": True, "symbols": True, "length": 16, "counter": 10, } master_password = "******" self.assertEqual(generate_password(profile, master_password), "XFt0F*,r619:+}[.")
def test_generate_password_4(self): profile = { "site": "example.org", "login": "******", "lowercase": True, "uppercase": True, "digits": False, "symbols": True, "length": 16, "counter": 1, } master_password = "******" self.assertEqual(generate_password(profile, master_password), "s>{F}RwkN/-fmM.X")
def test_generate_password_unicode(self): profile = { "site": "♥ LessPass ♥", "login": "******", "lowercase": True, "uppercase": True, "digits": True, "symbols": True, "length": 16, "counter": 1, } master_password = "******" self.assertEqual(generate_password(profile, master_password), "BH$>U5Lj7v9A1wB/")
def main(args=sys.argv[1:]): args = parse_args(args) if args.clipboard and not get_system_copy_command(): print("ERROR To use the option -c (--copy) you need pbcopy " + "on OSX, xsel or xclip on Linux, and clip on Windows") sys.exit(3) if args.prompt: args.site = getpass.getpass("Site: ") args.login = getpass.getpass("Login: "******"ERROR argument SITE is required but was not provided.") sys.exit(4) if not args.master_password: args.master_password = getpass.getpass("Master Password: "******"ERROR argument MASTER_PASSWORD is required but was not provided") sys.exit(5) profile, master_password = create_profile(args) generated_password = generate_password(profile, master_password) if args.clipboard: try: copy(generated_password) print("Copied to clipboard") except Exception as e: print("Copy failed, we are sorry") print("Can you send us an email at [email protected]\n") print("-" * 80) print("Object: [LessPass][cli] Copy issue on %s" % platform.system()) print("Hello,") print("I got an issue with LessPass cli software.\n") traceback.print_exc() print("-" * 80) else: print(generated_password)
def main(args=sys.argv[1:]): args = parse_args(args) if args.clipboard and not get_system_copy_command(): print( "ERROR To use the option -c (--copy) you need pbcopy " + "on OSX, xsel or xclip on Linux, and clip on Windows" ) sys.exit(3) if args.prompt_all: args.site = getpass.getpass("Site: ") args.login = getpass.getpass("Login: "******"Counter: ") if counter.isdigit(): args.counter = int(counter) else: print("ERROR argument COUNTER must be an integer.") sys.exit(4) length = getpass.getpass("Length [5-35]: ") try: length = int(length) if length >= 5 and length <= 35: args.length = length else: raise except: print("ERROR argument LENGTH must be an integer in range [5-35].") sys.exit(4) args.nl = True if getpass.getpass("Lowercase (Y/n): ") == 'n' else False args.nu = True if getpass.getpass("Uppercase (Y/n): ") == 'n' else False args.nd = True if getpass.getpass("Digits (Y/n): ") == 'n' else False args.ns = True if getpass.getpass("Symbols (Y/n): ") == 'n' else False elif args.prompt: args.site = getpass.getpass("Site: ") args.login = getpass.getpass("Login: "******"ERROR argument SITE is required but was not provided.") sys.exit(4) if not args.master_password: args.master_password = getpass.getpass("Master Password: "******"ERROR argument MASTER_PASSWORD is required but was not provided") sys.exit(5) profile, master_password = create_profile(args) generated_password = generate_password(profile, master_password) if args.clipboard: try: copy(generated_password) print("Copied to clipboard") except Exception as e: print("Copy failed, we are sorry") print("Can you send us an email at [email protected]\n") print("-" * 80) print("Object: [LessPass][cli] Copy issue on %s" % platform.system()) print("Hello,") print("I got an issue with LessPass cli software.\n") traceback.print_exc() print("-" * 80) else: print(generated_password)