Evil|Clan HOME EVIL|ARCHIVE Evil|Clan
HOME EVIL|ARCHIVE PASTEBIN PRIVACY CONTACT

Pastebin

show all

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

TOTP-Script

  1. #!/bin/bash
  2. #Small bashscript to get a TAN from oathtool, copy TAN to clipboard and output a small window with TAN-lifetime
  3. #requirements: gxmessage, oathtool and xclip
  4. #apt-get install xclip oathtool gxmessage
  5. #(C) 2018 ThEPaniC/Evil|Pan!C -> mail (at) thepanic.eu
  6. #Version 1.0
  7. #Released under GPL v2 or later
  8. #http://www.gnu.org/licenses/gpl-2.0.html
  9. OLDTAN="5" #Time in Seconds to specify a old TAN, if you need more time to paste your TAN, higher this value
  10. SECRET="secret" #your base32 encoded secret
  11.  
  12. #Change OLDTAN and SECRET for your needs
  13.  
  14. function tanlifetime {
  15. DATE=`date +%S`
  16. if [ "$DATE" -le "30" ]
  17. then
  18. timeleft=$(( 30-$DATE ))
  19. elif  [ "$DATE" -le "60" ]
  20. then
  21. timeleft=$(( 60-$DATE ))
  22. fi
  23. }
  24. function gettan {
  25. TAN="`oathtool --base32 --totp $SECRET`" &&
  26. echo $TAN | xclip -selection clipboard
  27. }
  28. tanlifetime &&
  29. if [ "$timeleft" -le "$OLDTAN" ]
  30. then
  31. sleeptime=$(( $timeleft+1 ))
  32. gxmessage -geometry 350x100 -timeout $sleeptime -center -title "old TAN" "short TAN lifetime, wait $sleeptime seconds for a new TAN" &&
  33. tanlifetime &&
  34. gettan &&
  35. gxmessage -geometry 300x100 -timeout 3 -center -title "TAN in clipboard" "TAN lifetime: $timeleft seconds"
  36. else
  37. gettan &&
  38. gxmessage -geometry 300x100 -timeout 3 -center -title "TAN in clipboard" "TAN lifetime: $timeleft seconds"
  39. fi
  40. exit 0