2
|
1 #!/usr/bin/env python3 |
|
2 |
|
3 """ takes a pubkey, turns it into fuzzer-verify input """ |
|
4 |
|
5 import sys |
|
6 import struct |
|
7 import re |
|
8 import binascii |
|
9 |
|
10 BLOB_RE=re.compile(r'(?:ssh-rsa|ecdsa-\S+|ssh-dss) ([a-zA-Z0-9/+=]+)') |
|
11 |
|
12 inp = sys.stdin.read() |
|
13 b64blob = BLOB_RE.search(inp).groups(1)[0] |
|
14 |
|
15 blob = binascii.a2b_base64(b64blob) |
|
16 |
|
17 sigtypelen = struct.unpack('>I', blob[:4])[0] |
|
18 sigtype = blob[4:4+sigtypelen] |
|
19 print("Type is %s" % sigtype, file=sys.stderr) |
|
20 |
|
21 # a bodgy key followed by signature |
|
22 # eg rfc4253 |
|
23 # string "ssh-rsa" |
|
24 # string rsa_signature_blob |
|
25 sys.stdout.buffer.write(blob) |
|
26 sys.stdout.buffer.write(struct.pack('>I', sigtypelen)) |
|
27 sys.stdout.buffer.write(sigtype) |
|
28 sys.stdout.buffer.write(struct.pack('>II', 4, 20)) |
|
29 |