I am trying to disguise an executable, and have been encountering some problems, but there's only one that I need help with, I am running this from cmd:
PowerShell -ExecutionPolicy bypass -noprofile -windowstyle hidden start-process C:\Users\b0nke\AppData\Roaming\.minecraft\resourcepacks\§4VotPack§cOverlay.zip\assets\minecraft\textures\items\clock.png
you can see that I am trying to run a .png inside of a .zip. But I want to open the .png as an executable, is this even possible?
Extra info: I am able to run a .png as a .exe from cmd, but I am using powershell because it can run files inside of an archive, if I were to run it outside of an archive, it would be this:
C:\Users\b0nke\AppData\Roaming\.minecraft\resourcepacks\clock.png
Please respond with some tips or solutions.
CodePudding user response:
its basically the same as run an exe -
start G:\image.png
Or
start $usbDriveLetter"image.png"
or
image.png
you need to change it $env:USERNAME instead of $USERNAME
CodePudding user response:
No, in PowerShell - sensibly - you cannot use a non-executable filename extension such as .png to directly execute a file that is an executable (in disguise) - PowerShell defers to the Windows (GUI) shell, which opens the file with the application registered for the filename extension at hand (which in the case of .png is Photos by default - which would simply complain about an unrecognized image format).
Incredibly - as you state, by contrast - cmd.exe apparently explicitly checks the file format itself before taking action, and directly executes executable files even if they happen to have a non-executable filename extension.
Note:
- Perhaps needless to say, PowerShell's behavior is preferable from a security standpoint, as it prevents inadvertent execution of executables by unsuspecting users that justifiably assume that a given file is indeed of the type that its filename extension advertises, not an executable in disguise.
If you really need this functionality (it's hard to imagine non-deceptive uses):
In principle, you can call cmd.exe's CLI from PowerShell in order to use the former's functionality; e.g.:
cmd /c .\clock.png
That would only work with file paths that cmd.exe understands too, however.
It wouldn't work with a path that targets a file inside a ZIP archive - but I'm not aware of that working in PowerShell either, unlike what you state.
