├── functions.py ├── metamask_bf_v1.py └── metamask_bf_v2.py /functions.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | #return your seed_words 4 | def seed_words(): 5 | return {} #you may put your own seed words here 6 | 7 | #copy to clipboard 8 | def copy2clip(txt): 9 | cmd='echo '+txt.strip()+'|clip' 10 | return subprocess.check_call(cmd, shell=True) 11 | #get next permutation 12 | def nextPermutation( arr): 13 | bPoint, n = -1, len(arr) 14 | for i in range(n-2,-1,-1): 15 | if arr[i] >= arr[i+1]: continue # Skip the non-increasing sequence 16 | bPoint = i # Got our breakpoint 17 | for j in range(n-1,i,-1): # again traverse from end 18 | if arr[j] > arr[bPoint]: # Search an element greater the element present at the breakPoint. 19 | arr[j], arr[bPoint] = arr[bPoint], arr[j] # Swap it 20 | break # We just need to swap once 21 | break # Break this loop too 22 | arr[bPoint+1:] = reversed(arr[bPoint+1:]) 23 | return arr 24 | #get nth permutation: 25 | def getPermutation( n: int, k: int): 26 | nums = [i for i in range(1,n+1)] 27 | ret = [] 28 | while(n): 29 | f = factorial(n-1) 30 | index = (k-1)//f 31 | ret += [nums[index]] 32 | nums.remove(nums[index]) 33 | n -= 1 34 | k %= f 35 | return ret 36 | 37 | def factorial(n: int)->int: 38 | if n==0: return 1 39 | elif n==1: return 1 40 | else: return n*factorial(n-1) 41 | -------------------------------------------------------------------------------- /metamask_bf_v1.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.by import By 3 | from selenium.webdriver.common.keys import Keys 4 | import time 5 | import subprocess 6 | 7 | def copy2clip(txt): 8 | cmd='echo '+txt.strip()+'|clip' 9 | return subprocess.check_call(cmd, shell=True) 10 | 11 | def nextPermutation( arr): 12 | bPoint, n = -1, len(arr) 13 | for i in range(n-2,-1,-1): 14 | if arr[i] >= arr[i+1]: continue # Skip the non-increasing sequence 15 | bPoint = i # Got our breakpoint 16 | for j in range(n-1,i,-1): # again traverse from end 17 | if arr[j] > arr[bPoint]: # Search an element greater the element present at the breakPoint. 18 | arr[j], arr[bPoint] = arr[bPoint], arr[j] # Swap it 19 | break # We just need to swap once 20 | break # Break this loop too 21 | arr[bPoint+1:] = reversed(arr[bPoint+1:]) 22 | return arr 23 | 24 | 25 | seed_words_test = {1:'abandon', 26 | 2:'ability', 27 | 3:'ask', 28 | 4:'asdfasdfasdf', 29 | 5:'above', 30 | 6:'absent', 31 | 7:'absorb', 32 | 8:'abstract', 33 | 9:'absurd', 34 | 10:'abuse', 35 | 11:'access', 36 | 12:'accident'} 37 | 38 | 39 | EXTENSION_PATH = "" #enter the path to the metamask .crx file here 40 | 41 | opt = webdriver.ChromeOptions() 42 | opt.add_extension(EXTENSION_PATH) 43 | driver = webdriver.Chrome(chrome_options=opt) 44 | time.sleep(1) 45 | 46 | #switch tabs 47 | driver.switch_to.window(driver.window_handles[0]) 48 | 49 | 50 | #CLICK THROUGH BUTTONS: 51 | #btn1 52 | time.sleep(1) 53 | elem = driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div[2]/div/div/div/button').click() 54 | #btn2 55 | time.sleep(1) 56 | elem = driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div[2]/div/div/div[2]/div/div[2]/div[1]/button').click() 57 | #btn3 58 | time.sleep(1) 59 | elem = driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div[2]/div/div/div/div[5]/div[1]/footer/button[2]').click() 60 | 61 | 62 | #CREATE KEYWORD STRING 63 | count = 0 64 | s = '' 65 | for e in seed_words_test: 66 | s += " " + seed_words_test[e] 67 | s.strip() 68 | 69 | #COPY STRING TO CLIPBOARD: 70 | copy2clip(s) 71 | 72 | #CLICK ON TEXTFIELD 73 | time.sleep(1) 74 | elem = driver.find_element(by = By.XPATH, value= '/html/body/div[1]/div/div[2]/div/div/div[2]/form/div[1]/div[2]/div[1]/div[1]/div/input') 75 | 76 | #PASTE CLIPBOARD TO TEXTFIELD 77 | elem.send_keys(Keys.CONTROL + 'v') 78 | time.sleep(2) 79 | 80 | arr = [1,2,3,4,5,6,7,8,9,10,11,12] 81 | 82 | looper = True 83 | 84 | while looper: 85 | try: 86 | elem = driver.find_element(by = By.XPATH, value= '/html/body/div[1]/div/div[2]/div/div/div[2]/form/div[1]/div[3]') 87 | count += 1 88 | s = '' 89 | arr = nextPermutation(arr) 90 | 91 | for e in arr: 92 | s += " " + seed_words_test[e] 93 | s.strip() 94 | 95 | #COPY STRING TO CLIPBOARD: 96 | copy2clip(s) 97 | #click on textfield 98 | elem = driver.find_element(by = By.XPATH, value= '/html/body/div[1]/div/div[2]/div/div/div[2]/form/div[1]/div[2]/div[1]/div[1]/div/input') 99 | #PASTE CLIPBOARD TO TEXTFIELD 100 | elem.send_keys(Keys.CONTROL + 'v') 101 | 102 | print(s) 103 | print(count) 104 | 105 | except: 106 | looper = False 107 | print("DONE!!!" , s) 108 | -------------------------------------------------------------------------------- /metamask_bf_v2.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.by import By 3 | from selenium.webdriver.common.keys import Keys 4 | import time 5 | #!!! 6 | import functions as mf #this file 'functions.py' is in the same folder. it is required for this program to run 7 | #!!! 8 | 9 | EXTENSION_PATH = "" #enter the path to your .crx file here 10 | mm_extension_id = "" #enter your metamask extension id here 11 | opt = webdriver.ChromeOptions() 12 | opt.add_extension(EXTENSION_PATH) 13 | driver = webdriver.Chrome(options=opt) 14 | 15 | driver.switch_to.window(driver.window_handles[1]) #switch to first window 16 | driver.get('chrome-extension://'+mm_extension_id+'/home.html#initialize/create-password/import-with-seed-phrase') #go to seed phrase page 17 | time.sleep(1) 18 | driver.find_element(by = By.XPATH, value= '//*[@id="import-srp__srp-word-0"]') #select textbox 19 | 20 | 21 | #ENTER SEED WORDS, current COUNT: 22 | seed_words = ['scene', 23 | 'scheme', 24 | 'school', 25 | 'science', 26 | 'scissors', 27 | 'produce', 28 | 'profit', 29 | 'program', 30 | 'project', 31 | 'script', 32 | 'scrub', 33 | 'sea'] 34 | password = '12345678' 35 | count = 1 #starts at 1, input 'n' to start at 'n'th permutation 36 | #EDITABLE ^^^ 37 | 38 | keys = [i for i in range(1,13)] 39 | seed_words = dict(zip(keys, seed_words)) 40 | 41 | s = '' 42 | arr = [1,2,3,4,5,6,7,8,9,10,11,12] 43 | #get starting point: 44 | arr = mf.getPermutation(len(arr), count) 45 | 46 | #print starting string and starting array: 47 | print("START:",arr, [seed_words[i] for i in arr]) 48 | 49 | #loop through permuations: 50 | t0 = time.time() 51 | looper = True 52 | while looper: 53 | #populate string: 54 | s = '' 55 | for i in arr: 56 | s += ' ' + seed_words[i] 57 | s.strip() 58 | 59 | mf.copy2clip(s) #copy string 60 | driver.find_element(by = By.XPATH, value = '//*[@id="import-srp__srp-word-0"]').send_keys(Keys.CONTROL + 'v') #paste string 61 | 62 | #if invalid seed phrase: 63 | try: 64 | driver.find_element(by = By.CSS_SELECTOR, value = '#app-content > div > div.main-container-wrapper > div > div > div > form > div.import-srp__container > div.actionable-message.actionable-message--danger.import-srp__srp-error.actionable-message--with-icon') #check to see if invalid message pops up 65 | #get next perm, increment 66 | arr = mf.nextPermutation(arr) 67 | print('Attempts', count, end = '\r', flush = False) 68 | print('count/sec:', "{:.2f}".format(count/(time.time()- t0)), '---- count:',count, end='\r', flush=True) 69 | count += 1 70 | 71 | #if valid seed phrase: 72 | except: 73 | #enter into wallet: 74 | driver.find_element(by = By.XPATH, value = '//*[@id="password"]').send_keys(password) #enter pass 75 | driver.find_element(by = By.XPATH, value = '//*[@id="confirm-password"]').send_keys(password) #enter pass2 76 | 77 | try: #after first login, check box disapears 78 | driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div[2]/div/div/div[2]/form/div[3]/input').click() #click check box 79 | except: 80 | pass 81 | 82 | try: #after first login, import btn -> restore btn 83 | driver.find_element(by = By.CSS_SELECTOR, value = '#app-content > div > div.main-container-wrapper > div > div > div.first-time-flow__import > form > button').click() #click import 84 | except: 85 | driver.find_element(by = By.XPATH, value = '//*[@id="app-content"]/div/div[3]/div/div/div/form/button').click() #click restore 86 | 87 | #HERE we need to wait for the restore process to load!! 88 | time.sleep(2) 89 | 90 | try: #after first login, click all done disapears 91 | driver.find_element(by = By.CSS_SELECTOR, value = '#app-content > div > div.main-container-wrapper > div > div > button').click() #click all done 92 | except: 93 | pass 94 | 95 | 96 | #once in wallet 97 | elem = driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div[3]/div/div/div/div[2]/div/div[1]/div/div/div/div[2]/span[1]') #find balance element 98 | usd = float(elem.text[1:]) #get balance usd 99 | if usd == 0: 100 | arr = mf.nextPermutation(arr) 101 | looper = True 102 | print(count, 'empty account:', s) 103 | count += 1 104 | 105 | try: #after first login, popup disapears 106 | driver.find_element(by = By.XPATH, value = '//*[@id="popover-content"]/div/div/section/div[1]/div/button').click() #exit pop-up 107 | except: 108 | pass 109 | driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div[1]/div/div[2]/div[2]/div/div').click() #click on profile 110 | driver.find_element(by = By.XPATH, value = '//*[@id="app-content"]/div/div[3]/div[2]/button').click() #click 'lock' account 111 | time.sleep(0.01) 112 | driver.get('chrome-extension://'+mm_extension_id+'/home.html#restore-vault') 113 | else: 114 | looper = False 115 | print("DONE",s, '$', str(usd)) 116 | print(count) 117 | --------------------------------------------------------------------------------