Generalized beam-splitting attack in quantum cryptography with dim coherent states