A variational approach to the reconstruction of cracks by boundary measurements