Last active
January 20, 2021 17:51
-
-
Save dlenski/d6d4df40c8dd538339f750902d68bcfb to your computer and use it in GitHub Desktop.
Make a working RSA token from seed, expiration date, and serial number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Incorporated into
rsa_ct_kip
as of dlenski/rsa_ct_kip@fb0ba0a.