Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Written by Paulo @ http://github.com/raggesilver
- # To compile: shc -f file_name.sh -o output_name
- YELLOW='\033[1;33m'
- RED='\033[0;31m'
- GREEN='\033[0;32m'
- NC='\033[0m'
- showLogo() {
- clear
- figlet -c PimScript
- sleep 3
- clear
- }
- getParams() {
- while [ "$1" != "" ]; do
- case $1 in
- -t | --target ) shift
- echo -e "${YELLOW}Warning ping target manually overwritten to: \"$1\"${NC}"
- target=$1
- ;;
- *) echo "Unknown option $1."
- exit -1
- esac
- shift
- done
- }
- checkInternetConnection() {
- wget -q --tries=5 --timeout=20 --spider "$target"
- if [[ ! $? -eq 0 ]]; then
- echo -e "${RED}This script requires internet connection!${NC}"
- exit 1
- fi
- }
- checkDependencies() {
- status=`dpkg -s figlet`
- if [[ ! "$status" == *"Status: install ok installed"* ]]; then
- zenity --warning --title "Dependencies" --text "PimSript Login depends on figlet to work. Please install it."
- sudo -K
- # PASSWD="$(zenity --password --title=Authentication --text='Install figlet')\n"
- gksu "apt-get install -y figlet"
- if [[ ! $? -eq 0 ]]; then exit 1; fi
- fi
- }
- printCenter() {
- COLUMNS=$(tput cols)
- while [ "$1" != "" ]; do
- text=$1
- printf "%*s\n" $(((${#text}+$COLUMNS)/2)) "$text"
- shift
- done
- }
- register() {
- clear
- printCenter "*~.REGISTER.~*"
- echo -n "Username> "
- read username
- echo -n "Password> "
- read -s password
- echo ""
- echo -n "Confirm password> "
- read -s confpassword
- if [[ "$password" != "$confpassword" ]]; then echo -e "\n${RED}Passwords don't match.${NC}"; sleep 3; register; return; fi
- echo ""
- password=`echo $password | md5sum | awk '{print $1}'`
- echo `curl "localhost/shell_app/register.php?username=$username&password=$password" -s`
- doLogin
- }
- doLogin() {
- if [[ $# -le 0 ]]; then
- clear
- printCenter "*~.LOGIN.~*" "type register as username to register"
- fi
- echo -n "Username> "
- read username
- if [[ "$username" == "register" ]]; then register; return; fi
- echo -n "Password> "
- read -s password
- echo ""
- password=`echo $password | md5sum | awk '{print $1}'`
- response=$(curl "localhost/shell_app/index.php?username=$username&password=$password" -s)
- case $response in
- 0) echo -e "${GREEN}Logged in, welcome \e[1m\e[93m\e[5m$username\e[0m!${NC}";;
- 1) echo -e "\nPlease fill in all the fields\n"; doLogin "false";;
- 2) echo -e "\nIncorrect credentials\n"; doLogin "false";;
- *) echo "Unknown response from server. > $response"
- esac
- }
- params=$@
- target="http://google.com"
- getParams $getParams
- checkInternetConnection
- con=$?
- checkDependencies
- showLogo
- doLogin
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement