We use equivariant localization to construct off-shell entropy functions for supersymmetric black holes in \(\mathcal{N}\) = 2, D = 4 gauged supergravity coupled to matter. This allows one to compute the black hole entropy without solving the supergravity equations of motion and provides a novel generalization of the attractor mechanism. We consider magnetically charged black holes in AdS4 which have an AdS2 × M2 near horizon geometry, where M2 is a sphere or a spindle, and we also obtain entropy functions for ungauged supergravity as a simple corollary. We derive analogous results for black strings and rings in D = 5 supergravity which have an AdS3 × M2 near horizon geometry, and in this setting we derive an off-shell expression for the central charge of the dual \(\mathcal{N}\) = (0, 2), d = 2 SCFT.