Note. We don't really care about the actual direction of the heat flux. Choose a direction as the positive direction, it the heat flux is negative it's going on the other side.
Solution. If we consider a steady 1D problem, the heat flux is constant on each section. Only conduction occurs and thus
$q_a = K_a \dfrac{T_1 - T_{ab}}{l_a} = $
$\quad = K_b \dfrac{T_{ab} - T_{bc}}{l_b} = q_b =$
$\quad = K_c \dfrac{T_{bc} - T_{bc}}{l_c} = q_c = $
$\quad = K_d \dfrac{T_{cd} - T_{2}}{l_d} = q_d$
Knowing the temperature $T_1$ and $T_2$, the equations above can be recast as a linear system of 4 equations and 4 unknowns, the heat flux and the temperature at the three interfaces $q$, $T_{ab}$, $T_{bc}$, and $T_{cd}$, as
$\begin{bmatrix} 1 & \frac{K_a}{l_a} & 0 & 0 \\
1 & -\frac{K_b}{l_b} & \frac{K_b}{l_b} & 0 \\
1 & 0 & -\frac{K_c}{l_c} & \frac{K_c}{l_c} \\
1 & 0 & 0 & -\frac{K_d}{l_d} \end{bmatrix}
\begin{bmatrix} q \\ T_{ab} \\ T_{bc} \\ T_{cd} \end{bmatrix} =
\begin{bmatrix} \frac{K_a}{l_a}T_1 \\ 0 \\ 0 \\ -\frac{K_d}{l_d}T_2 \end{bmatrix} $
Defining $R_i := \frac{l_i}{K_i}$ as the thermal resistance, we can interpret heat conduction with electrical analogy. It's quite easy to find that the heat flux reads
$\left(R_a + R_b + R_c + R_d \right) q = T_1 - T_2$$\qquad \rightarrow \qquad $$q = \dfrac{T_1 - T_2}{\sum_i R_i}$,
where the analogy with resistors in series should be evident. Once you know $q$ you can solve for the interface temperature $T_{ij}$. Eventually, temperature in the $i^{th}$ layer reads
$T(x_i) = T_i + (T_j- T_i) \frac{x_i}{l_i}$, with $x_i \in [ 0, l_i ]$