Wavefront shaping is increasingly being used in modern microscopy to obtain high-resolution images deep inside inhomogeneous media. Wavefront shaping methods typically rely on the presence of a “guide star” to find the optimal wavefront to mitigate the scattering of light. However, the use of guide stars poses severe limitations. Notably, only objects in the close vicinity of the guide star can be imaged. Here, we introduce a guide-star-free wavefront shaping method in which the optimal wavefront is computed using a digital model of the sample. The refractive index model of the sample, that serves as the input for the computation, is constructed in situ by the microscope itself. In a proof of principle imaging experiment, we demonstrate a large improvement in the two-photon fluorescence signal through a diffuse medium, outperforming state-of-the-art wavefront shaping by a factor of two in imaging depth.