Last active
July 21, 2018 18:44
-
-
Save vasa-develop/bb7d843f84dae36968196f3a9594b71b 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
pragma solidity ^0.4.19; | |
contract Private_Bank | |
{ | |
mapping (address => uint) public balances; | |
uint public MinDeposit = 1 ether; | |
Log TransferLog; | |
function Private_Bank(address _log) | |
{ | |
TransferLog = Log(_log); | |
} | |
function Deposit() | |
public | |
payable | |
{ | |
if(msg.value >= MinDeposit) | |
{ | |
balances[msg.sender]+=msg.value; | |
TransferLog.AddMessage(msg.sender,msg.value,"Deposit"); | |
} | |
} | |
function CashOut(uint _am) | |
{ | |
if(_am<=balances[msg.sender]) | |
{ | |
if(msg.sender.call.value(_am)()) | |
{ | |
balances[msg.sender]-=_am; | |
TransferLog.AddMessage(msg.sender,_am,"CashOut"); | |
} | |
} | |
} | |
function() public payable{} | |
} | |
contract Log | |
{ | |
struct Message | |
{ | |
address Sender; | |
string Data; | |
uint Val; | |
uint Time; | |
} | |
Message[] public History; | |
Message LastMsg; | |
function AddMessage(address _adr,uint _val,string _data) | |
public | |
{ | |
LastMsg.Sender = _adr; | |
LastMsg.Time = now; | |
LastMsg.Val = _val; | |
LastMsg.Data = _data; | |
History.push(LastMsg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment