Skip to content

Instantly share code, notes, and snippets.

@dlenski

dlenski/make_RSA_token.sh

Last active Jan 30, 2020
Embed
What would you like to do?
Make a working RSA token from seed, expiration date, and serial number
#!/bin/bash
# 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' |
base64)
echo "Seed (base64): $SEED_B64"
# Use `stoken export --template` to mash it into a working .sdtid token:
tf1=$(mktemp)
echo "<TKNBatch><TKN><SN>$SN</SN><Death>$EXPIRATION</Death><Seed>=$SEED_B64</Seed></TKN></TKNBatch>" > $tf1
tf2=$(mktemp)
stoken export --random --sdtid --template $tf1 > $tf2
# Show it as RSA SecurID v2 CTF:
echo -n "Compressed token format (v2): "
stoken export --file $tf2
@dlenski

This comment has been minimized.

Copy link
Owner Author

@dlenski 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
You can’t perform that action at this time.