This repository was archived by the owner on Dec 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def get_ps_script(path):
1919 return os .path .join (os .path .dirname (cme .__file__ ), 'data' , path )
2020
2121def encode_ps_command (command ):
22- return b64encode (command .encode ('UTF-16LE' ))
22+ return b64encode (command .encode ('UTF-16LE' )). decode ()
2323
2424def is_powershell_installed ():
2525 if which ('powershell' ):
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ def enum_host_info(self):
8383 try :
8484 smb_conn .login ('' , '' )
8585 except SessionError as e :
86- if "STATUS_ACCESS_DENIED" in e .message :
86+ if "STATUS_ACCESS_DENIED" in e .getErrorString () :
8787 pass
8888
8989 self .domain = smb_conn .getServerDNSDomainName ()
@@ -135,20 +135,12 @@ def create_conn_obj(self):
135135
136136 def check_if_admin (self , auth ):
137137 try :
138- # I'm pretty sure there has to be a better way of doing this.
139- # Currently we are just searching for our user in the sysadmin group
140-
141- self .conn .sql_query ("EXEC sp_helpsrvrolemember 'sysadmin'" )
138+ self .conn .sql_query ("SELECT IS_SRVROLEMEMBER('sysadmin')" )
142139 self .conn .printRows ()
143140 query_output = self .conn ._MSSQL__rowsPrinter .getMessage ()
144- logging .debug ("'sysadmin' group members:\n {}" .format (query_output ))
145-
146- if not auth :
147- search_string = '{}\\ {}' .format (self .domain , self .username )
148- else :
149- search_string = self .username
141+ query_output = query_output .strip ("\n -" )
150142
151- if re . search ( r'\b' + search_string + '\W' , query_output ):
143+ if int ( query_output ):
152144 self .admin_privs = True
153145 else :
154146 return False
You can’t perform that action at this time.
0 commit comments