Skip to content

02. Fallout

r1oga edited this page Oct 28, 2022 · 1 revision

Target

Claim ownership of the contract.

Weakness

The contract used a syntax deprecated since v 0.5. The function meant to be the constructor isn't one. It can actually be called after contract initialisation. It has a public visibility and can be called by anyone.

Solidity Concept

A constructor is an optional function declared with the constructor keyword which is executed upon contract creation, and where you can run contract initialisation code. Before the constructor code is executed, state variables are initialised to their specified value if you initialise them inline, or zero if you do not. Prior to version 0.4.22, constructors were defined as functions with the same name as the contract. This syntax was deprecated and is not allowed anymore in version 0.5.0.

The Fal1out() function was supposed to be named Fallout() and would have been the contract's constructor as syntax previous version 0.5.

Hack

Call Fal1out().

Takeaways

  • Work with the latest compiler versions which are more secure.
  • Listen to the compiler warnings.
  • Do test driven development to detect typos.
Clone this wiki locally