Skip to content

Commit

Permalink
debug: lvl 29
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct committed Oct 7, 2024
1 parent ea30e83 commit 310347a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/EthernautCTF/Switch.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@forge-std/console.sol';

contract Switch {
bool public switchOn; // switch is off
bytes4 public offSelector = bytes4(keccak256('turnSwitchOff()'));
Expand All @@ -17,6 +19,7 @@ contract Switch {
assembly {
calldatacopy(selector, 68, 4) // grab function selector from calldata
}
console.logBytes32(selector[0]);
require(
selector[0] == offSelector,
'Can only call the turnOffSwitch function'
Expand All @@ -25,6 +28,7 @@ contract Switch {
}

function flipSwitch(bytes memory _data) public onlyOff {
console.logBytes(_data);
(bool success, ) = address(this).call(_data);
require(success, 'call failed :(');
}
Expand Down

0 comments on commit 310347a

Please sign in to comment.