Skip to content

Instantly share code, notes, and snippets.

@muellerberndt
Created March 12, 2020 12:50
Show Gist options
  • Select an option

  • Save muellerberndt/fda8f3817d382615068760219f9c9934 to your computer and use it in GitHub Desktop.

Select an option

Save muellerberndt/fda8f3817d382615068760219f9c9934 to your computer and use it in GitHub Desktop.
pragma solidity ^0.5.0;
contract Vulnerable2Calls {
address public owner;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
constructor() public {
owner = msg.sender;
}
function _transferOwnership(address _owner) public {
owner = _owner;
}
function kill() public onlyOwner {
selfdestruct(msg.sender);
}
}
contract Vulnerable4Calls {
address public owner;
bool locked;
uint256 public maybePrime = 973013;
modifier onlyOwner {
require(msg.sender == owner);
_;
}
modifier only_uninitialized {
require(owner == address(0));
_;
}
constructor() public {
_init(msg.sender);
locked = true;
}
function _init(address _owner) public only_uninitialized {
owner = _owner;
}
function reset() public {
owner = address(0);
}
function unlock(uint256 x, uint256 y) public {
require(x > 1 && x < maybePrime);
require(y > 1 && y < maybePrime);
require(x*y != maybePrime);
locked = false;
}
function kill() public onlyOwner {
require(!locked);
selfdestruct(msg.sender);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment