How to construct a preemptive digital filter to neutralize an unwanted filter
If $S_x(\omega)$ is the desired input power spectral density (PSD), and $S_y(\omega)$ is the PSD at the output of the black box, which has the (unknown) frequency response $H(\omega)$, then the following relation holds:

$$S_y(\omega)=S_x(\omega)|H(\omega)|^2\tag{1}$$

Now you want to cascade the black box with a filter to recover the original PSD $S_x(\omega)$ from the distorted PSD $S_y(\omega)$:

$$S_y(\omega)|G(\omega)|^2=S_x(\omega)\tag{2}$$

From $(2)$ it immediately follows that

$$|G(\omega)|=\sqrt{\frac{S_x(\omega)}{S_y(\omega)}},\quad S_y(\omega)\neq 0\tag{3}$$

You need to design a filter with magnitude response $|G(\omega)|$ given by $(3)$. Note that for this application, the filter's phase response is irrelevant.