-
Notifications
You must be signed in to change notification settings - Fork 52
/
metamask_bf_v2.py
116 lines (98 loc) · 4.6 KB
/
metamask_bf_v2.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
#!!!
import functions as mf #this file 'functions.py' is in the same folder. it is required for this program to run
#!!!
EXTENSION_PATH = "" #enter the path to your .crx file here
mm_extension_id = "" #enter your metamask extension id here
opt = webdriver.ChromeOptions()
opt.add_extension(EXTENSION_PATH)
driver = webdriver.Chrome(options=opt)
driver.switch_to.window(driver.window_handles[1]) #switch to first window
driver.get('chrome-extension://'+mm_extension_id+'/home.html#initialize/create-password/import-with-seed-phrase') #go to seed phrase page
time.sleep(1)
driver.find_element(by = By.XPATH, value= '//*[@id="import-srp__srp-word-0"]') #select textbox
#ENTER SEED WORDS, current COUNT:
seed_words = ['scene',
'scheme',
'school',
'science',
'scissors',
'produce',
'profit',
'program',
'project',
'script',
'scrub',
'sea']
password = '12345678'
count = 1 #starts at 1, input 'n' to start at 'n'th permutation
#EDITABLE ^^^
keys = [i for i in range(1,13)]
seed_words = dict(zip(keys, seed_words))
s = ''
arr = [1,2,3,4,5,6,7,8,9,10,11,12]
#get starting point:
arr = mf.getPermutation(len(arr), count)
#print starting string and starting array:
print("START:",arr, [seed_words[i] for i in arr])
#loop through permuations:
t0 = time.time()
looper = True
while looper:
#populate string:
s = ''
for i in arr:
s += ' ' + seed_words[i]
s.strip()
mf.copy2clip(s) #copy string
driver.find_element(by = By.XPATH, value = '//*[@id="import-srp__srp-word-0"]').send_keys(Keys.CONTROL + 'v') #paste string
#if invalid seed phrase:
try:
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
#get next perm, increment
arr = mf.nextPermutation(arr)
print('Attempts', count, end = '\r', flush = False)
print('count/sec:', "{:.2f}".format(count/(time.time()- t0)), '---- count:',count, end='\r', flush=True)
count += 1
#if valid seed phrase:
except:
#enter into wallet:
driver.find_element(by = By.XPATH, value = '//*[@id="password"]').send_keys(password) #enter pass
driver.find_element(by = By.XPATH, value = '//*[@id="confirm-password"]').send_keys(password) #enter pass2
try: #after first login, check box disapears
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
except:
pass
try: #after first login, import btn -> restore btn
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
except:
driver.find_element(by = By.XPATH, value = '//*[@id="app-content"]/div/div[3]/div/div/div/form/button').click() #click restore
#HERE we need to wait for the restore process to load!!
time.sleep(2)
try: #after first login, click all done disapears
driver.find_element(by = By.CSS_SELECTOR, value = '#app-content > div > div.main-container-wrapper > div > div > button').click() #click all done
except:
pass
#once in wallet
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
usd = float(elem.text[1:]) #get balance usd
if usd == 0:
arr = mf.nextPermutation(arr)
looper = True
print(count, 'empty account:', s)
count += 1
try: #after first login, popup disapears
driver.find_element(by = By.XPATH, value = '//*[@id="popover-content"]/div/div/section/div[1]/div/button').click() #exit pop-up
except:
pass
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
driver.find_element(by = By.XPATH, value = '//*[@id="app-content"]/div/div[3]/div[2]/button').click() #click 'lock' account
time.sleep(0.01)
driver.get('chrome-extension://'+mm_extension_id+'/home.html#restore-vault')
else:
looper = False
print("DONE",s, '$', str(usd))
print(count)