class SSHScan::OS::Ubuntu

Constants

FINGERPRINTS

Obtained from scraping ChangeLog on Launchpad

Attributes

version[R]

Public Class Methods

new(banner) click to toggle source
# File lib/ssh_scan/os/ubuntu.rb, line 211
def initialize(banner)
  @banner = banner
  @version = Ubuntu::Version.new(ubuntu_version_guess)
end

Public Instance Methods

common() click to toggle source
# File lib/ssh_scan/os/ubuntu.rb, line 216
def common
  "ubuntu"
end
cpe() click to toggle source
# File lib/ssh_scan/os/ubuntu.rb, line 251
def cpe
  "o:canonical:ubuntu" + (@version.to_s ? ":#{@version}" : "")
end
fingerprints() click to toggle source

Get the FINGERPRINTS constant hash, generated from the scraping script. @return [Hash<String, Array<String>>] FINGERPRINTS constant

hash
# File lib/ssh_scan/os/ubuntu.rb, line 224
def fingerprints
  OS::Ubuntu::FINGERPRINTS
end
ubuntu_version_guess() click to toggle source
# File lib/ssh_scan/os/ubuntu.rb, line 228
def ubuntu_version_guess
  possible_versions = []
  OS::Ubuntu::FINGERPRINTS.keys.each do |ubuntu_version|
    OS::Ubuntu::FINGERPRINTS[ubuntu_version].uniq.each do |banner|
      openssh_ps, ubuntu_sig = banner.split("-")
      openssh_version = openssh_ps
      # If the version is like 6.6p1, deduce that
      if openssh_ps.include?("p")
        openssh_version = openssh_ps.split("p")[0]
      end
      if @banner.include?("OpenSSH_#{openssh_version}") &&
         @banner.include?(ubuntu_sig)
        possible_versions << ubuntu_version
      end
    end
  end
  possible_versions.uniq!
  if possible_versions.any?
    return possible_versions.join("|")
  end
  return nil
end