Yes this is possible, you can extract a MultiMatte element from the material that is applied to all the objects, this will give you a mask of all objects.
You can also extract a separate masks for each of the objects with that material by using Object IDs and another MultiMatte element that operates with Objects IDs unlike the previous one that uses Material IDs.