Giter Site home page Giter Site logo

ethernaut_all_-spoil-'s Introduction

English README  Jump to Japanese Version

Ethernaut Solutions

  • The Ethernaut is a Web3/Solidity-based coding wargame, played in the Ethereum Virtual Machine.
  • Each level is a smart contract that needs to be 'hacked'.

Here are the writeups of my solutions levels I cleared. ** I will not recommend you to look at solutions I wrote. Solve it yourself for your learning 😛 **

How to use Ethernaut

  • To use ethernaut, you need to use the console from the developper tool of your browser in the first place.
  • If your confortable with Foundry and Methods call using cast and send, you can also solve problem from Foundry framework.
  • If you are not confortable yet with ABI, then it is a great way to learn about it and how to call any contract by external calls.
  • In higher difficulty levels, you will need to wrote smart contracts and interfaces to hack some smart contract externally for clearing levels.

Ethernaut 0. Hello Ethernaut


Ethernaut Hello


Introductory level.

Link to the repository: Here.


Ethernaut 1. Fallback


Ethernaut Fallback


The goal is to become the Owner of the smart contract to be able to steal all the funds in it.

Link to the repository: Here.


Ethernaut 2. Fallout


Ethernaut Fallout


The goal is to become the Owner of the smart contract.

  • The best hint is in the presentation image of the problem.

    Link to the repository: Here.


Ethernaut 3. Coinflip


Ethernaut coinflip


The goal is to guess 10 times the right side on which the coin is gonna flip when calling the flip() function.

Link to the repository: Here.


Ethernaut 4. Telephone


Ethernaut Telephone


The goal is to become the Owner of the smart contract.

  • In the Telephone smart contract, there is a logic that if transaction made that is not from tx.origin we can become the owner.
  • It is a problem to show what to use when it comes to the transaction origine. tx.origin or msg.sender .
  • The tx.origin global variable refers to the original external account that started the transaction while msg.sender is a direct transaction from an user.

    Link to the repository: Here.


Ethernaut 5. Token


Ethernaut Token


The goal is to get all ERC20 Tokens of the contract transfered to our balance

  • The trick in that contract is that it is done under Solidity 0.6.0. under 0.8.0 we need to use a library called SafeMath for dealing with numbers.
  • Without SafeMath all solidity contracts with a compiler version under 0.8.0 have an underflow and overflow problem.
  • Example: We have an integer of type uint with value of 20. Let say we do 20 + 1, we don't get 21. Instead we get 1 by going over 21. Which is the UintMax in this case.
  • Meaning we can have all tokens of the total supply.
  • SafeMath was used to prevent this problem. Since 0.8.0 it is integrated into solidity by default. Link to the repository: Here.


Ethernaut 8. Vault


Ethernaut Vault


The goal is to unlock the contract by finding the Bytes32 password.

  • The solution here is to find the value of the private variable

    Link to the repository: Here.


Ethernaut 9. King


Ethernaut King


The goal is to take control of the contract.

  • The solution here is to send an amount of ether superior to the prize to the contract. Here is an easy explanation:
  • To do so we can only use the call function.
  • transfer and send can not be used as when calling the receive function of the contract, it will revert the transaction due to the gas cap of 2300.
  • call function does not have this gas cap and can be used to send ether to the contract. Link to the repository: Here.


Ethernaut 10. Re-Entrancy


Ethernaut King


The goal is to empty the contract of its funds.

  • What is going to happen, we need to call donate to set a value to the balance of contract used for the attack.
  • Then call withdraw to empty the contract. Since the state changes happen later on, the receive function will be called and the attack will be repeated until the attacked contract balance is less than 0.001eth. Link to the repository: Here.


日本語版の README

Ethernaut の解決策

  • Ethernaut は、Web3/Solidity ベースのコーディングウォーゲームで、Ethereum Virtual Machine (EVM) でプレイされます。
  • 各レベルはハッキングする必要があるスマートコントラクトです。

これはクリアしたレベルの解決策です。 **解決策を見ることをお勧めしません。学習のために自分で解決してください 😛 **

Ethernaut の使用方法

  • Ethernaut を使用するには、まずブラウザの開発者ツールからコンソールを使用する必要があります。
  • Foundry と cast および send を使用した方法の呼び出しに慣れている場合、Foundry フレームワークから問題を解決することもできます。
  • まだ ABI に慣れていない場合、それを使用して任意のコントラクトを外部呼び出しで呼び出す方法について学び、理解するのに最適な方法です。
  • より高難度のレベルでは、スマートコントラクトとインターフェースを作成して、いくつかのスマートコントラクトを外部からハッキングするために解レベルをクリアする必要があります。

Ethernaut 0. Hello Ethernaut


Ethernaut Hello


これは導入的なレベルである。

レポジトリーへのリンクは: こちら


Ethernaut 0. Fallback


Ethernaut Hello


目標は、そのスマートコントラクトのオーナーになり、中にあるすべての資金を奪うことです。

レポジトリーへのリンクは: こちら


Ethernaut 2. Fallout


Ethernaut Fallback


  • 目標は、スマートコントラクトの所有者になることです。
    最も役立つヒントは、問題のプレゼンテーション画像にあります。

レポジトリーへのリンクは: こちら


Ethernaut 3. Coinflip


Ethernaut coinflip


  • 目標は、flip() 関数を呼び出すときに、コインがどの側に反転するかを 10 回正しく予想することです。

レポジトリーへのリンクは: こちら


Ethernaut 4. Telephone


Ethernaut Telephone


目標は、スマートコントラクトの所有者になることです。

  • Telephoneスマートコントラクトでは、tx.origin からのトランザクションでない場合、オーナーになる仕組みがあります。
  • トランザクションの発生元を示すときに、tx.origin または msg.sender を使用するかどうかは問題です。
  • tx.origin 変数は、トランザクションを開始した元の外部アカウントを参照しますが、msg.sender はユーザーから直接のトランザクションです。

    レポジトリーへのリンクは: こちら


Ethernaut 5. Token


Ethernaut Token


目標は、コントラクトのすべての ERC20 トークンを手に入れることです。

  • このコントラクトのミソは、Solidity 0.6.0 の下で行われたことです。0.8.0 では、数値の処理に SafeMath と呼ばれるライブラリを使用する必要があります。
  • SafeMath がない場合、コンパイラバージョンが 0.8.0 未満のすべての Solidity コントラクトにはアンダーフローオーバーフローの問題があります。
  • 例:uint 型の整数で値が 20 の場合、20 + 1 を行ったとしましょう。結果は21 ではなく、21 を超えて 1 を得ます。これはこの場合の UintMax です。
  • つまり、合計供給量のすべてのトークンを持っている可能性があります。
  • この問題を防ぐために SafeMath が使用されました。0.8.0 以降、Solidity にはデフォルトで組み込まれています。

レポジトリーへのリンクは: こちら


Ethernaut 8. Vault


Ethernaut Vault


コントラクトを解除する目的は、Bytes32 パスワードを見つけることです。

  • ここでの解決策は、private 変数 password の値を見つけることです。

    レポジトリーへのリンクは: こちら.


Ethernaut 9. King


Ethernaut King


コントラクトの管理権を握ることが目標です。

  • ここでの解決策は、賞金よりも多いエーテルをコントラクトに送ることです。簡単な説明は以下の通りです:

  • これを行うには、call関数のみを使用できます。

  • transfersendは使用できません。コントラクトのreceive関数を呼び出すと、2300 のガス上限のためにトランザクションがリバートされるからです。

  • call関数にはこのガス上限がなく、エーテルをコントラクトに送るために使用できます。

    レポジトリーへのリンクは: こちら.


Ethernaut 10. Re-Entrancy


Ethernaut King


目標は、契約の資金を空にすることです。

    • 何が起こるかというと、攻撃に使用される契約の残高にvalueを設定するためにdonateを呼び出す必要があります。
  • その後、withdrawを呼び出して契約の中身を空にします。状態の変更が後で起こるため、receive関数が呼び出され、攻撃された契約の残高が0.001eth未満になるまで攻撃が繰り返されます。

    レポジトリーへのリンクは: こちら.


ethernaut_all_-spoil-'s People

Contributors

jer-b avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.