jborean93 / pypsexec

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

Pypsexec Windows authentication issue #30

Open whitesec121 opened 4 years ago

whitesec121 commented 4 years ago

Hello @jborean93

I am having an issue while connecting my windows host machine from the Linux guest (Installed in VMWARE Workstation) using the following piece of code.

`from pypsexec.client import Client import os import time import sys import paramiko

host = '192.168.0.32' user = '.' passd = ''

c = Client(host, username=user, password=passd, encrypt=False,port=445) c.connect()

try: c.create_service() stdout = c.run_executable("cmd.exe", arguments="notepad",timeout_seconds=20) finally: c.cleanup() c.remove_service() c.disconnect()

output = [] output = stdout[0].decode("utf-8") print(output.split("\r\n")[1:3]) `

The error is pypsexec.exceptions.SCMRException: Exception calling ROpenSCManagerW. Code: 5, Msg: ERROR_ACCESS_DENIED

Could you let know what is wrong?

whitesec121 commented 4 years ago

Further updates: I created the property LocalAccountTokenFilterPolicy=1 in registry and now get the following error instead

pypsexec.exceptions.SCMRException: Exception calling RDeleteService. Code: 1072, Msg: ERROR_SERVICE_MARKED_FOR_DELETE

whitesec121 commented 4 years ago

Hello, I checked some of the previous issues and updated the code with an exception that you mentioned but it shows the following error

Traceback (most recent call last): File "cwin.py", line 2, in from pypsexec.exception import SCMRException ImportError: No module named exception