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

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.

图片转代码服务由CSDN问答提供 功能建议

我试图通过执行powershell来创建一个php脚本来更改Active Directory用户密码。 http://pastebin.com/XYvSFjPv - 面向希望了解的人 < p>转入问题转义引号' 我的目标是充分利用所有字符(utf08标准),包括引号 as我经历了很多 如何逃避并且仍然没有达到令人满意的结果的网站。 如果可能的话,我希望有一些帮助来逃避这些角色,因为我找不到任何能够轻易逃脱角色的功能。

我在带有IIS 7,PHP 5.4和Powershell v1.0

的Windows 2008服务器上运行此脚本,并通过观察命令 shell_exec()发送到命令 -line反过来启动powershell(我不确定我是否必须双重转义以使其工作。)

并确保它很清楚我想逃避以下字符 使用 shell_exec()命令为Powershell v1.0 '

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

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.

    点赞 打赏 评论

相关推荐 更多相似问题