So, we can check each one of these possible values for the shared secret.
In practice, the number of possible values for the shared secret is too large for scanning over all the possibilities to be practical - there are always easier attacks. And, as you appear to have guessed correctly, recognizing the shared secret based on $g, g^a \bmod p, g^b \bmod p$ is believed to be a hard problem (in fact, we call it the "Decisional Diffie-Hellman problem")
One attack is to take $g$ and $g^a \bmod p$ and attempt to recover $a$ (that is, solve the discrete log problem) - once we have $a$, we can compute $B^a \bmod p$ (which is the shared secret), and that's the shared secret.
The other possible approach is to attack the symmetric side of things - we ignore the DH operation completely, and just do a brute-force attack on the symmetric key. BTW: not knowing the exact plaintext is typically not an issue; even if we don't know what it is exactly, we generally know enough about it to distinguish it from random gibberish (which is what you get when you attempt to decrypt it with the wrong key) - in addition, if you use an AEAD algorithm, the key is used to generate a tag (as well as encrypt), and the tag can also be used to distinguish the correct key (even if the plaintext really is random gibberish).
For both of these attacks, we typically select security parameters (such as the size of $p$ and the size of the symmetric key) to make both these approaches infeasible.