You don't use a pre-generated list of primes. That would make it easy to crack as you note. The algorithm you want to use would be something like this (see note 4.51 in HAC, see also an answer on crypto.SE):
- Generate a random $512$ bit odd number, say $p$
- Test to see if $p$ is prime; if it is, return $p$; this is expected to occur after testing about $Log(p)/2 \sim 177$ candidates
- Otherwise set $p = p+2$, goto 2
There are other methods to generate primes (e.g., do step 1, if step 2 fails goto step 1). The method I outlined is what OpenSSL uses though.
For an official, public standard on RSA key generation, see FIPS 186-4, section 5.1 and Appendix B.3.1.