-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbasic_hard.sol
More file actions
68 lines (59 loc) · 1.5 KB
/
basic_hard.sol
File metadata and controls
68 lines (59 loc) · 1.5 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
pragma solidity 0.7.6;
interface IFoobar {
function lol() external view returns (uint256);
}
contract basic_hard {
uint256 state = 0;
bool sub1 = false;
bool sub2 = false;
bool[2] sub3;
constructor() payable {}
function addnflip(bool b) internal returns (bool) {
if (b) {
state -= 1;
} else {
state += 1;
}
return !b;
}
// inspired by https://github.com/crytic/echidna/blob/master/examples/solidity/coverage/single.sol
function first(
uint256 x,
uint256 y,
uint256 z
) public {
require(x == 42424242);
require(y == 8);
require(z == 123);
sub1 = addnflip(sub1);
}
function second() public payable {
require(msg.value > 0);
if (msg.value == 10000) {
sub2 = addnflip(sub2);
} else {
state -= 1;
}
}
// symex killer; lol
function third(IFoobar[] calldata bars) public {
for (uint256 i = 0; i < bars.length; i++) {
if (bars[i].lol() == 1337) {
if (i < sub3.length) {
sub3[i] = addnflip(sub3[i]);
} else {
state -= 1;
}
} else {
state -= 1;
}
}
}
function echidna_state() public view returns (bool) {
return state != 4;
}
function ether_oracle() public {
require(state == 4);
selfdestruct(msg.sender);
}
}