Ethernaut Puzzle 02 Fallout

This problem requires us to become the owner of this smart contract.

This may be the easiest problem in this series. All you need is careful observation.

1
2
3
4
5
6
7
8
9
10
11
12
13
contract Fallout {

using SafeMath for uint256;
mapping (address => uint) allocations;
address payable public owner;


/* constructor */
function Fal1out() public payable {
owner = msg.sender;
allocations[owner] = msg.value;
}
}

The constructor function is misspelt… It should be Fallout instead of Fal1out(). See the difference between the number 1 and the letter l.

In this currect situation, anyone can claim the ownership of this smart contract. All we need to do is just invoke Fal1out function then we become the owner of this smart contract. Then this problem is resolved !

By the way, now the correct way of writing the constructor function is just:

1
2
3
4
5
6
contract Fallout {

/* constructor */
constructor() public {
}
}

I would say this way is much safier. Even if you spell wrong, the compiler will definitely raise the error as this function is quite different with other functions. (no functionflag)