6. When four dice are rolled randomly, the probability that the product of the four numbers obtained is a perfect square is $\qquad$ .


6. $\frac{25}{162}$.

Obviously, the number of 5s in four rolls must be even.
If all four rolls are 5, then their product is clearly a perfect square, and there is only 1 such case.

Below, we use a recursive method to consider the cases where there are exactly 0 or 2 fives in four rolls.

Let $a_{n}$ be the number of ways to select $n$ numbers from $\{1,2,3,4,6\}$ with repetition, such that the product of these numbers is a perfect square.
Notice that $a_{1}=2$.
For $n \in \mathbf{Z}_{+}$, consider the number of ways to select $n+1$ numbers such that their product is a perfect square. If the product of the first $n$ numbers is a perfect square, then the $(n+1)$-th number can only be 1 or 4, giving $2 a_{n}$ ways; if the product of the first $n$ numbers is not a perfect square, then the $(n+1)$-th number must be one of 2, 3, or 6, giving $5^{n}-a_{n}$ ways.
Thus, $a_{n+1}=2 a_{n}+\left(5^{n}-a_{n}\right)$
$=a_{n}+5^{n}\left(n \in \mathbf{Z}_{+}\right)$.
From this, we can recursively obtain
$$
a_{2}=7, a_{3}=32, a_{4}=157 \text {. }
$$

For the case where there are exactly 2 fives in four rolls, there are $\mathrm{C}_{4}^{2} \times 6$ ways to determine the positions of the fives.
Therefore, the required probability is
$$
\frac{1+6 \times 7+157}{6^{4}}=\frac{200}{1296}=\frac{25}{162} .
$$