def encrypt_list(pwd_list, file): for i in range(40): salt = crypt.mksalt(crypt.METHOD_SHA512) hash = crypt.crypt(pwd_list[i], salt) file.write('user' + str(i + 1) + ":" + str(hash) + ":" + str((16840 + i)) + ":0:99999:7:::" + "\n")
def read_in_username(): username = input('Your username: '******'a+') as fd: fd.write(username + ":") fd.write(pcrypt.crypt(password, salt='a5') + "\n") print("\nEntropy is: " + str(entropy))
def main(): # pragma: no cover """Command line interface""" cliargs = argparse.ArgumentParser() cliargs.add_argument("--splunk-secret", required=False, type=six.ensure_binary) cliargs.add_argument("--splunk-secret-text", required=False, type=six.ensure_binary) cliargs.add_argument("-D", "--decrypt", action="store_const", dest="mode", const="decrypt") cliargs.add_argument("-H", "--hash-passwd", action="store_const", dest="mode", const="hash") cliargs.add_argument("--new", action="store_const", dest="mode", const="encrypt_new") cliargs.add_argument("--nosalt", action="store_true", dest="nosalt") cliargs.add_argument("--password") args = cliargs.parse_args() if args.splunk_secret: with open(args.splunk_secret, "rb") as splunk_secret_file: key = splunk_secret_file.read().strip() elif args.splunk_secret_text: key = args.splunk_secret_text.strip() elif args.mode != "hash": raise argparse.ArgumentTypeError( "--splunk-secret or --splunk-secret-text must be defined") try: if args.mode == "decrypt": ciphertext = args.password or six.moves.input( "Encrypted password: "******"hash": ciphertext = args.password or getpass.getpass("Password: "******"Plaintext password: "******"encrypt_new": output = encrypt_new(key, plaintext) else: output = encrypt(key, plaintext, args.nosalt) except KeyboardInterrupt: pass else: print(output)
def brute_force(): start = time.time() with open("password.txt", 'r') as fd: sep = ':' line = fd.read().splitlines() for x in line: line = str(line).split(":", 1)[-1] for i in itertools.product(string.printable, repeat=3): password = ''.join(i) print(password) i = pcrypt.crypt(password, salt='a5') print(line) print(i) if i + "']" == line: print("Found your password: "******"%s seconds taken" % (time.time() - start)) time.sleep(30) else: print("Could not find your password.")
import pcrypt import getpass # get password from user input in hidden mode using getpass module pass_word = getpass.getpass("Enter your password : "******"*********************************your password is encrypted*******************************" ) print("\n") print(encrypted_password)
def hash_password(hash_id, salt, password): return crypt(password, '${}${}'.format(hash_id, salt))