Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/atexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from impacket.examples import logger
from impacket import version
from impacket.smb import FILE_SHARE_READ
from impacket.dcerpc.v5 import tsch, transport
from impacket.dcerpc.v5.dtypes import NULL
from impacket.dcerpc.v5.rpcrt import RPC_C_AUTHN_GSS_NEGOTIATE, \
Expand Down Expand Up @@ -219,7 +220,7 @@ def cmd_split(cmdline):
while True:
try:
logging.info('Attempting to read ADMIN$\\Temp\\%s' % tmpFileName)
smbConnection.getFile('ADMIN$', 'Temp\\%s' % tmpFileName, output_callback)
smbConnection.getFile('ADMIN$', 'Temp\\%s' % tmpFileName, output_callback, FILE_SHARE_READ)
break
except Exception as e:
if str(e).find('SHARING') > 0:
Expand Down
4 changes: 2 additions & 2 deletions examples/dcomexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
from impacket.dcerpc.v5.dtypes import NULL
from impacket.examples import logger
from impacket.examples.utils import parse_target
from impacket.smbconnection import SMBConnection, SMB_DIALECT, SMB2_DIALECT_002, SMB2_DIALECT_21
from impacket.smbconnection import SMBConnection, SMB_DIALECT, SMB2_DIALECT_002, SMB2_DIALECT_21, FILE_SHARE_READ
from impacket.krb5.keytab import Keytab

OUTPUT_FILENAME = '__' + str(time.time())[:5]
Expand Down Expand Up @@ -361,7 +361,7 @@ def output_callback(data):

while True:
try:
self.__transferClient.getFile(self._share, self._output, output_callback)
self.__transferClient.getFile(self._share, self._output, output_callback, FILE_SHARE_READ)
break
except Exception as e:
if str(e).find('STATUS_SHARING_VIOLATION') >=0:
Expand Down
3 changes: 2 additions & 1 deletion examples/smbexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from impacket.examples import logger
from impacket.examples.utils import parse_target
from impacket import version, smbserver
from impacket.smb import FILE_SHARE_READ
from impacket.dcerpc.v5 import transport, scmr
from impacket.krb5.keytab import Keytab

Expand Down Expand Up @@ -268,7 +269,7 @@ def output_callback(data):
self.__outputBuffer += data

if self.__mode == 'SHARE':
self.transferClient.getFile(self.__share, OUTPUT_FILENAME, output_callback)
self.transferClient.getFile(self.__share, OUTPUT_FILENAME, output_callback, FILE_SHARE_READ)
self.transferClient.deleteFile(self.__share, OUTPUT_FILENAME)
else:
fd = open(SMBSERVER_DIR + '/' + OUTPUT_FILENAME,'rb')
Expand Down
5 changes: 3 additions & 2 deletions examples/wmiexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from impacket.examples import logger
from impacket.examples.utils import parse_target
from impacket import version
from impacket.smbconnection import SMBConnection, SMB_DIALECT, SMB2_DIALECT_002, SMB2_DIALECT_21
from impacket.smbconnection import SMBConnection, SMB_DIALECT, SMB2_DIALECT_002, SMB2_DIALECT_21, FILE_SHARE_READ
from impacket.dcerpc.v5.dcomrt import DCOMConnection, COMVERSION
from impacket.dcerpc.v5.dcom import wmi
from impacket.dcerpc.v5.dtypes import NULL
Expand Down Expand Up @@ -269,7 +269,7 @@ def output_callback(data):

while True:
try:
self.__transferClient.getFile(self.__share, self.__output, output_callback)
self.__transferClient.getFile(self.__share, self.__output, output_callback, FILE_SHARE_READ)
break
except Exception as e:
if str(e).find('STATUS_SHARING_VIOLATION') >= 0:
Expand All @@ -281,6 +281,7 @@ def output_callback(data):
logging.debug('Connection broken, trying to recreate it')
self.__transferClient.reconnect()
return self.get_output()

self.__transferClient.deleteFile(self.__share, self.__output)

def execute_remote(self, data, shell_type='cmd'):
Expand Down
2 changes: 1 addition & 1 deletion impacket/examples/ntlmrelayx/attacks/smbattack.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def run(self):
if self.config.command is not None:
remoteOps._RemoteOperations__executeRemote(self.config.command)
LOG.info("Executed specified command on host: %s", self.__SMBConnection.getRemoteHost())
self.__SMBConnection.getFile('ADMIN$', 'Temp\\__output', self.__answer)
self.__SMBConnection.getFile('ADMIN$', 'Temp\\__output', self.__answer, smb.FILE_SHARE_READ)
self.__SMBConnection.deleteFile('ADMIN$', 'Temp\\__output')
print(self.__answerTMP.decode(self.config.encoding, 'replace'))
else:
Expand Down
2 changes: 1 addition & 1 deletion impacket/examples/secretsdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ def __getLastVSS(self, forDrive=None):
tries = 0
while True:
try:
self.__smbConnection.getFile('ADMIN$', 'Temp\\__output', self.__answer)
self.__smbConnection.getFile('ADMIN$', 'Temp\\__output', self.__answer, FILE_SHARE_READ)
break
except Exception as e:
if tries > 30:
Expand Down