Created
January 1, 2016 05:29
-
-
Save rkrishnasanka/121fc6e48ed203cca1d7 to your computer and use it in GitHub Desktop.
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
import sys | |
import base64 | |
import struct | |
key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAADQ1IiOUdFSuqJ2l0fhs= root@kali' | |
# get the second field from the public key file. | |
keydata = base64.b64decode( | |
key.split(None)[1]) | |
parts = [] | |
while keydata: | |
# read the length of the data | |
dlen = struct.unpack('>I', keydata[:4])[0] | |
# read in <length> bytes | |
data, keydata = keydata[4:dlen+4], keydata[4+dlen:] | |
parts.append(data) | |
e_val = eval('0x' + ''.join(['%02X' % struct.unpack('B', x)[0] for x in parts[1]])) | |
n_val = eval('0x' + ''.join(['%02X' % struct.unpack('B', x)[0] for x in parts[2]])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment