ElGamal with weak public key
Can you confirm whether this attack will work


It depends on a situation which is mind boggingly unlikely to happen, but if it is does happen, yes, it will work.

We'll have $\beta = p - 1$ iff $d$ just happens to be the value $(p-1)/2$; this happens with probability $1 / (p-2)$.

For El Gamal to be secure at all, $p$ needs to be large, say, at least 2048 bits.  This means that this has a probability circa $2^{-2048}$ of happening.  We typically don't sit around worrying that we'll be hit by a meteor in the next 10 seconds; that has a much higher probability of happening than us picking the bad $d$.