Created
February 8, 2017 14:33
-
-
Save gwire/0952739eb9a872ec2df9185a0de738dc to your computer and use it in GitHub Desktop.
takes an SSHFP record and converts to tinydns format
This file contains 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
#!/usr/bin/env python | |
# tinysshfp - takes the output of "ssh-keygen -r" and converts into tinydns | |
# | |
# example: ssh-keygen -r example.com | ./tinysshfp.py | |
# | |
# 2017 Lee Maguire | |
import getopt | |
import sys | |
import re | |
ttl = "" | |
def tinySshfpRecord( hostname, algid, fptype, fp, ttl ): | |
fpout = "" | |
for c in range(0, len(fp), 2): | |
fpout = fpout + "\\{0:03o}".format(int("0x"+fp[c]+fp[c+1],16)) | |
return(":" + hostname + ":44:" + "\\{0:03o}".format(int(algid)) + "\\{0:03o}".format(int(fptype)) + fpout + ":" + ttl); | |
opts, args = getopt.getopt(sys.argv[1:],"ht:",["ttl="]) | |
for opt, arg in opts: | |
if opt == '-h': | |
print 'Usage: tinysshfp.py -t 60' | |
sys.exit() | |
elif opt in ("-t", "--ttl"): | |
ttl = arg | |
for input_text in sys.stdin: | |
hostname,xin,xsshfp,algid,fptype,fp = input_text.rstrip().split(" ") | |
line = tinySshfpRecord( hostname, algid, fptype, fp, ttl ) | |
sys.stdout.write( line + "\n") | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment