-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathRecovery.t.sol
40 lines (34 loc) · 1.03 KB
/
Recovery.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Test, console} from "../lib/forge-std/src/Test.sol";
import {Recovery} from "../src/Recovery.sol";
contract RecoveryTest is Test {
Recovery target;
RecoveryHacker hackTarget;
function setUp() public {
target = new Recovery();
hackTarget = new RecoveryHacker();
}
function test_RecoveryToReceiveEther() public {
address lostcontract = hackTarget.hack(address(target));
assert(lostcontract != address(0));
}
}
contract RecoveryHacker {
function hack(address target) public pure returns (address lostcontract) {
lostcontract = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
bytes1(0xd6),
bytes1(0x94),
address(target),
bytes1(0x01)
)
)
)
)
);
}
}