-
Notifications
You must be signed in to change notification settings - Fork 4
14. GatekeeperTwo
r1oga edited this page Oct 29, 2022
·
1 revision
Make it through the gatekeeper two.
-
gateOne
relies ontx.origin
. - Being able to read the public contract logic teaches how to pass
gateTwo
andgateThree
.
Inline assembly & contract creation/initialization
From the Ethereum yellow paper section 7.1 - subtleties we learn:
while the initialisation code is executing, the newly created address exists but with no intrinsic body code⁴. 4. During initialization code execution, EXTCODESIZE on the address should return zero [...]
-
gateOne
: similar to the gateOne of Level 13 - Gatekeeper One or to the hack of Level 4 - Telephone -
gateTwo
: call theenter
function during contract initialization, i.e from withinconstructor
to ensureEXTCODESIZE = 0
-
gateThree
uint64(bytes8(keccak256(abi.encodePacked(msg.sender)))) ^ uint64(_gateKey)
noteda ^ b
meansa XOR b
.
uint64(0) - 1
: underflow, this is equals touint64(1)
.
So we need to take_gatekey = ~msg.sender
(Bitwise NOT) to ensure that the XOR product of each bit ofa
andb
will be 1.
During contract initialization, the contract has no intrinsic body code and its extcodesize
is 0.