Advertisement
constantin-net

fsudo

Aug 15th, 2022
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.79 KB | None | 0 0
  1. #!/bin/bash
  2. [ -z "$1" ] && echo -e "USAGE:\n\t-e\n\t-c" && exit 0
  3. if [ "$(id -u)" != "1000" ]; then
  4.    echo "This script must be run as user"
  5.    exit 1
  6. fi
  7. secret="$HOME/.secret_vault"
  8. secret_p="$HOME/.secret_passphrase"
  9.  
  10. if [ "$1" == "-e" ]; then
  11.     touch $secret
  12.     #touch $secret_p
  13.     echo "Enter password:"
  14.     read -r -s pw
  15.     echo "Enter passphrase:"
  16.     read -r -s pp
  17.     echo "$pw" | openssl enc -aes-256-cbc -md sha512 -a -pbkdf2 -iter 100000 -salt -pass pass:"$pp" > "$secret"
  18.     chmod 600 $secret
  19.     echo "$pp" > $secret_p
  20.     chmod 600 $secret_p
  21.     exit
  22. fi
  23. if [ "$1" == "-c" ]; then
  24.    #echo "Enter passphrase:"
  25.    #read -r -s passphrase
  26.    cat "$secret" | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:`cat "$secret_p"`
  27. fi
  28. exit 0
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement