Class: Msf::WindowsVersion
- Inherits:
-
Object
- Object
- Msf::WindowsVersion
- Defined in:
- lib/msf/core/windows_version.rb
Overview
Represents the version of a Windows operating system
Defined Under Namespace
Modules: MajorRelease
Constant Summary collapse
- VER_NT_WORKSTATION =
1
- VER_NT_DOMAIN_CONTROLLER =
2
- VER_NT_SERVER =
3
- Win2000 =
Rex::Version.new('5.0.2195')
- XP_SP0 =
Rex::Version.new('5.1.2600.0')
- XP_SP1 =
Rex::Version.new('5.1.2600.1')
- XP_SP2 =
Rex::Version.new('5.1.2600.2')
- XP_SP3 =
Rex::Version.new('5.1.2600.3')
- Server2003_SP0 =
Rex::Version.new('5.2.3790.0')
- Server2003_SP1 =
Rex::Version.new('5.2.3790.1')
- Server2003_SP2 =
Rex::Version.new('5.2.3790.2')
- Vista_SP0 =
Server2008_SP0 = Rex::Version.new('6.0.6000.0')
- Vista_SP1 =
Server2008_SP1 = Rex::Version.new('6.0.6001.1')
- Vista_SP2 =
Server2008_SP2 = Rex::Version.new('6.0.6002.2')
- Server2008_SP2_Update =
Rex::Version.new('6.0.6003.2')
- Win7_SP0 =
Server2008_R2_SP0 = Rex::Version.new('6.1.7600.0')
- Win7_SP1 =
Server2008_R2_SP1 = Rex::Version.new('6.1.7601.1')
- Win8 =
Server2012 = Rex::Version.new('6.2.9200.0')
- Win81 =
Server2012_R2 = Rex::Version.new('6.3.9600.0')
- Win10_1507 =
Win10_InitialRelease = Rex::Version.new('10.0.10240.0')
- Win10_1511 =
Rex::Version.new('10.0.10586.0')
- Win10_1607 =
Server2016 = Rex::Version.new('10.0.14393.0')
- Win10_1703 =
Rex::Version.new('10.0.15063.0')
- Win10_1709 =
Rex::Version.new('10.0.16299.0')
- Win10_1803 =
Rex::Version.new('10.0.17134.0')
- Win10_1809 =
Server2019 = Rex::Version.new('10.0.17763.0')
- Win10_1903 =
Rex::Version.new('10.0.18362.0')
- Win10_1909 =
Rex::Version.new('10.0.18363.0')
- Win10_2004 =
Rex::Version.new('10.0.19041.0')
- Win10_20H2 =
Rex::Version.new('10.0.19042.0')
- Win10_21H1 =
Rex::Version.new('10.0.19043.0')
- Win10_21H2 =
Rex::Version.new('10.0.19044.0')
- Win10_22H2 =
Rex::Version.new('10.0.19045.0')
- Server2022 =
Rex::Version.new('10.0.20348.0')
- Win11_21H2 =
Rex::Version.new('10.0.22000.0')
- Win11_22H2 =
Rex::Version.new('10.0.22621.0')
Instance Method Summary collapse
-
#build_number ⇒ Object
The specific build number of this version (major.minor.build.service_pack).
-
#domain_controller? ⇒ Boolean
This Windows Server has been promoted to a DC.
-
#initialize(major, minor, build, service_pack, revision, product_type) ⇒ WindowsVersion
constructor
A new instance of WindowsVersion.
-
#product_name ⇒ Object
The name of the OS, as it is most commonly rendered.
-
#revision_number ⇒ Object
The specific revision number of this version This is mainly going to be present on Windows 10+, wherein it’s easy to get it from the registry.
- #to_s ⇒ Object
-
#vista_or_2008? ⇒ Boolean
Is this version number from the Vista/Server 2008 generation of Windows OSes.
-
#win7_or_2008r2? ⇒ Boolean
Is this version number from the Windows 7/Server 2008 R2 generation of Windows OSes.
-
#windows_server? ⇒ Boolean
Is this OS a Windows Server instance?.
-
#workstation? ⇒ Boolean
Is this a Workstation build?.
-
#xp_or_2003? ⇒ Boolean
Is this version number from the XP/Server 2003 generation of Windows OSes.
Constructor Details
#initialize(major, minor, build, service_pack, revision, product_type) ⇒ WindowsVersion
Returns a new instance of WindowsVersion.
73 74 75 76 77 78 79 80 |
# File 'lib/msf/core/windows_version.rb', line 73 def initialize(major, minor, build, service_pack, revision, product_type) self._major = major self._minor = minor self._build = build self._service_pack = service_pack self._revision = revision self.product_type = product_type end |
Instance Method Details
#build_number ⇒ Object
The specific build number of this version (major.minor.build.service_pack)
89 90 91 |
# File 'lib/msf/core/windows_version.rb', line 89 def build_number Rex::Version.new("#{_major}.#{_minor}.#{_build}.#{_service_pack}") end |
#domain_controller? ⇒ Boolean
This Windows Server has been promoted to a DC
107 108 109 |
# File 'lib/msf/core/windows_version.rb', line 107 def domain_controller? product_type == VER_NT_DOMAIN_CONTROLLER end |
#product_name ⇒ Object
The name of the OS, as it is most commonly rendered. Includes Service Pack if present, or build number if Win10 or higher.
112 113 114 115 116 117 118 119 120 |
# File 'lib/msf/core/windows_version.rb', line 112 def product_name result = "Unknown Windows version: #{_major}.#{_minor}.#{_build}" name = major_release_name result = name unless name.nil? result = "#{result} Service Pack #{_service_pack}" if _service_pack != 0 result = "#{result} Build #{_build}" if build_number >= Win10_InitialRelease result end |
#revision_number ⇒ Object
The specific revision number of this version This is mainly going to be present on Windows 10+, wherein it’s easy to get it from the registry.
84 85 86 |
# File 'lib/msf/core/windows_version.rb', line 84 def revision_number _revision end |
#to_s ⇒ Object
122 123 124 |
# File 'lib/msf/core/windows_version.rb', line 122 def to_s product_name end |
#vista_or_2008? ⇒ Boolean
Is this version number from the Vista/Server 2008 generation of Windows OSes
127 128 129 |
# File 'lib/msf/core/windows_version.rb', line 127 def vista_or_2008? build_number.between?(Vista_SP0, Vista_SP2) end |
#win7_or_2008r2? ⇒ Boolean
Is this version number from the Windows 7/Server 2008 R2 generation of Windows OSes
132 133 134 |
# File 'lib/msf/core/windows_version.rb', line 132 def win7_or_2008r2? build_number.between?(Win7_SP0, Win7_SP1) end |
#windows_server? ⇒ Boolean
Is this OS a Windows Server instance?
94 95 96 97 98 99 |
# File 'lib/msf/core/windows_version.rb', line 94 def windows_server? # There are other types than just workstation/server/DC, but Microsoft's own documentation says # "If it's not Workstation, then it's Server" # https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa product_type != VER_NT_WORKSTATION end |
#workstation? ⇒ Boolean
Is this a Workstation build?
102 103 104 |
# File 'lib/msf/core/windows_version.rb', line 102 def workstation? product_type == VER_NT_WORKSTATION end |
#xp_or_2003? ⇒ Boolean
Is this version number from the XP/Server 2003 generation of Windows OSes
137 138 139 |
# File 'lib/msf/core/windows_version.rb', line 137 def xp_or_2003? build_number.between?(XP_SP0, Server2003_SP2) end |