Skip to content

Instantly share code, notes, and snippets.

@rafaelribeiroo
Last active April 23, 2020 17:12
Show Gist options
  • Save rafaelribeiroo/7a379960feb6ab255091b85bf000c210 to your computer and use it in GitHub Desktop.
Save rafaelribeiroo/7a379960feb6ab255091b85bf000c210 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
declare -A f=(
[askpass]=/lib/cryptsetup/askpass
)
declare -A c=(
[WHITE]='\033[1;37m'
[RED]='\033[31;1m'
[RED-BLINK]='\033[31;1;5m'
[GREEN]='\033[1;32m'
[YELLOW]='\033[1;33m'
[CYAN]='\033[1;36m'
[END]='\e[0m'
)
show() {
echo -e ${c[WHITE]}"${1}"${c[END]}
# Don't sleep if 2ø parameter contains 1
[[ "${2}" != "1" ]] && take_a_break
}
take_a_break() {
sleep 3s
}
l=(
'https://api.github.com/user/keys' # 0
)
for (( ; ; )); do
read -p $'\033[1;37m\nENTER YOUR USERNAME FROM GITHUB: \033[m' user
password=$("${f[askpass]}" $'\033[1;37mPASSWORD:\033[m')
check_integrity=$(curl --silent --include --user "${user}":"${password}" "${l[0]}" | grep Status | awk '{print $2}')
# Success messages are between 200 & 226 and error between 400 & 451
# [[ "${check_integrity}" -eq 401 || "${check_integrity}" -eq 403 ]]
[[ "${check_integrity}" -ge 400 ]] \
&& show "\n\t\t${c[WHITE]}TRY HARDER ${c[WHITE]}!!!" "1" \
|| break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment