Skip to content

Commit d1a5032

Browse files
committed
Added the following changes on top of OpenZeppelin#193
moved files upgraded solidity levels upgraded contracts corrected the tests changed bytecode decompiler added review comment changes added images
1 parent 682e7aa commit d1a5032

File tree

14 files changed

+34
-170
lines changed

14 files changed

+34
-170
lines changed

client/public/imgs/BigLevel30.svg

Lines changed: 1 addition & 0 deletions
Loading

client/public/imgs/Level30.svg

Lines changed: 1 addition & 0 deletions
Loading

client/src/gamedata/authors.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@
147147
"websites": [
148148
"https://www.linkedin.com/in/kstasi/"
149149
]
150+
},
151+
"AshiqAmien": {
152+
"name": [
153+
"Ashiq Amien"
154+
],
155+
"emails": [
156+
157+
],
158+
"websites": [
159+
"https://github.com/AshiqAmien"
160+
]
150161
}
151162
}
152163
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"I've asked the development team to create and deploy an ERC20 token for me, and this is the source code they've provided. For some reason, the block explorer does not verify the source code. The team has confirmed that it should not be an issue, and everything seems to work just fine anyway."
22

3-
Find the backdoor and complete the level by draining the owner's account.
3+
Find the backdoor and complete the level by draining the owner's account.
4+
5+
Remember how you solved level 0 - Hello Ethernaut.
46

57

68
Things that might help:
7-
* An [EVM bytecode decompiler](https://ropsten.etherscan.io/bytecode-decompiler?a=)
9+
* An [EVM bytecode decompiler](https://goerli.etherscan.io/bytecode-decompiler?a=)
810
* A tool to help encode function parameters, such as [HashEx](https://abi.hashex.org/)
911

1012

client/src/gamedata/gamedata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@
458458
"revealCode": true,
459459
"deployParams": [],
460460
"deployFunds": 0,
461-
"deployId": "23",
461+
"deployId": "30",
462462
"instanceGas": 2000000,
463463
"author": "AshiqAmien"
464464
}
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
pragma solidity ^0.6.0;
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
23

34
import '../levels/SafeToken.sol';
45

56
contract SafeTokenAttack {
6-
77
function openBackdoor(address level) public {
8-
(bool success,) = level.call(hex"31eaf0aa0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000970617373776f7264310000000000000000000000000000000000000000000000");
8+
(bool success,) = level.call(hex"31eaf0aa0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a65746865726e6175743000000000000000000000000000000000000000000000");
99
require(success, "call unsuccessful!");
1010
}
1111

1212
function transferOwnerTokens(address level) public {
1313
SafeToken instance = SafeToken(level);
1414
instance.transfer(address(this),0);
1515
}
16-
17-
18-
19-
2016
}
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
pragma solidity ^0.6.0;
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
23

3-
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
4+
import 'openzeppelin-contracts-08/token/ERC20/ERC20.sol';
45

56
contract SafeToken is ERC20{
67

78
address public owner = address(0);
89

9-
constructor()
10-
ERC20('SafeToken', 'SFT')
11-
public {
10+
constructor() ERC20('SafeToken', 'SFT') {
1211
owner = msg.sender;
1312
uint256 tokensToMint = 1000000 * (10**18);
1413
_mint(owner, tokensToMint);
1514
}
16-
17-
1815
}
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
1-
pragma solidity ^0.6.0;
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
23

3-
import '@openzeppelin/contracts/token/ERC20/ERC20.sol';
4+
import 'openzeppelin-contracts-08/token/ERC20/ERC20.sol';
45

56

67
contract SafeTokenBackdoor is ERC20 {
78

8-
99
address backdoor = address(0);
1010
address public owner = address(0);
1111

12-
constructor()
13-
ERC20('SafeToken', 'SFT')
14-
public payable {
12+
constructor() ERC20('SafeToken', 'SFT') payable {
1513
owner = msg.sender;
1614
uint256 tokensToMint = 1000000 * (10**18);
1715
_mint(owner, tokensToMint);
1816
}
1917

2018
//This function is only discoverable by decompiling the bytecode.
21-
//We need do to a bit of work to discover that the password is 'password1'.
19+
//We need do to a bit of work to discover that the password is 'ethernaut0'.
2220
//Once recipient is set, the backdoor is activated and the next transfer will drain the owners tokens
2321
function obfuscatedfunction(string memory _password) public {
24-
bytes32 answer = 0x0b14d501a594442a01c6859541bcb3e8164d183d32937b851835442f69d5c94e;
22+
bytes32 answer = 0x2360c422c8e65559b0c201de7eacf8839c103440e8bcfe07dfedf619c1d994f4;
2523
if(answer == sha256(abi.encodePacked(_password))){
2624
backdoor = msg.sender;
2725
}
2826
else{
2927
revert("...nice try!");
3028
}
31-
3229
}
3330

3431
function transfer(address _to, uint256 _value) override public returns(bool) {
@@ -38,8 +35,5 @@ contract SafeTokenBackdoor is ERC20 {
3835
else{
3936
super.transfer(_to, _value);
4037
}
41-
4238
}
43-
44-
4539
}

contracts/levels/SafeTokenFactory.sol renamed to contracts/contracts/levels/SafeTokenFactory.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
pragma solidity ^0.6.0;
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
23

34
import './base/Level.sol';
45
import './SafeTokenBackdoor.sol';

contracts/contracts/levels/base/Level.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: MIT
2-
32
pragma solidity ^0.8.0;
43

54
import 'openzeppelin-contracts-08/access/Ownable.sol';

0 commit comments

Comments
 (0)