mirror of https://github.com/n1nj4sec/pupy.git
psexec: convert errors to unicode
This commit is contained in:
parent
561db4e46b
commit
9924bb1691
|
@ -26,6 +26,8 @@ from impacket.system_errors import \
|
||||||
ERROR_SERVICE_REQUEST_TIMEOUT
|
ERROR_SERVICE_REQUEST_TIMEOUT
|
||||||
from impacket.smbconnection import SMBConnection, SessionError, SMB_DIALECT
|
from impacket.smbconnection import SMBConnection, SessionError, SMB_DIALECT
|
||||||
|
|
||||||
|
from sys import getdefaultencoding
|
||||||
|
|
||||||
from Crypto.Cipher import DES
|
from Crypto.Cipher import DES
|
||||||
assert(DES)
|
assert(DES)
|
||||||
|
|
||||||
|
@ -233,7 +235,10 @@ class FileTransfer(object):
|
||||||
if te in (UnicodeEncodeError, UnicodeDecodeError):
|
if te in (UnicodeEncodeError, UnicodeDecodeError):
|
||||||
return 'Could not convert name to unicode. Use -c option to specify encoding'
|
return 'Could not convert name to unicode. Use -c option to specify encoding'
|
||||||
elif te == SessionError:
|
elif te == SessionError:
|
||||||
return self._exception.getErrorString()[1]
|
error = self._exception.getErrorString()[1]
|
||||||
|
if type(error) != unicode:
|
||||||
|
error = error.decode(getdefaultencoding())
|
||||||
|
return error
|
||||||
else:
|
else:
|
||||||
return te.__name__ +": " + str(self._exception)
|
return te.__name__ +": " + str(self._exception)
|
||||||
|
|
||||||
|
@ -577,6 +582,9 @@ def smbexec(
|
||||||
if output:
|
if output:
|
||||||
smbc, error = conninfo.create_connection()
|
smbc, error = conninfo.create_connection()
|
||||||
if not smbc:
|
if not smbc:
|
||||||
|
if type(error) != unicode:
|
||||||
|
error = error.decode(getdefaultencoding())
|
||||||
|
|
||||||
return None, error
|
return None, error
|
||||||
|
|
||||||
filename = wmiexec(conninfo, command, share, output)
|
filename = wmiexec(conninfo, command, share, output)
|
||||||
|
|
Loading…
Reference in New Issue