The Zeppelin Ethernaut CTF series (FallOut)
Challenge number 2 is quiet easy.
In it, we are given a contract and we have to claim its ownership.
Here is the contract in question:
pragma solidity ^0.4.18;
import 'zeppelin-solidity/contracts/ownership/Ownable.sol';
contract Fallout is Ownable {
mapping (address => uint) allocations;
/* constructor */
function Fal1out() public payable {
owner = msg.sender;
allocations[owner] = msg.value;
}
function allocate() public payable {
allocations[msg.sender] += msg.value;
}
function sendAllocation(address allocator) public {
require(allocations[allocator] > 0);
allocator.transfer(allocations[allocator]);
}
function collectAllocations() public onlyOwner {
msg.sender.transfer(this.balance);
}
function allocatorBalance(address allocator) public view returns (uint) {
return allocations[allocator];
}
}
In Solidity, the first function that has the same name as the contract name is called the constructor and is called once when the contract is deployed.
If we look closely we can see that the contract name - Fallout - and the constructor - Fal1out - are written differently. That means Fal1out is not a constructor and can thus be called:
contract.Fal1out()
wait for the transaction to be sent and mined, which gets us here:
Congratulations @ksloven! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!