Как применить pyethrecover.py к v3 .json/transfor v3 .json к .v1

Я пытаюсь запустить pyethrecover.py через Python в одном из моих файлов .json, созданных Ethereum-кошельком для Mac. Похоже, что мой файл .json имеет версию 3, а pyethrecover.py работает только с файлами версии 1 (файл pyethrecover.py ищет encseed и ethaddr, которые недоступны в версиях файлов .json версии 3).

Есть ли способ перенести файлы v3 в файлы v1 (без ввода пароля) или другой способ взломать мой файл .json, если я забыл свой точный пароль? Или, может быть, изменить мой файл v3 .json, чтобы помочь pyethrecover.py работать над ним?

Я уже отправил электронное письмо ethereal.org со своей проблемой, но ответа нет.

Надеюсь, вы можете мне помочь!

Ответы (2)

У меня такая же проблема. Я создал кошелек с помощью gethи каким-то образом записал неправильный пароль. Я использовал простой pythonкод ниже, чтобы решить проблему. Я знаю, что это некрасиво, но мне просто нужно было быстрое решение моей проблемы. Кто-то другой может взять это и сделать правильный инструмент, или, возможно, я когда-нибудь доберусь до него в качестве хорошего pythonучебного опыта. Я протестировал около 100 000 паролей и смог восстановить их с помощью этого кода. Он имеет аналогичный формат pyethrecover(инструмент предпродажи) и используется pyethereumдля декодирования файла хранилища ключей.

Вам необходимо загрузить/установить pyethereumбиблиотеку: https://github.com/ethereum/pyethereum
См. там документацию по требованиям и инструкциям.

Из pyethereumнужного, keys.pyкоторый имеет функциюdecode_keystore_json

from keys import decode_keystore_json #keys.py from pyethereum, we only want the decode_keystore_json function
import json
import itertools
import sys

f = open('wallet.json') # the json account file from keystore, here renamed
jsondata=json.load(f)

Запустите следующее, если у вас есть текстовый файл с записанными разными паролями, которые вы хотите попробовать, по одному в каждой строке:

# Reading possible passwords from a text file
with open('listofpasswords.txt') as fpw: # a text file with possible passwords on each line
    lines = fpw.read().splitlines()

n_pws = len(lines)
print 'Number of passwords to test: %d' % (n_pws,)
i=1
for l in lines:
    try:
        decode_keystore_json(jsondata,l)
        print '\n*** found password in text file:'
        print l
        break
    except:
        sys.stdout.write("\r#%d %s" % (i,l)) #prints simple progress with # in list that is tested and the pw string
        sys.stdout.flush()
        i+=1

Или этот код, если вы хотите составить пароли из возможных комбинаций (см. пример 2 pyethrecover):

# Constructing passwords from possible combinations (see doc of pyethrecover)
grammar=[
    ('correct',),
    ('horse','donkey'),
    ('staple','STAPLE'),
    ('','battery')
]

pwds=[]
def generate_all(el, tr): #taken from pyethrecover
    if el:
        for j in xrange(len(el[0])):
            for w in generate_all(el[1:], tr + el[0][j]):
                yield w
    else:
        yield tr


pwds = itertools.chain(pwds, generate_all(grammar,''))
pwds_l = list(pwds)
n_pws = len(pwds_l)
print 'Number of passwords to test: %d' % (n_pws,)
i=1
for l in pwds_l:
    try:
        decode_keystore_json(jsondata,l)
        print '\n*** found password in grammar list:'
        print l
        break
    except:
        sys.stdout.write("\r#%d %s" % (i,l)) #prints simple progress with # in list that is tested and the pw string
        sys.stdout.flush()
        i+=1

Удачи!

Ответ @rhkarls спас жизнь!

Мне просто пришлось немного адаптировать код для моей версии Python (3.5.2).

from keys import decode_keystore_json #keys.py from pyethereum, we only want the decode_keystore_json function
import json
import itertools
import sys
print(sys.version)

# the json account file from keystore, here renamed, normally has a name like 
# Ethereum\keystore\UTC--2016-12-23T11-51-50.069518500Z--637f383c240g512be19d3ffa3b45d7f03babf091
f = open('ethereum-wallet.json')
jsondata=json.load(f)

combinations=[
    ('beautiful', 'ugly', 'elegant', 'clumsy', ''),
    ('blue', 'red', 'yellow', 'green'),
    ('horse', 'dog', 'cat')
]

pwds=[]
def generate_all(el, tr): #taken from pyethrecover
    if el:
        for j in range(len(el[0])):
            for w in generate_all(el[1:], tr + el[0][j]):
                yield w
    else:
        yield tr


pwds = itertools.chain(pwds, generate_all(combinations,''))
pwds_l = list(pwds)
n_pws = len(pwds_l)

print('Number of passwords to test {0} '.format(n_pws))

i=1
found = 0
for l in pwds_l:    
    try:
        decode_keystore_json(jsondata,l)
        print('\n*** found password in text file {0} '.format(l))
        found = 1
        break
    except:   
        i+=1

if found == 0:
    print('Password not found in {0} attempts'.format(n_pws))
Я собрал параллельную версию вышеперечисленного: github.com/danielchalef/pyethrecoverv3 .