Using the Rodrigues formula for rotation $(\theta)$ around an axis $\vec k$
$$
p^{\theta} = p\cos\theta+\vec k\times p\sin\theta+(\vec k\cdot p)\vec k(1-\cos\theta)
$$
the rotated cube around $(A,\vec k)$ can be obtained calculating
$$
p^{\theta}_k = p_k\cos\theta+\vec k\times p_k\sin\theta+(\vec k\cdot p_k)\vec k(1-\cos\theta)
$$
because $A=(0,0,0)$.
Now regarding the rotated edge containing $C$ we have
$$
\frac 12(p^{\theta}_t+p^{\theta}_b)\cdot(0,0,1)=0
$$
where $p^{\theta}_t,p^{\theta}_b$ are respectively the rotated edge extrema. Regarding the point $B$ we need to determine $0\le \lambda\le 1$ such that
$$
\lambda p^{\theta}_t+(1-\lambda)p^{\theta}_b= B
$$
where $p^{\theta}_t,p^{\theta}_b$ are respectively the corresponding rotated edge extrema, and finally, the normalization condition $\|\vec k \|=1$. This gives us four conditions and five unknowns $(\vec k, \theta,\lambda)$. This can be solved as a minimization procedure as follows
$$
\min_{\vec k,\theta,\lambda}\|\lambda p^{\theta}_{t_1}+(1-\lambda)p^{\theta}_{b_1}- B\| \ \ \text{s. t}\ \ \ \cases{0\le \lambda\le 1\\
\|\vec k\| = 1\\ \frac 12(p^{\theta}_{t_2}+p^{\theta}_{b_2})\cdot(0,0,1)=0}
$$
giving
$$
\vec k = (0.130848,-0.447689,0.884564), \theta = -0.751834, \lambda = 0.708333, E = (31.7616, 3.94883, -11.2963)
$$
In blue the original cube, in red, rotated and in black the point $C$

Follows a MATHEMATICA script to perform this minimization
Clear[k]
k = {kx, ky, kz};
p1b = {0, 0, 0};
p2b = {24, 0, 0};
p3b = {24, 24, 0};
p4b = {0, 24, 0};
p1t = {0, 0, 24};
p2t = {24, 0, 24};
p3t = {24, 24, 24};
p4t = {0, 24, 24};
p0 = {20, -15, 0};
rot[p_, k_, theta_] := p Cos[theta] + Cross[k, p] Sin[theta] + k (k.p) (1 - Cos[theta])
rp2b = rot[p2b - p1b, k, theta];
rp2t = rot[p2t - p1b, k, theta];
rp3b = rot[p3b - p1b, k, theta];
rp3t = rot[p3t - p1b, k, theta];
equs1 = lambda rp2b + (1 - lambda) rp2t - p0;
equs2 = 1/2 (rp3t + rp3b).{0, 0, 1};
equs3 = k.k - 1;
sol = NMinimize[{equs1.equs1, 0 < lambda < 1, equs2 == 0, equs3 == 0}, {kx, ky, kz, theta, lambda}]