metalx1000

password manager

May 31st, 2022 (edited)
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.72 KB | None | 0 0
  1. #!/bin/bash
  2. ######################################################################
  3. #Copyright (C) 2022  Kris Occhipinti
  4. #https://filmsbykris.com
  5.  
  6. #This program is free software: you can redistribute it and/or modify
  7. #it under the terms of the GNU General Public License as published by
  8. #the Free Software Foundation, either version 3 of the License, or
  9. #(at your option) any later version.
  10.  
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #GNU General Public License for more details.
  15.  
  16. #You should have received a copy of the GNU General Public License
  17. #along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. ######################################################################
  19.  
  20. [[ $(which xclip) ]] && clipboard="xclip"
  21. [[ $(which termux-clipboard-set) ]] && clipboard="termux-clipboard-set"
  22. timeout=30
  23.  
  24. dir="$HOME/.fbk/pass"
  25. mkdir -p "$dir"
  26.  
  27. function new_site(){
  28.   read -p "Enter Site Name: " site
  29.   password="$(date +%s | sha256sum | base64 | head -c 10)$(date +%d)!"
  30.   echo "Password: ${password}"
  31.   echo "${password}"| openssl aes-256-cbc -salt -pbkdf2 -out "${dir}/${site}.aes"
  32.   option="${site}.aes|${password}"
  33. }
  34.  
  35. function get_password(){
  36.   site="$(echo "$option"|cut -d\| -f1)"
  37.   enc_pass="$(echo "$option"|cut -d\| -f2)"
  38.   openssl aes-256-cbc -d -salt -pbkdf2 -in "${dir}/${site}"|$clipboard
  39.   echo "Password Copied to Clipboard."
  40.   wipe &
  41. }
  42.  
  43. function wipe(){
  44.   sleep $timeout
  45.   echo ""|$clipboard;
  46. }
  47.  
  48. option="$((echo "NEW SITE";ls "${dir}")|fzf)"
  49.  
  50. [[ "$option" == "" ]] && exit 1
  51. [[ "$option" == "NEW SITE" ]] && new_site
  52.  
  53. get_password
  54.  
Add Comment
Please, Sign In to add comment