Cryptography plays a crucial role in safeguarding privacy and confidentiality. Therefore, it is imperative to ensure the security and resistance to cryptanalysis of the employed ciphers. In this paper, an innovative approach called three levels multiple particle swarm optimization (TL-MPSO) has been proposed to enhance the traditional particle swarm optimization (PSO) for cryptanalysis of nonlinear stream ciphers through a ciphertext only attack. We focus on the geffe generator system, which relies on a set of linear feedback shift registers (LFSRs) with a nonlinear combining function. TL-MPSO employs a three-levels approach with distinct search strategies. In the first level, known as the discovery level, particles are randomly distributed into equally sized sub-swarms with no communication between particles in different sub-swarms. The primary objective is to thoroughly explore the search space, with communication limited to neighbouring particles within the same sub-swarm. The second level, called the extraction level, is generated artificially by perturbing the best particles from the discovery level. Particles in different sub-swarms communicate in parallel and co-evolve. Finally, the third level, the optimization level, is artificially generated from the previous level, with all sub-swarms merged into a single large swarm. In all levels, an adaptive movement strategy for each particle is established through a new inertia weight updating process, and a dynamic regrouping strategy is applied to enhance the chances of achieving the global best. Evaluation results demonstrate that the proposed system requires only a minimal number of characters and achieves optimal CPU times. Specifically, when attacking Geffe generators with lengths ranging from 15 to 35, the proposed algorithm consistently achieves optimal solutions with just 10 to 50 cipher characters. Our experiments reveal that TL-MPSO is more accurate and faster than traditional PSO, representing an efficient technique compared to existing cryptanalysis methods.