题目描述

image.png

解题过程

题目源码

  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.6.0;
  3. import '@openzeppelin/contracts/math/SafeMath.sol';
  4. contract Fallout {
  5. using SafeMath for uint256;
  6. mapping (address => uint) allocations;
  7. address payable public owner;
  8. /* constructor */
  9. function Fal1out() public payable {
  10. owner = msg.sender;
  11. allocations[owner] = msg.value;
  12. }
  13. modifier onlyOwner {
  14. require(
  15. msg.sender == owner,
  16. "caller is not the owner"
  17. );
  18. _;
  19. }
  20. function allocate() public payable {
  21. allocations[msg.sender] = allocations[msg.sender].add(msg.value);
  22. }
  23. function sendAllocation(address payable allocator) public {
  24. require(allocations[allocator] > 0);
  25. allocator.transfer(allocations[allocator]);
  26. }
  27. function collectAllocations() public onlyOwner {
  28. msg.sender.transfer(address(this).balance);
  29. }
  30. function allocatorBalance(address allocator) public view returns (uint) {
  31. return allocations[allocator];
  32. }
  33. }

我们可以注意到构造函数 Fallout 被写成了 Fal1out,导致该函数不是构造函数,可以直接调用获取 owner权限
image.png
调用方法即可获取权限
image.png