Python impacket.smb3structs.FILE_READ_DATA Examples
The following are 8
code examples of impacket.smb3structs.FILE_READ_DATA().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
impacket.smb3structs
, or try the search function
.
Example #1
Source File: impacketconnection.py From lsassy with MIT License | 6 votes |
def openFile(self, tid, fpath, timeout: int = 3): self._log.debug("Opening file {}".format(fpath)) start = time.time() while True: try: fid = self._conn.openFile(tid, fpath, desiredAccess=FILE_READ_DATA) self._log.debug("File {} opened".format(fpath)) return fid except Exception as e: if str(e).find('STATUS_SHARING_VIOLATION') >= 0 or str(e).find('STATUS_OBJECT_NAME_NOT_FOUND') >= 0: # Output not finished, let's wait if time.time() - start > timeout: raise(Exception(e)) time.sleep(1) else: raise Exception(e)
Example #2
Source File: secretsdump.py From cracke-dit with MIT License | 6 votes |
def open(self): tries = 0 while True: try: self.__fid = self.__smbConnection.openFile(self.__tid, self.__fileName, desiredAccess=FILE_READ_DATA, shareMode=FILE_SHARE_READ) except Exception, e: if str(e).find('STATUS_SHARING_VIOLATION') >=0: if tries >= 3: raise e # Stuff didn't finish yet.. wait more time.sleep(5) tries += 1 pass else: raise e else: break
Example #3
Source File: dump.py From Exchange2domain with MIT License | 6 votes |
def open(self): tries = 0 while True: try: self.__fid = self.__smbConnection.openFile(self.__tid, self.__fileName, desiredAccess=FILE_READ_DATA, shareMode=FILE_SHARE_READ) except Exception, e: if str(e).find('STATUS_SHARING_VIOLATION') >=0: if tries >= 3: raise e # Stuff didn't finish yet.. wait more time.sleep(5) tries += 1 pass else: raise e else: break
Example #4
Source File: secretsdump.py From Slackor with GNU General Public License v3.0 | 6 votes |
def open(self): tries = 0 while True: try: self.__fid = self.__smbConnection.openFile(self.__tid, self.__fileName, desiredAccess=FILE_READ_DATA, shareMode=FILE_SHARE_READ) except Exception as e: if str(e).find('STATUS_SHARING_VIOLATION') >=0: if tries >= 3: raise e # Stuff didn't finish yet.. wait more time.sleep(5) tries += 1 pass else: raise e else: break
Example #5
Source File: dump.py From CVE-2019-1040 with MIT License | 6 votes |
def open(self): tries = 0 while True: try: self.__fid = self.__smbConnection.openFile(self.__tid, self.__fileName, desiredAccess=FILE_READ_DATA, shareMode=FILE_SHARE_READ) except Exception as e: if str(e).find('STATUS_SHARING_VIOLATION') >=0: if tries >= 3: raise e # Stuff didn't finish yet.. wait more time.sleep(5) tries += 1 pass else: raise e else: break
Example #6
Source File: remotefile.py From CrackMapExec with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, smbConnection, fileName, share='ADMIN$', access = FILE_READ_DATA | FILE_WRITE_DATA ): self.__smbConnection = smbConnection self.__share = share self.__access = access self.__fileName = fileName self.__tid = self.__smbConnection.connectTree(share) self.__fid = None self.__currentOffset = 0
Example #7
Source File: remotefile.py From ActiveReign with GNU General Public License v3.0 | 5 votes |
def __init__(self, smbConnection, fileName, share, access = FILE_READ_DATA | FILE_WRITE_DATA ): self.__smbConnection = smbConnection self.__share = share self.__access = access self.__fileName = fileName self.__tid = self.__smbConnection.connectTree(share) self.__fid = None self.__currentOffset = 0
Example #8
Source File: smbspider.py From CrackMapExec with BSD 2-Clause "Simplified" License | 4 votes |
def search_content(self, path, result): path = path.replace('*', '') try: rfile = RemoteFile(self.smbconnection, path + result.get_longname(), self.share, access=FILE_READ_DATA) rfile.open() while True: try: contents = rfile.read(4096) if not contents: break except SessionError as e: if 'STATUS_END_OF_FILE' in str(e): break except Exception: traceback.print_exc() break for pattern in self.pattern: if contents.lower().find(pattern.lower()) != -1: self.logger.highlight(u"//{}/{}/{}{} [lastm:'{}' size:{} offset:{} pattern:'{}']".format(self.smbconnection.getRemoteHost(), self.share, path, result.get_longname(), 'n\\a' if not self.get_lastm_time(result) else self.get_lastm_time(result), result.get_filesize(), rfile.tell(), pattern)) self.results.append('{}{}'.format(path, result.get_longname())) for regex in self.regex: if regex.findall(contents): self.logger.highlight(u"//{}/{}/{}{} [lastm:'{}' size:{} offset:{} regex:'{}']".format(self.smbconnection.getRemoteHost(), self.share, path, result.get_longname(), 'n\\a' if not self.get_lastm_time(result) else self.get_lastm_time(result), result.get_filesize(), rfile.tell(), regex.pattern)) self.results.append('{}{}'.format(path, result.get_longname())) rfile.close() return except SessionError as e: if 'STATUS_SHARING_VIOLATION' in str(e): pass except Exception: traceback.print_exc()