MCPcopy Create free account
hub / github.com/secdev/scapy / lookup_folder

Method lookup_folder

scapy/layers/smbserver.py:1129–1163  ·  view source on GitHub ↗

Lookup a folder handle

(self, handle, filter, offset, cls)

Source from the content-addressed store, hash-verified

1127 return fid
1128
1129 def lookup_folder(self, handle, filter, offset, cls):
1130 """
1131 Lookup a folder handle
1132 """
1133 path = self.current_handles[handle][0]
1134 self.vprint("Query directory: " + str(path))
1135 self.current_handles[handle][1]["LastAccessTime"] = self.current_smb_time()
1136 if not path.is_dir():
1137 raise NotADirectoryError
1138 return sorted(
1139 [
1140 cls(FileName=x.name, **self.current_handles[self.lookup_file(x)][1])
1141 for x in path.glob(filter)
1142 # Note: symbolic links are unsupported because it's hard to check
1143 # for path traversal on them.
1144 if not x.is_symlink()
1145 ]
1146 + [
1147 cls(
1148 FileAttributes=("FILE_ATTRIBUTE_DIRECTORY"),
1149 FileName=".",
1150 )
1151 ]
1152 + (
1153 [
1154 cls(
1155 FileAttributes=("FILE_ATTRIBUTE_DIRECTORY"),
1156 FileName="..",
1157 )
1158 ]
1159 if path.resolve() != self.root_path()
1160 else []
1161 ),
1162 key=lambda x: x.FileName,
1163 )[offset:]
1164
1165 @ATMT.action(receive_create_file)
1166 def send_create_file_response(self, pkt):

Callers 1

Calls 5

vprintMethod · 0.95
current_smb_timeMethod · 0.95
lookup_fileMethod · 0.95
root_pathMethod · 0.95
resolveMethod · 0.45

Tested by

no test coverage detected