mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Do base64-encoding of the SSH key before returning, not after.
Not all SSH key formats use base64 encoding, for example SSH1 keys looks different. So we can't blindly base64-encode the raw strings that we receive. Attempt to return keys in the same format as is used by the known_hosts file.
This commit is contained in:
@@ -228,7 +228,7 @@ fetch_host_key = function( host, port, key_type )
|
|||||||
stdnse.print_debug( "Unsupported key type: %s", key_type )
|
stdnse.print_debug( "Unsupported key type: %s", key_type )
|
||||||
end
|
end
|
||||||
|
|
||||||
return { key=public_host_key, key_type=key_type, fp_input=public_host_key, bits=bits,
|
return { key=base64.enc(public_host_key), key_type=key_type, fp_input=public_host_key, bits=bits,
|
||||||
full_key=('%s %s'):format(key_type,base64.enc(public_host_key)),
|
full_key=('%s %s'):format(key_type,base64.enc(public_host_key)),
|
||||||
algorithm=algorithm, fingerprint=openssl.md5(public_host_key) }
|
algorithm=algorithm, fingerprint=openssl.md5(public_host_key) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ local function portaction(host, port)
|
|||||||
fingerprint=stdnse.tohex(key.fingerprint),
|
fingerprint=stdnse.tohex(key.fingerprint),
|
||||||
type=key.key_type,
|
type=key.key_type,
|
||||||
bits=key.bits,
|
bits=key.bits,
|
||||||
key=base64.enc(key.key),
|
key=key.key,
|
||||||
})
|
})
|
||||||
if format:find( 'hex', 1, true ) or all_formats then
|
if format:find( 'hex', 1, true ) or all_formats then
|
||||||
table.insert( output, ssh1.fingerprint_hex( key.fingerprint, key.algorithm, key.bits ) )
|
table.insert( output, ssh1.fingerprint_hex( key.fingerprint, key.algorithm, key.bits ) )
|
||||||
|
|||||||
Reference in New Issue
Block a user