Skip to content

Instantly share code, notes, and snippets.

View SomberNight's full-sized avatar

ghost43 SomberNight

View GitHub Profile
@SomberNight
SomberNight / ledger_dongle.py
Last active December 11, 2018 20:05
ledger dongle from electrum qt
# get access to ledger dongle object from electrum qt context
def get_dongle():
plugin_mgr = window.gui_object.plugins
plugin = plugin_mgr.get_plugin("ledger")
devices = plugin_mgr.device_manager.scan_devices()
dongle = None
for device in devices:
if device.product_key not in plugin.DEVICE_IDS:
@SomberNight
SomberNight / decrypt_electrum_wallet.py
Created November 22, 2018 11:43
Decrypt Electrum wallet file
import sys
import getpass
from electrum.storage import WalletStorage
##########
# Set the path to your wallet file here.
#
path = "C:/Users/User/AppData/Roaming/Electrum/testnet/wallets/test_segwit_asdasd"
##########
@SomberNight
SomberNight / taskgroup_wait_example.py
Last active September 8, 2018 15:05
TaskGroup wait example
import asyncio
from aiorpcx import TaskGroup, timeout_after
async def main():
print("main entered")
try:
async with TaskGroup() as group:
await group.spawn(forever())
# if we spawn a task to run "g", we will finish:
await group.spawn(g())
@SomberNight
SomberNight / dbb_xprv_helper_script.py
Created September 7, 2018 21:12
digital bitbox backup xprv helper
# to be used with https://shiftcrypto.ch/backup
from electrum import bitcoin
# TODO change to 'BIP32 extended master private key'
bip32_extended_root_key = "xprv9s21ZrQH143K3EQ2jcSFQVoBtQyv2rPe8tfaYcP3JQe5SU4sPgrnm9n7XLJxuQkua9xYScs29nA6kWmKnb2dEsVvARM6eyFP1D969p8zZ8Z"
xprv, xpub = bitcoin.bip32_private_derivation(bip32_extended_root_key, "m/", "m/44'/0'/0'")
print("legacy xprv:", xprv)
import electrum
from electrum import bip32
initial_xprv = '.......' # TODO fill in
target_xtype = 'p2wpkh' # TODO change?
_, depth, fingerprint, child_number, c, cK = bip32.deserialize_xprv(initial_xprv)
target_xprv = bip32.serialize_xprv(target_xtype, c, cK, depth, fingerprint, child_number)
print(target_xprv)
@SomberNight
SomberNight / electrum_gap_limits.py
Created July 18, 2018 22:41
Change gap limits without GUI in Electrum
from electrum.storage import WalletStorage
from electrum.wallet import Wallet
#from electrum import constants
#constants.set_testnet()
storage = WalletStorage('/home/user/.electrum/testnet/wallets/default_wallet')
wallet = Wallet(storage)
wallet.change_gap_limit(200)
wallet.gap_limit_for_change = 200
@SomberNight
SomberNight / xpub_to_ypub.py
Last active July 10, 2018 15:31
convert xpub to ypub
from electrum import bitcoin
xpub1 = 'xpub661MyMwAqRbcEcF8odLPZvkWA3xi9ptJqzfzzFFmvNcRtnGb2wzKgVCNN8i1uAwa6kwXLgG7atobaSoExfhpxDfuQp3FfSKPWcocLxKJyk9'
xtype, depth, fingerprint, child_number, c, K_or_k = bitcoin.deserialize_xkey(xpub1, False)
xpub2 = bitcoin.serialize_xpub('p2wpkh-p2sh', c, K_or_k, depth, fingerprint, child_number)
print(xpub2)
@SomberNight
SomberNight / bruteforce_pw.py
Created June 16, 2018 02:30
Electrum Android wallet file: bruteforce 6-digit PIN
# note: for good perfomance, have pycryptodome installed
# (about 20x faster than pyaes for this).
# for ref, it takes about 60 seconds to scan the whole domain for me with pycryptodome.
import electrum
from electrum.wallet import Wallet
from electrum.storage import WalletStorage
storage = WalletStorage('path_to_wallet_file')
wallet = Wallet(storage)

Keybase proof

I hereby claim:

  • I am SomberNight on github.
  • I am ghost43 (https://keybase.io/ghost43) on keybase.
  • I have a public key whose fingerprint is 4AD6 4339 DFA0 5E20 B3F6 AD51 E7B7 48CD AF5E 5ED9

To claim this, I am signing this object:

@SomberNight
SomberNight / electrumpro_keystore.py
Created May 8, 2018 08:55
decompiled keystore.py from ElectrumPro 4.0.2 scam
# uncompyle6 version 3.1.3
# Python bytecode 3.5 (3351)
# Decompiled from: Python 3.5.3 (default, Jan 19 2017, 14:11:04)
# [GCC 6.3.0 20170118]
# Embedded file name: site-packages\electrum-4.0.2-py3.5.egg\electrum\keystore.py
import base64, random, threading, requests, time
from unicodedata import normalize
from . import bitcoin
from .bitcoin import *
from . import constants