Splendor White's blog

归档 · 2023

首页

关于

归档

Ethernaut 闯关笔记 第12关 Elevator

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface Building { function isLastFloor(uint) external returns (bool); } contract Elevator { bool public top; uint public floor; function goTo(uint _floor) public { Building building = Building(msg.sender); if (! building.isLastFloor(_floor)) { ..

更多

Solidity 1.0.0 ——下一代智能合约语言中激动人心的改进

导论 在广泛分析诸如 Solidity Github 仓库、 Solidity 发展路线图、 Twitter 上的社群对话、活跃的 Pull Requests 和 Issues 等信息后,本文深入探讨了 Solidity 的未来将会走向何方。 这门领先的智能合约编程语言即将发布 0.9.0 和 1.0.0 升级,其中将推出几项备受期待的增强功能。 本文旨在向读者介绍Solidity的最新发展和改进,这些发展和改进基于社区的投入和正在进行的辩论。虽然提供的相关信息尚无定论,但它揭示了潜在的技术进步方向。 1. 革命性地将 require() 与 Custom Error 进行集成 当前方法(0.8.x): error UnauthorizedAccess(); if (condition) {..

更多

Ethernaut 闯关笔记 第11关 Re-entrancy

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.6.12; import 'openzeppelin-contracts-06/math/SafeMath.sol'; contract Reentrance { using SafeMath for uint256; mapping(address => uint) public balances; function donate(address _to) public payable { balances[_to] = balances[_to].add(msg.value); } fu..

更多

Ethernaut 闯关笔记 第10关 King

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract King { address king; uint public prize; address public owner; constructor() payable { owner = msg.sender; king = msg.sender; prize = msg.value; } receive() external payable { require(msg.value >= prize ..

更多
loading..

Ethernaut 闯关笔记 第9关 Vault

原始代码 攻击思路 1 :反编译并直接读取 storage 合约的 bytecode 为: 0x6080604052348015600f57600080fd5b506004361060325760003560e01c8063cf309012146037578063ec9b5b3a146057575b600080fd5b60005460439060ff1681565b604051901515815260200160405180910390f35b60666062366004607f565b6068565b005b806001541415607c576000805460ff191690555b50565b600060208284031215609057600080fd5b503591905056fea264..

更多

Ethernaut 闯关笔记 第8关 Force

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Force {/* MEOW ? /\_/\ / ____/ o o \ /~____ =ø= / (______)__m_m) */} 攻击思路 因为该合约没有任何 payable 函数,也没有 receive() 函数,因此不能直接发送交易。 强制调用合约代码,可以使用另一个合约的 selfdestruct() 关键字。 每一个合约都可以通过 selfdestruct(address) 关键字实现自毁,并将剩余的 ETH 余额发送到指定的地址。 注意,ERC-..

更多

Ethernaut 闯关笔记 第7关 Delegation

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Delegate { address public owner; constructor(address _owner) { owner = _owner; } function pwn() public { owner = msg.sender; } } contract Delegation { address public owner; Delegate delegate; const..

更多

Ethernaut 闯关笔记 第6关 Token

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; contract Token { mapping(address => uint) balances; uint public totalSupply; constructor(uint _initialSupply) public { balances[msg.sender] = totalSupply = _initialSupply; } function transfer(address _to, uint _value) public returns (bool) {..

更多

Ethernaut 闯关笔记 第5关 Telephone

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Telephone { address public owner; constructor() { owner = msg.sender; } function changeOwner(address _owner) public { if (tx.origin != msg.sender) { owner = _owner; } } } 目标:成为合约 owner 。..

更多

Ethernaut 闯关笔记 第4关 Coin Flip

原始代码 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract CoinFlip { uint256 public consecutiveWins; uint256 lastHash; uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968; constructor() { consecutiveWins = 0; } function flip(bool _guess) public return..

更多
12