-
Notifications
You must be signed in to change notification settings - Fork 145
Unable to run Powershell interactively #125
Comments
Yeah I remember that dude. I'm actually thinking of baking in some kind of PS functionality directly into Meterpreter instead of trying to shim it in/out through the the usual means. Hence the new issue. Thoughts? |
Definitely would be . Trying to grab the stdout handles from powershell is just painful. Could wrap scripts to redirect output to clipboard/files/or some other handle but could break depending on script. Better solution could be to implement https://github.com/silentbreaksec/UnmanagedPowerShell as a reflective DLL/meterpreter plugin. This would bypass software restriction policies on powershell.exe etc. Metasploit side may have to track the functions within the Powershell (regex ftw) or the user may have to specify the function to run after the Powershell script is injected? |
N.b. powershell -C/E command will generally work OK. But obviously limited to the command line length of 8192 which is easily reached when encoding larger scripts. |
One challenge with the RDI approach (which I'd much prefer than shimming text across process boundaries) is that we could be running this inside a process that already has the CLR running. This is an issue I'm keen to solve in general which could allow us to push and load .NET extensions. I'll try to get some time to look into this at some point soon. |
the result of In fact, if you just do: |
Yup, exactly. PS does some horrible shit with handles. I think automating it via an extension is the way to go. Investigation added to the ever-growing list of things to do. |
Try dropping it directly into powershell before a normal shell. It could be blocking the powershell from executing since you are already in a less privileged shell. |
Was this ever solved? Having kind of the same issue, just with NW, if you could spare me 5, please see: nwjs/nw.js#4409 |
Not yet. It is being actively discussed. We are pondering solutions at the
moment.
|
I was able to get this to work in the NWjs project. Maybe you can get inspired by the way NodeJS does this with their child_process option: https://nodejs.org/api/child_process.html Have a great day. |
You didn't just invoke node on me did you? ;)
I'm afraid the way node operates is completely different to how meterpreter
operates. The implementations will be very different.
Cheers!
|
Is it me or is the powershell in meterpreter broken ?
|
It's not broken, and is not the right place for this comment @5p3c7r3. Try |
For some reason the interaction with Powershell through Meterpreter doesn't work interactively:
😞
It looks like it might have something to do with the way that the std handles are managed. This isn't great. We should try to figure out what's going on here so that people can run interactive powershell prompts through Meterpreter. At the time time, it'd be nice to have a
powershell
command that behaves likeshell
, but gives a powershell prompt instead of a command prompt.The text was updated successfully, but these errors were encountered: