Skip to content

Instantly share code, notes, and snippets.

@devonwesley
Created July 16, 2018 10:50
Show Gist options
  • Save devonwesley/66c7cf9358d6d653fc4bd532e7c9e9c4 to your computer and use it in GitHub Desktop.
Save devonwesley/66c7cf9358d6d653fc4bd532e7c9e9c4 to your computer and use it in GitHub Desktop.
`./geth --preload "/Users/you/here/reentrancy_attack/scripts/scenario.js" attach ipc:newdata/geth.ipc`
var VictimContract = eth.contract([
{
"constant": false,
"inputs": [],
"name": "withdraw",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "deposit",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
}
]);
var Victim = VictimContract.at('0xed1f0ae556562f41e4f689fae1abeefd9426fc34');
var AttackerContract = eth.contract([
{
"constant": true,
"inputs": [],
"name": "count",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "victim",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "c",
"type": "uint256"
},
{
"indexed": false,
"name": "balance",
"type": "uint256"
}
],
"name": "LogFallback",
"type": "event"
},
{
"constant": false,
"inputs": [],
"name": "attack",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]);
var Attacker = AttackerContract.at('0xbf3615b919cc305f2a69fb874148d0804dfdc087');
getBalance = eth.getBalance;
function balanceInEth(address) {
return web3.fromWei(getBalance(address).toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment