Evil|Clan HOME SERVERLIST OA-CONNECT EVIL|ARCHIVE Evil|Clan
HOME SERVERLIST OA-CONNECT EVIL|ARCHIVE PASTEBIN PRIVACY CONTACT

Pastebin

show all

PaniC posted at 2018-04-09 13:59:32 | show line numbers

TOTP-Script

#!/bin/bash
#Small bashscript to get a TAN from oathtool, copy TAN to clipboard and output a small window with TAN-lifetime
#requirements: gxmessage, oathtool and xclip
#apt-get install xclip oathtool gxmessage
#(C) 2018 ThEPaniC/Evil|Pan!C -> mail (at) thepanic.eu
#Version 1.0
#Released under GPL v2 or later
#http://www.gnu.org/licenses/gpl-2.0.html
OLDTAN="5" #Time in Seconds to specify a old TAN, if you need more time to paste your TAN, higher this value
SECRET="secret" #your base32 encoded secret

#Change OLDTAN and SECRET for your needs

function tanlifetime {
DATE=`date +%S`
if [ "$DATE" -le "30" ]
then
timeleft=$(( 30-$DATE ))
elif  [ "$DATE" -le "60" ]
then
timeleft=$(( 60-$DATE ))
fi
}
function gettan {
TAN="`oathtool --base32 --totp $SECRET`" &&
echo $TAN | xclip -selection clipboard
}
tanlifetime &&
if [ "$timeleft" -le "$OLDTAN" ]
then
sleeptime=$(( $timeleft+1 ))
gxmessage -geometry 350x100 -timeout $sleeptime -center -title "old TAN" "short TAN lifetime, wait $sleeptime seconds for a new TAN" &&
tanlifetime &&
gettan &&
gxmessage -geometry 300x100 -timeout 3 -center -title "TAN in clipboard" "TAN lifetime: $timeleft seconds"
else
gettan &&
gxmessage -geometry 300x100 -timeout 3 -center -title "TAN in clipboard" "TAN lifetime: $timeleft seconds"
fi
exit 0