jborean93 / pypsexec

Remote Windows execution like PsExec on Python
MIT License
113 stars 38 forks source link

Running a process locally inside another RDP session #9

Closed justinttl closed 5 years ago

justinttl commented 5 years ago

Hi, just want to ask a simple use case question.

Does this support running a process in another interactive RDP session within the same machine?

Something along the lines of

PsExec.exe  -i $(SESSION_ID) -w $(pwd) <command> 

Thanks~

jborean93 commented 5 years ago

While it should work I've had mixed results with getting it to work. You can specify these arguments when calling run_executable() like;

stdout, stderr, rc = c.run_executable("notepad.exe",
                                      interactive=True,
                                      interactive_session=1,
                                      working_dir="C:\\Users")

The key is having interactive=True and then specify the session with interactive_session.

justinttl commented 5 years ago

Thanks for the response. I will give it a shot

jborean93 commented 5 years ago

@justinttl were you able to try this out?

justinttl commented 5 years ago

@jborean93

Hey, sorry didn't manage to find time to explore this path. Ended up directly using win32 APIs to invoke the sequence of processes by using a User Token. Obviously this requires high level of permissions in the OS, but ultimately I thought that was a better solution.

I might try the suggested approach one day and drop a reply here. Please feel free to close out the issue for now!

Thanks.