Level 1
Noob Hacker
Ethernaut 20
Alien Codex
0 / 100 EXP
100 EXP to Junior Hacker
0%
Unlocked hints
Alien Codex
0/3
Unlock a hint to view it here.
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
contract Ownable {
address public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
}
/// @notice Adapted from OpenZeppelin Ethernaut level 19. Solidity 0.5 is
/// intentional: decrementing an empty dynamic array has no checked arithmetic.
contract AlienCodex is Ownable {
bool public contact;
bytes32[] public codex;
modifier contacted() {
assert(contact);
_;
}
function makeContact() public {
contact = true;
}
function record(bytes32 content) public contacted {
codex.push(content);
}
function retract() public contacted {
codex.length--;
}
function revise(uint256 index, bytes32 content) public contacted {
codex[index] = content;
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.16;
interface AlienVm {
function addr(uint256 privateKey) external returns (address);
function startBroadcast(uint256 privateKey) external;
function stopBroadcast() external;
}
contract AlienScript {
AlienVm internal constant vm = AlienVm(address(uint160(uint256(keccak256("hevm cheat code")))));
uint256 internal constant PLAYER_PRIVATE_KEY = 1;
address internal constant PLAYER_ADDRESS = 0x7E5F4552091A69125d5DfCb7b8C2659029395Bdf;
}
Starter exploit
Exploit.s.sol
// TODO: implement the exploit.
function run() external {
vm.startBroadcast(PLAYER_PRIVATE_KEY);
vm.stopBroadcast();
}
Ready to test your exploit?
The starter code is yours to inspect. Sign in to edit it, run Foundry, and keep every clear.
Contract line
Add audit note
0 / 300
CTF tour
Exploit Challenge
This is your guided Solidity CTF workspace.
Keep your audit trail
Sign in to save private notes on contract lines and continue your review later.
Delete this audit note?
This removes it permanently from your private workspace.
