DEV Community

Cover image for Ethernaut Hacks Level 0: Hello Ethernaut
Naveen ⚡
Naveen ⚡

Posted on • Updated on

Ethernaut Hacks Level 0: Hello Ethernaut

This is the level 0 of Ethernaut game.

Pre-requisites

Hack

I assume you've read instructions of the level 0 and acquired test ether. The level contract methods are injected right into our browser console, so we can start calling methods.

Let's start.
The instructions asks to call this method in console:

await contract.info()

// Output: 'You will find what you need in info1().'
Enter fullscreen mode Exit fullscreen mode

We follow the output and call:

await contract.info1()

// Output: 'Try info2(), but with "hello" as a parameter.'
Enter fullscreen mode Exit fullscreen mode

Following...

await contract.info2("hello")

// Output: 'The property infoNum holds the number of the next info method to call.'
Enter fullscreen mode Exit fullscreen mode

To get infoNum we call it's public getter:

await contract.infoNum().then(v => v.toString())

// Output: 42
Enter fullscreen mode Exit fullscreen mode

Note that infoNum() returns a BigNumber object so we convert it to string to see actual number.

Proceeding with info42:

await contract.info42()

// Output: 'theMethodName is the name of the next method.'
Enter fullscreen mode Exit fullscreen mode

Again, following output:

await contract.theMethodName()

// Output: 'The method name is method7123949.'
Enter fullscreen mode Exit fullscreen mode

And so:

await contract.method7123949()

// Output: 'If you know the password, submit it to authenticate().'
Enter fullscreen mode Exit fullscreen mode

Ok...but what's the password? Let's inspect the contracts ABI:

contract

// Output: { abi: ..., address: ..., ...., password: f () }
Enter fullscreen mode Exit fullscreen mode

Upon inspecting we see there's a password method for contract. Let's call it:

await contract.password()

// Output: 'ethernaut0`
Enter fullscreen mode Exit fullscreen mode

We got the password. Finally:

await contract.authenticate('ethernaut0')
Enter fullscreen mode Exit fullscreen mode

and confirm the transaction on metamask. Submit instance.

Level completed!

Learned something awesome? Consider starring the repo here 😄

and following me on twitter here 🙏

Top comments (0)