Smart contract hacks (Re-entrance, Arithmetic overflow and underflow, Accessing private data)

Procedure

Overflow & Underflow

Choose overflow and underflow from the following options.

overflow-underflow

Enter the value for Uint8.

overflow-underflow

Enter a value greater than 255.

overflow-underflow

Click on the help button to see the explanation.

overflow-underflow

Click on the underflow button.

overflow-underflow

Enter a value for Uint8.

overflow-underflow

Enter a value less than 0.

overflow-underflow

Click on the help button to see the explanation.

Re-entrancy

Click on the attack button and observe the changes happening carefully.

re-entrancy

Step 1: The attack() function deposits 1 ETH into the Bank contract.

re-entrancy

Step 2: The attack() function deposits 1 ETH into the Bank contract.

re-entrancy

Step 3: Since the balance of msg.sender (the Attack contract's address) is greater than 0, an external contract is called to send the value.

re-entrancy

Step 4: When the Attack contract receives ETH from the Bank contract, the fallback() function is called. First, it checks the balance in the Bank contract, then it calls the withdraw() function in the Bank contract again.

re-entrancy

Step 5: The line balances[msg.sender] = 0 is not reached because msg.sender.call has not finished yet. This continues until all the funds in the Bank contract are drained.

re-entrancy