Created
July 21, 2018 18:33
-
-
Save vasa-develop/b8f734a09b48c4b3133ebf6c1875983d to your computer and use it in GitHub Desktop.
DO NOT USE THIS CODE. THIS CODE IS USED TO DEMONSTRATE A VULNERABILITY IN A SOLIDITY CODE.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract FibonacciBalance { | |
address public fibonacciLibrary; | |
// the current fibonacci number to withdraw | |
uint public calculatedFibNumber; | |
// the starting fibonacci sequence number | |
uint public start = 3; | |
uint public withdrawalCounter; | |
// the fibonancci function selector | |
bytes4 constant fibSig = bytes4(sha3("setFibonacci(uint256)")); | |
// constructor - loads the contract with ether | |
constructor(address _fibonacciLibrary) public payable { | |
fibonacciLibrary = _fibonacciLibrary; | |
} | |
function withdraw() { | |
withdrawalCounter += 1; | |
// calculate the fibonacci number for the current withdrawal user | |
// this sets calculatedFibNumber | |
require(fibonacciLibrary.delegatecall(fibSig, withdrawalCounter)); | |
msg.sender.transfer(calculatedFibNumber * 1 ether); | |
} | |
// allow users to call fibonacci library functions | |
function() public { | |
require(fibonacciLibrary.delegatecall(msg.data)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment