题目预览
Assume ownership
分析
题目合约:
pragma solidity ^0.4.21;
contract AssumeOwnershipChallenge {
address owner;
bool public isComplete;
function AssumeOwmershipChallenge() public {
owner = msg.sender;
}
function authenticate() public {
require(msg.sender == owner);
isComplete = true;
}
}
合约很短,需要我们成为owner,但是owner在合约里面看上去只有一个地方发生了改变,一眼看过去好像是构造函数,但细心一点就能发现,有一个字母的错误,所以我们可以任意调用这个函数改变owner。
攻击
部署合约,分别调用两个函数,即可完成攻击
Token bank
分析
题目合约:
pragma solidity ^0.4.21;
interface ITokenReceiver {
function tokenFallback(address from, uint256 value, bytes data) external;
}
contract SimpleERC223Token {
// Track how many tokens are owned by each address.
mapping (address => uint256) public balanceOf;
string public name = "Simple ERC223 Token";
string public symbol = "SET";
uint8 public decimals = 18;
uint256 public totalSupply = 1000000 * (uint256(10) ** decimals);
event Transfer(address indexed from, address indexed to, uint256 value);
function SimpleERC223Token() public