Hamlet got exactly what he wanted, to expose and kill Claudius. Claudius had a plan to have Laertes stab Hamlet with the poisoned rapier. But Hamlet realized that Laertes was working for Claudius. Just then, Laertes started trying to stab him. Hamlet ended up with the poisoned rapier and stuck Laertes with it.
The Ghost got his revenge through Hamlet, after Hamlets mother drank the poisoned wine. Hamlet realized that the poisoned cup was for him. This