Somewhat generically:
a line through two points $A$ and $B$ has parametric formula $f(t) = A + (B-A)t$.
A plane of form $C\cdot x=k$ and this line meet at $C\cdot(A+(B-A)t)=k$, which can be transformed to $$t=\frac{k - C\cdot A}{C\cdot(B-A)}$$.
For a cube like this, the planes are $-x=0$, $-y=0$, $-z=0$, $x=1$, $y=1$, and $z=1$. In order to find the intersections between the cube and the line, we will find the intersections of these planes with the line, as $t$ values. Then, sort the planes and $t$ values by the $t$ values; if every dimension the line moves in appears once in the first half of the list, then the line passes through the cube and the line enters the cube at the $t$ value just before the midway point on the list and exits the cube at the $t$ value just after.
This last trick only works if you know that every face in your polytope has a parallel counterpart; otherwise you have to check whether a point at $t=-\infty$ gives $C\cdot(A+(B-A)t)$ means outside -- and then scan through the sorted list of $t$ values and planes to see whether all out-in transitions happen before any in-out transitions; the last out-in transition is where the line enters the polytope, the first in-out transition is where the line exits.
In your case, you will find that three of the $t$ values are $0$, and the other three are positive. The smallest positive $t$ value gives the point where the line exits the cube.