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 20:16:06 | show line numbers

TOTP-Script v1.1

#!/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.1
#Released under GPL v2 or later
#http://www.gnu.org/licenses/gpl-2.0.html

secret="secret here" #your base32 encoded secret
oldtan="5" #Time in Seconds to specify a old TAN, set this value higher if you need more time to paste your TAN
windowname="TOTP-Script"
windowsize="350x100"
windowtimeout="5"
windowoparam="-borderless -wrap"


#tanlifetime only supports the default 30 seconds lifetime
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 $windowsize $windowoparam -timeout $sleeptime -center -title $windowname "short TAN lifetime please wait $sleeptime seconds for a new TAN" &
sleep $sleeptime
tanlifetime &&
gettan &&
gxmessage -geometry $windowsize $windowoparam -timeout $windowtimeout -center -title $windowname "TAN in clipboard lifetime: $timeleft seconds"
else
gettan &&
gxmessage -geometry $windowsize $windowoparam -timeout $windowtimeout -center -title $windowname "TAN in clipboard lifetime: $timeleft seconds"
fi
exit 0