In this paper we show how to simulate attacks on authentication protocols in a realistic environment. The attack on the Needham-Schroeder public key protocol found by Gavin Lowe is run inside a malicious agent communicating with normal agents. The simulator is also able to detect flaws in attacks: a previously unreported error on an attack on the Shamir Rivest Adelman is detected by simulation.