Adam  Števko avatar Adam Števko committed c67a97d

ssh-hostkey.nse and ssh2.lua should know about ECDSA

Comments (0)

Files changed (2)

     local n
     _, _, _, n = bin.unpack( ">aaa", public_host_key )
     bits = openssl.bignum_bin2bn( n ):num_bits()
+  elseif key_type == 'ecdsa-sha2-nistp256' then
+    algorithm = "ECDSA"
+    bits = "256"
+  elseif key_type == 'ecdsa-sha2-nistp384' then
+    algorithm = "ECDSA"
+    bits = "384"
+  elseif key_type == 'ecdsa-sha2-nistp521' then
+    algorithm = "ECDSA"
+    bits = "521"
   else
     stdnse.print_debug( "Unsupported key type: %s", key_type )
   end

scripts/ssh-hostkey.nse

   key = ssh2.fetch_host_key( host, port, "ssh-rsa" )
   if key then table.insert( keys, key ) end
 
+  key = ssh2.fetch_host_key( host, port, "ecdsa-sha2-nistp256" )
+  if key then table.insert( keys, key ) end
+
+  key = ssh2.fetch_host_key( host, port, "ecdsa-sha2-nistp384" )
+  if key then table.insert( keys, key ) end
+
+  key = ssh2.fetch_host_key( host, port, "ecdsa-sha2-nistp521" )
+  if key then table.insert( keys, key ) end
+
   for _, key in ipairs( keys ) do
     add_key_to_registry( host, key )
     if format:find( 'hex', 1, true ) or all_formats then
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.