MCPcopy Index your code
hub / github.com/secdev/scapy / query_directory

Method query_directory

scapy/layers/smbclient.py:927–960  ·  view source on GitHub ↗

Query the Directory with FileId

(self, FileId, FileName="*")

Source from the content-addressed store, hash-verified

925 return resp.Count
926
927 def query_directory(self, FileId, FileName="*"):
928 """
929 Query the Directory with FileId
930 """
931 results = []
932 Flags = "SMB2_RESTART_SCANS"
933 while True:
934 pkt = SMB2_Query_Directory_Request(
935 FileInformationClass="FileIdBothDirectoryInformation",
936 FileId=FileId,
937 FileName=FileName,
938 Flags=Flags,
939 )
940 resp = self.ins.sr1(pkt, verbose=0, timeout=self.timeout)
941 Flags = 0 # only the first one is RESTART_SCANS
942 if not resp:
943 raise ValueError("QueryDirectory timed out !")
944 if SMB2_Error_Response in resp:
945 break
946 elif SMB2_Query_Directory_Response not in resp:
947 raise ValueError("Failed QueryDirectory ! %s" % resp.NTStatus)
948 res = FileIdBothDirectoryInformation(resp.Output)
949 results.extend(
950 [
951 (
952 x.FileName,
953 x.FileAttributes,
954 x.EndOfFile,
955 x.LastWriteTime,
956 )
957 for x in res.files
958 ]
959 )
960 return results
961
962 def query_info(self, FileId, InfoType, FileInfoClass, AdditionalInformation=0):
963 """

Callers 1

lsMethod · 0.80

Calls 4

extendMethod · 0.80
sr1Method · 0.45

Tested by

no test coverage detected