如何使用WFH搜索Windows可执行程序中的常见漏洞或功能

关于WFH

WFH,全名为Windows Feature Hunter,即Windows功能搜索工具,该工具基于Python开发,使用Frida实现其功能,可以帮助广大研究人员搜索和识别Windows可执行程序中的常见安全漏洞以及功能。当前版本的WFH能够自动识别动态链接库DLL中潜在的侧加载问题以及组件对象模型COM中劫持攻击的实现可能。

DLL侧加载利用勒Windows中WinSXS程序集来从SXS列表中加载恶意DLL文件。COM劫持将允许攻击者置入恶意代码,而这些代码将能够通过劫持COM引用和关系代替合法软件的执行。

WFH可以输出潜在的安全漏洞,并将目标Windows可执行文件中的潜在漏洞相关信息写入至CSV文件中。

工具安装

首先, 广大研究人员需要使用下列命令将该项目源码克隆至本地:

  1. git clone https://github.com/ConsciousHacker/WFH 

然后运行下列命令安装和配置相关依赖组件:

  1. pip install -r requirements.txt 

工具帮助信息

  1. PS C:\Tools\WFH > python .\wfh.py -h 
  2.  
  3. usage: wfh.py [-h] -t T [T ...] -m {dll,com} [-v] [-timeout TIMEOUT] 
  4.  
  5.   
  6.  
  7. Windows Feature Hunter 
  8.  
  9.   
  10.  
  11. optional arguments: 
  12.  
  13.   -h, --help            show this help message and exit 
  14.  
  15.   -t T [T ...], -targets T [T ...] 
  16.  
  17.                         list of target windows executables 
  18.  
  19.   -m {dll,com}, -mode {dll,com} 
  20.  
  21.                         vulnerabilities to potentially identify 
  22.  
  23.   -v, -verbose          verbose output from Frida instrumentation 
  24.  
  25.   -timeout TIMEOUT      timeout value for Frida instrumentation 
  26.  
  27.   
  28.  
  29. EXAMPLE USAGE 
  30.  
  31.     NOTE: It is recommended to copy target binaries to the same directory as wfh for identifying DLL Sideloading 
  32.  
  33.   
  34.  
  35.     DLL Sideloading Identification (Single):        python wfh.py -t .\mspaint.exe -m dll 
  36.  
  37.     DLL Sideloading Identification (Verbose):       python wfh.py -t .\mspaint.exe -m dll -v 
  38.  
  39.     DLL Sideloading Identification (Timeout 30s):   python wfh.py -t .\mspaint.exe -m dll -timeout 30 
  40.  
  41.     DLL Sideloading Identification (Wildcard):      python wfh.py -t * -m dll 
  42.  
  43.     DLL Sideloading Identification (List):          python wfh.py -t .\mspaint.exe .\charmap.exe -m dll 
  44.  
  45.   
  46.  
  47.     COM Hijacking Identification (Single):          python wfh.py -t "C:\Program Files\Internet Explorer\iexplore.exe" -m com 
  48.  
  49.     COM Hijacking Identification (Verbose):         python wfh.py -t "C:\Program Files\Internet Explorer\iexplore.exe" -m com -v 
  50.  
  51.     COM Hijacking Identification (Timeout 60s):     python wfh.py -t "C:\Program Files\Internet Explorer\iexplore.exe" -m com -timeout 60 
  52.  
  53.     COM Hijacking Identification (Wildcard):        python wfh.py -t * -m com -v 
  54.  
  55. COM Hijacking Identification (List):            python wfh.py -t "C:\Program Files\Internet Explorer\iexplore.exe" "C:\Windows\System32\notepad.exe" -m com -v 

工具使用

(1) DLL侧加载识别

首先,我们需要将需要分析的代码拷贝至WFH工具所在的目录下,然后按照下列命令执行扫描分析:

  1. PS C:\Tools\WFH > copy C:\Windows\System32\mspaint.exe . 
  2.  
  3. PS C:\Tools\WFH > copy C:\Windows\System32\charmap.exe . 
  4.  
  5. PS C:\Tools\WFH > dir 
  6.  
  7.   
  8.  
  9.   
  10.  
  11.     Directory: C:\Tools\WFH 
  12.  
  13.   
  14.  
  15.   
  16.  
  17. Mode                 LastWriteTime         Length Name 
  18.  
  19. ----                 -------------         ------ ---- 
  20.  
  21. d-----         5/14/2021   2:12 PM                .vscode 
  22.  
  23. -a----          5/6/2021   2:39 PM           1928 .gitignore 
  24.  
  25. -a----         12/7/2019   2:09 AM         198656 charmap.exe 
  26.  
  27. -a----         5/18/2021   7:39 AM           6603 loadlibrary.js 
  28.  
  29. -a----          4/7/2021  12:48 PM         988160 mspaint.exe 
  30.  
  31. -a----         5/18/2021   7:53 AM           8705 README.md 
  32.  
  33. -a----         5/17/2021  11:27 AM           5948 registry.js 
  34.  
  35. -a----          5/6/2021   2:41 PM             11 requirements.txt 
  36.  
  37. -a----         5/18/2021   8:35 AM          10623 wfh.py 

接下来,我们就可以使用WFH来对目标代码进行分析,并尝试识别其中的DLL侧加载机会:

  1. PS C:\Tools\WFH > python .\wfh.py -t * -m dll 
  2.  
  3. ================================================== 
  4.  
  5. Running Frida against charmap.exe 
  6.  
  7. -------------------------------------------------- 
  8.  
  9.         [+] Potential DllMain Sideloading: LoadLibraryW,LPCWSTR: MSFTEDIT.DLL 
  10.  
  11.         [+] Potential DllMain Sideloading: LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE 
  12.  
  13.   
  14.  
  15. [*] Writing raw Frida instrumentation to charmap.exe-raw.log 
  16.  
  17. [*] Writing Potential DLL Sideloading to charmap.exe-sideload.log 
  18.  
  19. -------------------------------------------------- 
  20.  
  21. ================================================== 
  22.  
  23. Running Frida against mspaint.exe 
  24.  
  25. -------------------------------------------------- 
  26.  
  27.         [+] Potential DllMain Sideloading: LoadLibraryExW,LPCWSTR : gdiplus.dll, dwFlags : NONE 
  28.  
  29.         [-] Potential DllExport Sideloading: GetProcAddress,hModule : C:\WINDOWS\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.789_none_faf0a7e97612e7bb\gdiplus.dll, LPCSTR: GdiplusStartup 
  30.  
  31.         [+] Potential DllMain Sideloading: LoadLibraryW,LPCWSTR: MSFTEDIT.DLL 
  32.  
  33.         [+] Potential DllMain Sideloading: LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE 
  34.  
  35.   
  36.  
  37. [*] Writing raw Frida instrumentation to mspaint.exe-raw.log 
  38.  
  39. [*] Writing Potential DLL Sideloading to mspaint.exe-sideload.log 
  40.  
  41. -------------------------------------------------- 
  42.  
  43. ================================================== 
  44.  
  45. [*] Writing dll results to dll_results.csv 
  46.  
  47.   
  48.  
  49. PS C:\Tools\WFH > type .\dll_results.csv 
  50.  
  51. Executable,WinAPI,DLL,EntryPoint / WinAPI Args 
  52.  
  53. charmap.exe,LoadLibraryW,LPCWSTR: MSFTEDIT.DLL 
  54.  
  55. charmap.exe,LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE 
  56.  
  57. mspaint.exe,LoadLibraryExW,LPCWSTR : gdiplus.dll, dwFlags : NONE 
  58.  
  59. mspaint.exe,GetProcAddress,hModule : C:\WINDOWS\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.789_none_faf0a7e97612e7bb\gdiplus.dll, LPCSTR: GdiplusStartup 
  60.  
  61. mspaint.exe,LoadLibraryW,LPCWSTR: MSFTEDIT.DLL 
  62.  
  63. mspaint.exe,LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE 

如果你想让WFH输出更多详细内容,可以使用“-v”参数开启Verbose模式。此时将能够查看Windows API调用的详细情况:

  1. PS C:\Tools\WFH > python .\wfh.py -t * -m dll -v 
  2.  
  3. ================================================== 
  4.  
  5. Running Frida against charmap.exe 
  6.  
  7. {'type': 'send', 'payload': 'LoadLibraryW,LPCWSTR: MSFTEDIT.DLL'} 
  8.  
  9. {'type': 'send', 'payload': 'LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE'} 
  10.  
  11. -------------------------------------------------- 
  12.  
  13.         [+] Potential DllMain Sideloading: LoadLibraryW,LPCWSTR: MSFTEDIT.DLL 
  14.  
  15.         [+] Potential DllMain Sideloading: LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE 
  16.  
  17.   
  18.  
  19. [*] Writing raw Frida instrumentation to charmap.exe-raw.log 
  20.  
  21. [*] Writing Potential DLL Sideloading to charmap.exe-sideload.log 
  22.  
  23. -------------------------------------------------- 
  24.  
  25. ================================================== 
  26.  
  27. Running Frida against mspaint.exe 
  28.  
  29. {'type': 'send', 'payload': 'LoadLibraryExW,LPCWSTR : gdiplus.dll, dwFlags : NONE'} 
  30.  
  31. {'type': 'send', 'payload': 'GetProcAddress,hModule : C:\\WINDOWS\\WinSxS\\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.789_none_faf0a7e97612e7bb\\gdiplus.dll, LPCSTR: GdiplusStartup'} 
  32.  
  33. {'type': 'send', 'payload': 'LoadLibraryW,LPCWSTR: MSFTEDIT.DLL'} 
  34.  
  35. {'type': 'send', 'payload': 'LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE'} 
  36.  
  37. -------------------------------------------------- 
  38.  
  39.         [+] Potential DllMain Sideloading: LoadLibraryExW,LPCWSTR : gdiplus.dll, dwFlags : NONE 
  40.  
  41.         [-] Potential DllExport Sideloading: GetProcAddress,hModule : C:\WINDOWS\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.19041.789_none_faf0a7e97612e7bb\gdiplus.dll, LPCSTR: GdiplusStartup 
  42.  
  43.         [+] Potential DllMain Sideloading: LoadLibraryW,LPCWSTR: MSFTEDIT.DLL 
  44.  
  45.         [+] Potential DllMain Sideloading: LoadLibraryExW,LPCWSTR : MSFTEDIT.DLL, dwFlags : NONE 
  46.  
  47.   
  48.  
  49. [*] Writing raw Frida instrumentation to mspaint.exe-raw.log 
  50.  
  51. [*] Writing Potential DLL Sideloading to mspaint.exe-sideload.log 
  52.  
  53. -------------------------------------------------- 
  54.  
  55. ================================================== 
  56.  
  57. [*] Writing dll results to dll_results.csv 

(2) COM劫持识别

  1. PS C:\Tools\WFH > python .\wfh.py -t "C:\Program Files\Internet Explorer\iexplore.exe" -m com 
  2.  
  3. ================================================== 
  4.  
  5. Running Frida against C:\Program Files\Internet Explorer\iexplore.exe 
  6.  
  7. -------------------------------------------------- 
  8.  
  9.         [+] Potential COM Hijack: Path : HKEY_LOCAL_MACHINE\Software\Classes\CLSID\{0E5AAE11-A475-4C5B-AB00-C66DE400274E}\InProcServer*32,lpValueName : null,Type : REG_EXPAND_SZ, Value : %SystemRoot%\system32\Windows.Storage.dll 
  10.  
  11.         [+] Potential COM Hijack: Path : HKEY_CLASSES_ROOT\CLSID\{1FD49718-1D00-4B19-AF5F-070AF6D5D54C}\InProcServer*32,lpValueName : null,Type : REG_SZ, Value : C:\Program Files (x86)\Microsoft\Edge\Application\90.0.818.62\BHO\ie_to_edge_bho_64.dll 
  12.  
  13.   
  14.  
  15. [*] Writing raw Frida instrumentation to .\iexplore.exe-raw.log 
  16.  
  17. [*] Writing Potential COM Hijack to .\iexplore.exe-comhijack.log 
  18.  
  19. -------------------------------------------------- 
  20.  
  21. ================================================== 
  22.  
  23. [*] Writing dll results to comhijack_results.csv 

工具使用样例

(1) 原生Windows签名代码

将所有的原生Windows签名代码拷贝至WFH脚本所在目录:

  1. Get-ChildItem c:\ -File | ForEach-Object { if($_ -match '.+?exe$') {Get-AuthenticodeSignature $_.fullname} } | where {$_.IsOSBinary} | ForEach-Object {Copy-Item $_.path . } 

(2) 搜索DLL侧加载机会

  1. python wfh.py -t * -m dll 

(3) 搜索COM劫持机会

  1. python wfh.py -t * -m com 

项目地址

WFH:【GitHub传送门

 

文章来源网络,作者:管理,如若转载,请注明出处:https://shuyeidc.com/wp/143282.html<

(0)
管理的头像管理
上一篇2025-03-09 15:16
下一篇 2025-03-09 15:17

相关推荐

  • jsp空间购买和交换数据空间怎么买,有哪些注意事项?

    购买JSP空间时,是否考虑过数据交换空间的性能?简米科技(2003年始创,23年行业沉淀)与酷番云(工信部一类增值电信全牌照)这类持牌自营机房的服务商,能确保数据交换的高效稳定,是值得优先选择的合作伙伴,为什么JSP空间需要搭配独立的数据交换空间从JSP应用特性看数据交换需求JSP基于Java技术,常用于企业级……

    2026-08-11
    0
  • 建网站用香港空间效果怎么样,香港空间稳定吗?

    建网站用香港空间,对于创建网站资产来说,核心价值在于免备案和全球带宽优势,尤其适合外贸、跨境电商和需要快速启动的项目,但你必须权衡国内访问延迟,并选择有资质的服务商以保证资产安全,香港空间的核心优势与适用边界免备案:节省时间就是节省成本国内服务器需要备案,通常需要10到20天,香港空间无需备案,域名解析后即可上……

    2026-08-11
    0
  • Java连接云数据库的方法是什么,如何操作

    Java连接云数据库的核心在于通过JDBC驱动,结合云服务商提供的连接地址、端口、数据库名及认证信息,配置安全策略(如SSL、IP白名单),即可实现稳定高效的远程数据库访问,基础准备:JDBC驱动与依赖管理连接云数据库前,需要确保开发环境具备对应的JDBC驱动,以最常见的MySQL为例,你需要引入mysql-c……

    2026-08-11
    0
  • 建网站公安联网备案必须使用数据码吗,备案流程是什么

    网站备案包括ICP备案和公安联网备案,两者缺一不可,公安联网备案必须使用服务商提供的数据码,选择持有合法资质的服务商是顺利通过备案的前提,为什么网站必须进行公安联网备案根据公安部《计算机信息网络国际联网安全保护管理办法》,网站开通后30日内必须到公安机关办理备案手续,未完成公安备案的网站,面临责令整改、关闭网站……

    2026-08-10
    0
  • 建一个企业网站大概需要多少钱?,怎么收费?

    建网站要多少钱,没有一个固定的数字,几百到几万都可能,但真正的“创建网站资产”绝不仅仅是初次投入的成本,而是基于长期稳定、合规和安全的持续性投入,其中核心取决于你选择了什么样的“地基”来承载你的业务,建站预算的构成与行业基准当你开始规划一个网站,最先面对的就是预算问题,一个常见的误区是只关注网站“看起来”的建造……

    2026-08-10
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注