forked from SunWeb3Sec/DeFiVulnLabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisibility.sol
More file actions
30 lines (23 loc) · 736 Bytes
/
Copy pathVisibility.sol
File metadata and controls
30 lines (23 loc) · 736 Bytes
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
import "forge-std/Test.sol";
contract ContractTest is Test {
ownerGame ownerGameContract;
function testVisibility() public {
ownerGameContract = new ownerGame();
console.log("Before exploiting, owner of ownerGame:",ownerGameContract.owner());
ownerGameContract.changeOwner(msg.sender);
console.log("After exploiting, owner of ownerGame:",ownerGameContract.owner());
console.log("Exploit completed");
}
receive() payable external{}
}
contract ownerGame{
address public owner;
constructor() {
owner = msg.sender;
}
function changeOwner(address _new) public { //vulnerable point
owner = _new;
}
}