8. In a square $ABCD$ with side length 8, $M$ is the midpoint of side $BC$, and $N$ is a point on side $DA$ such that $DN = 3NA$. If for a constant $m$, there are exactly six different points $P$ on the perimeter of square $ABCD$ such that $\overrightarrow{PM} \cdot \overrightarrow{PN} = m$, then the range of the real number $m$ is ( ).
(A) $(-8,8)$
(B) $(-1,24)$
(C) $(-1,8)$
(D) $(0,8)$
8. C.

As shown in Figure 4, establish a rectangular coordinate system, $A(0,0)$, $M(8,4)$, $N(0,2)$, $P(x, y)$.
From the problem, we have
$$
\begin{array}{l}
\overrightarrow{P M} \cdot \overrightarrow{P N}=(8-x, 4-y) \cdot(-x, 2-y) \\
=x^{2}-8 x+y^{2}-6 y+8=m \\
\Leftrightarrow(x-4)^{2}+(y-3)^{2}=m+17 .
\end{array}
$$

Therefore, the circle with center $(4,3)$ and radius $\sqrt{m+17}$ intersects the four sides of the square at exactly six different points.
From the graph, it is easy to see that
$$
4<\sqrt{m+17}<5 \Rightarrow m \in(-1,8) .
$$