本文整理匯總了Python中impacket.smb3structs.FILE_READ_DATA屬性的典型用法代碼示例。如果您正苦於以下問題:Python smb3structs.FILE_READ_DATA屬性的具體用法?Python smb3structs.FILE_READ_DATA怎麽用?Python smb3structs.FILE_READ_DATA使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類impacket.smb3structs
的用法示例。
在下文中一共展示了smb3structs.FILE_READ_DATA屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: openFile
# 需要導入模塊: from impacket import smb3structs [as 別名]
# 或者: from impacket.smb3structs import FILE_READ_DATA [as 別名]
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)
示例2: open
# 需要導入模塊: from impacket import smb3structs [as 別名]
# 或者: from impacket.smb3structs import FILE_READ_DATA [as 別名]
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
示例3: open
# 需要導入模塊: from impacket import smb3structs [as 別名]
# 或者: from impacket.smb3structs import FILE_READ_DATA [as 別名]
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
示例4: __init__
# 需要導入模塊: from impacket import smb3structs [as 別名]
# 或者: from impacket.smb3structs import FILE_READ_DATA [as 別名]
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
示例5: __init__
# 需要導入模塊: from impacket import smb3structs [as 別名]
# 或者: from impacket.smb3structs import FILE_READ_DATA [as 別名]
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
示例6: search_content
# 需要導入模塊: from impacket import smb3structs [as 別名]
# 或者: from impacket.smb3structs import FILE_READ_DATA [as 別名]
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()