Ethernaut King

Breaking the Game

This next challenge intends to simulate a game. It keeps track of a King and a Prize, where for each ether transfer made to the contract, if the transfer is bigger than the prize, the sender will be promoted to King.

The purpose is to find a way to break it, by becoming promoted to King forever, where no one could overthrow us.

Refer below for the challenge code:

A Quick Recap

In Ethereum there are two kind of addresses, an Externally Owned Accounts (EOAs) or Contract Addresses.

When an EOA receives money, the ledger is then updated with the new balance of the account, and that is the most of what we can expect from EOAs: to send and receive ether or to trigger contract’s functions. However, Contract Addresses contain bytecode that can be run when a transaction is received (we have seen examples on earlier posts with the use of the fallback() and receive() functions).

Exploitation Steps

--

--

Diogo Pereira | diogo-pereira.com

I help organisations build cyber-resilient applications, bring security awareness and mindset growth tips to interested individuals