Skip to content

Instantly share code, notes, and snippets.

Last active January 20, 2021 17:51
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Make a working RSA token from seed, expiration date, and serial number
# Takes SN, EXPIRATION, and SEED environment variables
# (SEED must be 32 hex digits) and converts them to
# an RSA SecurID token in CTF format.
# Requires:
# stoken >=v0.9
# perl5
# base64
# Show input parameters:
echo "Serial Number: $SN"
echo "Expiration (YYYY/MM/DD): $EXPIRATION"
echo "Seed (hex): $SEED"
# Convert seed to base64 and show it:
SEED_B64=$(echo -n "$SEED" |
perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' |
echo "Seed (base64): $SEED_B64"
# Use `stoken export --template` to mash it into a working .sdtid token:
echo "<TKNBatch><TKN><SN>$SN</SN><Death>$EXPIRATION</Death><Seed>=$SEED_B64</Seed></TKN></TKNBatch>" > $tf1
stoken export --random --sdtid --template $tf1 > $tf2
# Show it as RSA SecurID v2 CTF:
echo -n "Compressed token format (v2): "
stoken export --file $tf2
Copy link

dlenski commented Jan 30, 2020

Incorporated into rsa_ct_kip as of dlenski/rsa_ct_kip@fb0ba0a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment