You can see in Elliott Mendelson, Introduction to Mathematical Logic (4th ed - 1997), page 38, the Lemma 1.11.c [see page 39 for the derivation] :
$\vdash \lnot \mathcal B \rightarrow (\mathcal B \rightarrow \mathcal C)$.
It is the "basic building block" for proving in an Hilbert-style proof system (axioms + modus ponens) the Ex Falso Quodlibet.
In Natural Deduction, you can use the so-called $\lnot$-elimination rule (from $A$ and $\lnot A$, infer $\bot$, i.e. the falsum) followed by the Abs-rule (from $\bot$, infer $B$ whatever) to derive from a contradiction a formula wathever [you can see the discussion about the DN rules involving $\lnot$ and $\bot$ in this post].
Note.
This is Mendelson's axiom system :
(A1) $\mathcal{B} \rightarrow ( \mathcal{C} \rightarrow \mathcal{B})$
(A2) $(\mathcal{B} \rightarrow ( \mathcal{C} \rightarrow \mathcal{D})) \rightarrow ((\mathcal{B} \rightarrow \mathcal{C}) \rightarrow (\mathcal{B} \rightarrow \mathcal{D}))$
(A3) $(\lnot \mathcal{C} \rightarrow \lnot \mathcal{B}) \rightarrow ((\lnot \mathcal{C} \rightarrow \mathcal{B}) \rightarrow \mathcal{C})$.
With (A1) and (A2) he proves Lemma 1.8 [page 36] :
$\vdash \mathcal{B} \rightarrow \mathcal{B}$.
With the help of Lemma 1.8 and using only (A1) and (A2) it is possible to prove the Deduction Theorem [Prop 1.9, page 37]:
if $\Gamma, \mathcal{B} \vdash \mathcal{C}$, then $\Gamma \vdash \mathcal{B} \rightarrow \mathcal{C}$.
Finally, Mendelson proves Lemma 1.11.c :
$\vdash \lnot \mathcal B \rightarrow (\mathcal B \rightarrow \mathcal C)$.
Without DT we may still have ex falso quodlibet as a "derived rule" :
(1) $\quad \lnot \mathcal B$ --- assumed
(2) $\quad \mathcal B$ --- assumed
(3) $\quad \vdash \mathcal B \rightarrow ( \lnot \mathcal C \rightarrow \mathcal B )$ --- (A1)
(4) $\quad \vdash \mathcal{\lnot B} \rightarrow ( \mathcal{\lnot C} \rightarrow \mathcal{\lnot B})$ --- (A1)
(5) $\quad \mathcal{\lnot C} \rightarrow \mathcal B$ --- from (2) and (3) by modus ponens
(6) $\quad \mathcal{\lnot C} \rightarrow \mathcal{\lnot B}$ --- from (1) and (4) by modus ponens
(7) $\quad \vdash (\lnot \mathcal{C} \rightarrow \lnot \mathcal{B}) \rightarrow ((\lnot \mathcal{C} \rightarrow \mathcal{B}) \rightarrow \mathcal{C})$ --- (A3)
(8) $\quad \mathcal{C}$ --- from (5), (6) and (7) by modus ponens twice.
Thus :
$\quad \lnot \mathcal B, \mathcal B \vdash \mathcal C$.
In Mendelson's system, $\land$ and $\lor$ are not primitive; they are defined as :
$p \land q =_{def} \lnot (p \rightarrow \lnot q)$
$p \lor q =_{def} \lnot p \rightarrow q$
Having the Deduction Theorem, Mendelson proves a couple of other useful results [see Corollary 1.10, page 38] and then Lemma 1.11 including :
$\vdash \lnot \lnot \mathcal B \rightarrow \mathcal B$ --- Lemma 1.11.a
and
$\vdash \mathcal B \rightarrow \lnot \lnot \mathcal B$ --- Lemma 1.11.b.
Now we have :
(a)$\quad \vdash \mathcal B \rightarrow \lnot \lnot \mathcal B$ --- Lemma 1.11.b
(b)$\quad \vdash \lnot \lnot (\mathcal B \rightarrow \lnot \lnot \mathcal B)$ --- from Lemma 1.11.b "applied to itself" by modus ponens
(c)$\quad \vdash \lnot (\mathcal B \land \lnot \mathcal B)$ --- with definition of $\land$
(d)$\quad \vdash \lnot (\mathcal B \land \lnot \mathcal B) \rightarrow ((\mathcal B \land \lnot \mathcal B) \rightarrow \mathcal C)$ --- Lemma 1.11c with the substitution of $(\mathcal B \land \lnot \mathcal B)$ in place of $\mathcal B$.
Thus :
$\vdash \mathcal B \land \lnot \mathcal B \rightarrow \mathcal C$ --- from (c) and (d) by modus ponens.
Further reading.
You can usefully see the note by Peter Smith on Types of proof system in his Logic Matters blog.