Skip to content

Instantly share code, notes, and snippets.

@dionyziz
Created March 27, 2020 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dionyziz/c4bb728ccae98fcf043b61548cc8359a to your computer and use it in GitHub Desktop.
Save dionyziz/c4bb728ccae98fcf043b61548cc8359a to your computer and use it in GitHub Desktop.
class Bank {
constructor() {
this.attacker_balance = 1;
}
withdraw() {
if (this.attacker_balance == 1) {
console.log('Sending ' + this.attacker_balance + ' ETH to attacker');
send_money_to_attacker(this.attacker_balance);
}
console.log('Setting balance to 0');
this.attacker_balance = 0;
}
}
let bank = new Bank();
let withdrawals = 0;
function send_money_to_attacker(money) {
console.log('Got ' + money + ' ETH');
++withdrawals;
if (withdrawals < 10) {
bank.withdraw();
}
}
bank.withdraw();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment