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

Method send_create_file_response

scapy/layers/smbserver.py:1166–1311  ·  view source on GitHub ↗

Handle CreateFile request See [MS-SMB2] 3.3.5.9 ()

(self, pkt)

Source from the content-addressed store, hash-verified

1164
1165 @ATMT.action(receive_create_file)
1166 def send_create_file_response(self, pkt):
1167 """
1168 Handle CreateFile request
1169
1170 See [MS-SMB2] 3.3.5.9 ()
1171 """
1172 self.update_smbheader(pkt)
1173 if pkt[SMB2_Create_Request].NameLen:
1174 fname = pkt[SMB2_Create_Request].Name
1175 else:
1176 fname = None
1177 if fname:
1178 self.vprint("Opened: " + fname)
1179 if self.current_tree() == "IPC$":
1180 # Special IPC$ case: opening a pipe
1181 FILE_ID = self.PIPES_TABLE.get(fname, None)
1182 if FILE_ID:
1183 attrs = {
1184 "CreationTime": 0,
1185 "LastAccessTime": 0,
1186 "LastWriteTime": 0,
1187 "ChangeTime": 0,
1188 "EndOfFile": 0,
1189 "AllocationSize": 4096,
1190 }
1191 self.current_handles[FILE_ID] = (
1192 fname,
1193 attrs,
1194 )
1195 self.send(
1196 self.smb_header.copy()
1197 / SMB2_Create_Response(
1198 OplockLevel=pkt.RequestedOplockLevel,
1199 FileId=FILE_ID,
1200 **attrs,
1201 )
1202 )
1203 else:
1204 # NOT_FOUND
1205 resp = self.smb_header.copy() / SMB2_Error_Response()
1206 resp.Command = "SMB2_CREATE"
1207 resp.Status = "STATUS_OBJECT_NAME_NOT_FOUND"
1208 self.send(resp)
1209 return
1210 else:
1211 # Check if there is a Durable Handle Reconnect Request
1212 durable_handle = None
1213 if pkt[SMB2_Create_Request].CreateContextsLen:
1214 try:
1215 durable_handle = next(
1216 x.Data.FileId
1217 for x in pkt[SMB2_Create_Request].CreateContexts
1218 if x.Name == b"DH2C"
1219 )
1220 except StopIteration:
1221 pass
1222 # Lookup file handle
1223 try:

Callers

nothing calls this directly

Calls 15

update_smbheaderMethod · 0.95
vprintMethod · 0.95
current_treeMethod · 0.95
sendMethod · 0.95
lookup_fileMethod · 0.95
set_compounded_handleMethod · 0.95
make_file_idMethod · 0.95
SMB2_Error_ResponseClass · 0.90
SMB2_Create_ContextClass · 0.90

Tested by

no test coverage detected