douyanqu9722 2014-11-11 04:37
浏览 70
已采纳

PHP to Powershell - 逃避

I am trying to make a php script to change Active Directory User passwords by executing powershell. http://pastebin.com/XYvSFjPv - for those that wish to look

Ran into a problem escaping quotes " and ' My goal is to make full use of all characters (utf08 standard) including quotes as I've been through many websites of how to escape and still not come to a satisfactory result. I would like some help in escaping these characters if at all possible because I have found no function to easily escape characters.

I am running this script on a Windows 2008 server with IIS 7, PHP 5.4 and Powershell v1.0

and by observation the command shell_exec() sends to command-line which in turn starts up powershell (I am not sure if i have to double escape to make this work.)

And to make sure it's clear I would like to escape the following characters ' and " for Powershell v1.0 using the shell_exec() command.

  • 写回答

1条回答 默认 最新

  • dtpt75860 2014-11-11 06:44
    关注

    The simplest way to pass complex arguments to Powershell is to use the -EncodedCommand switch. It takes a Base64 encoded parameter string. No escaping is needed for the quotes or any other weird characters for that matter. This has been discussed in other posts. Php's got a base64_encode() function that should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突