def send(self): if "*" not in self.path: openPath = self.path else: openPath = self.path[: self.path.index("*")] if openPath.endswith("\\"): openPath = openPath[: -1] # We need to start by opening the directory. request = DeviceCreateRequestPDU( self.deviceID, 0, self.requestID, 0, DirectoryAccessMask.FILE_LIST_DIRECTORY, 0, FileAttributes.FILE_ATTRIBUTE_DIRECTORY, FileShareAccess(7), # read, write, delete FileCreateDisposition.FILE_OPEN, FileCreateOptions.FILE_DIRECTORY_FILE, openPath ) self.sendIORequest(request)
def parseDeviceCreateRequest(self, deviceID: int, fileID: int, completionID: int, minorFunction: int, stream: BytesIO) -> DeviceCreateRequestPDU: desiredAccess = Uint32LE.unpack(stream) allocationSize = Uint64LE.unpack(stream) fileAttributes = FileAttributes(Uint32LE.unpack(stream)) sharedAccess = FileShareAccess(Uint32LE.unpack(stream)) createDisposition = FileCreateDisposition(Uint32LE.unpack(stream)) createOptions = FileCreateOptions(Uint32LE.unpack(stream)) pathLength = Uint32LE.unpack(stream) path = stream.read(pathLength) path = decodeUTF16LE(path)[: -1] return DeviceCreateRequestPDU( deviceID, fileID, completionID, minorFunction, desiredAccess, allocationSize, fileAttributes, sharedAccess, createDisposition, createOptions, path )
def parseDeviceCreateRequest(self, deviceId: int, fileId: int, completionId: int, minorFunction: int, stream: BytesIO) -> DeviceCreateRequestPDU: """ Starting at desiredAccess. """ desiredAccess = Uint32LE.unpack(stream) allocationSize = Uint64LE.unpack(stream) fileAttributes = Uint32LE.unpack(stream) sharedAccess = Uint32LE.unpack(stream) createDisposition = Uint32LE.unpack(stream) createOptions = Uint32LE.unpack(stream) pathLength = Uint32LE.unpack(stream) path = stream.read(pathLength) return DeviceCreateRequestPDU(deviceId, fileId, completionId, minorFunction, desiredAccess, allocationSize, fileAttributes, sharedAccess, createDisposition, createOptions, path)
def send(self): # Open the file request = DeviceCreateRequestPDU( self.deviceID, 0, self.requestID, 0, FileAccessMask.FILE_READ_DATA, 0, FileAttributes.FILE_ATTRIBUTE_NONE, FileShareAccess(7), # read, write, delete FileCreateDisposition.FILE_OPEN, FileCreateOptions.FILE_NON_DIRECTORY_FILE, self.path) self.sendIORequest(request)