(self, share, rpc, mode, serviceName, shell_type)
| 174 | |
| 175 | class RemoteShell(cmd.Cmd): |
| 176 | def __init__(self, share, rpc, mode, serviceName, shell_type): |
| 177 | cmd.Cmd.__init__(self) |
| 178 | self.__share = share |
| 179 | self.__mode = mode |
| 180 | self.__output = '\\\\%COMPUTERNAME%\\' + self.__share + '\\' + OUTPUT_FILENAME |
| 181 | self.__outputBuffer = b'' |
| 182 | self.__command = '' |
| 183 | self.__shell = '%COMSPEC% /Q /c ' |
| 184 | self.__shell_type = shell_type |
| 185 | self.__pwsh = 'powershell.exe -NoP -NoL -sta -NonI -W Hidden -Exec Bypass -Enc ' |
| 186 | self.__serviceName = serviceName |
| 187 | self.__rpc = rpc |
| 188 | self.intro = '[!] Launching semi-interactive shell - Careful what you execute' |
| 189 | |
| 190 | self.__scmr = rpc.get_dce_rpc() |
| 191 | try: |
| 192 | self.__scmr.connect() |
| 193 | except Exception as e: |
| 194 | logging.critical(str(e)) |
| 195 | sys.exit(1) |
| 196 | |
| 197 | s = rpc.get_smb_connection() |
| 198 | |
| 199 | # We don't wanna deal with timeouts from now on. |
| 200 | s.setTimeout(100000) |
| 201 | if mode == 'SERVER': |
| 202 | myIPaddr = s.getSMBServer().get_socket().getsockname()[0] |
| 203 | self.__copyBack = 'copy %s \\\\%s\\%s' % (self.__output, myIPaddr, DUMMY_SHARE) |
| 204 | |
| 205 | self.__scmr.bind(scmr.MSRPC_UUID_SCMR) |
| 206 | resp = scmr.hROpenSCManagerW(self.__scmr) |
| 207 | self.__scHandle = resp['lpScHandle'] |
| 208 | self.transferClient = rpc.get_smb_connection() |
| 209 | self.do_cd('') |
| 210 | |
| 211 | def finish(self): |
| 212 | # Just in case the ouput file is still in the share |
nothing calls this directly
no test coverage detected