Disclaimer: This answer derives the prices of two different binary options within the Black/Scholes framework. Note that this is not an appropriate valuation model to use for non-European contracts in most real-world markets.
Up-and-In Binary Call
After reading your question for a second time, I agree with Quantuple's comment that you seem to be looking for the solution to an up-and-in binary call option.
Formally, let
\begin{equation}
\nu = \inf \left\{ t \in \mathbb{R}_+ : S_t \geq K \right\}
\end{equation}
be the first hitting time of $S$ to the strike $K$. The option has a unit payoff conditional on $\nu \leq T$ and $S_T \geq K$, i.e.
\begin{equation}
V_T = \mathrm{1} \left\{ S_T \geq K \right\} \mathrm{1} \left\{ \nu \leq T \right\}.
\end{equation}
Note however that $S_T \geq K \; \Rightarrow \; \nu \leq T$ and thus $\left\{ S_T \geq K \right\} \subseteq \left\{ \nu \leq T \right\}$. Consequently, we can skip the second indicator and your payoff is just
\begin{equation}
V_T = \mathrm{1} \left\{ S_T > K \right\}.
\end{equation}
I.e. the price of an up-and-in binary call option is the same of that of a normal binary call option. You thus have the standard result that
\begin{equation}
V_0 = e^{-r T} \mathcal{N} \left( d_- \right),
\end{equation}
where
\begin{equation}
d_- = \frac{1}{\sigma \sqrt{T}} \left( \ln \left( \frac{S_0}{K} \right) + \left( r - \frac{1}{2} \sigma^2 \right) T \right).
\end{equation}
Down-and-Out Binary Call
A more interesting case is the down-and-out binary call. This is how I initially understood your question. Now let
\begin{equation}
\nu = \inf \left\{ t \in \mathbb{R}_+ : S_t \leq K \right\}
\end{equation}
and
\begin{equation}
V_T = \mathrm{1} \left\{ S_T \geq K \right\} \mathrm{1} \left\{ \nu > T \right\}.
\end{equation}
This option knocks out, should the spot price breach the barrier before maturity. Otherwise it has a digital payoff of one.
Let $\tau = T - t$ be the time-to-maturity. The valuation function $\tilde{V}(S, \tau)$ of this option satisfies the initial boundary value problem
\begin{eqnarray}
\mathcal{L} \left\{ \tilde{V} \right\} (S, \tau) & = & 0 \qquad (S, \tau) \in \mathcal{D},\\
\tilde{V}(K, \tau) & = & 0, \qquad \forall \tau \in \mathbb{R}_+\\
\tilde{V}(S, 0) & = & \mathrm{1} \{ S \geq K \},
\end{eqnarray}
where $\mathcal{L}$ is the Black/Scholes forward operator and $\mathcal{D} = \left\{ (S, \tau): S > K, \tau \in \mathbb{R}_+ \right\}$. Using the method of images, see e.g. Buchen (2001), the solution can be shown to be
\begin{equation}
\tilde{V}(S, \tau) = \mathcal{B}_K^+(S, \tau) - \stackrel{K}{\mathcal{I}} \left\{ \mathcal{B}_K^+(S, \tau) \right\},
\end{equation}
where
\begin{eqnarray}
\mathcal{B}_K^+ (S, \tau) & = & e^{-r \tau} \mathcal{N} \left( d_- \right),\\
d_- & = & \frac{1}{\sigma \sqrt{\tau}} \left( \ln \left( \frac{S}{K} \right) + \left( r - \frac{1}{2} \sigma^2 \right) \tau \right),\\
\stackrel{K}{\mathcal{I}} \left\{ \mathcal{B}_K^+ (S, \tau) \right\} & = & \left( \frac{S}{K} \right)^{2 \alpha} \mathcal{B}_K^+ \left( \frac{K^2}{S}, \tau \right),\\
\alpha & = & \frac{1}{2} - \frac{r}{\sigma^2}.
\end{eqnarray}
References
Buchen, Peter W. (2001) "Image Options and the Road to Barriers," Risk Magazine, Vol. 14, No. 9, pp. 127-130