def __chooseDevice(self, devices): if not len(devices): raise RuntimeError("No Trezor connected!") if len(devices) == 1: try: return devices[0] except IOError: raise RuntimeError("Device is currently in use") i = 0 sys.stderr.write("----------------------------\n") sys.stderr.write("Available devices:\n") for d in devices: try: client = TrezorClient(d, ui=ui.ClickUI()) except IOError: sys.stderr.write("[-] <device is currently in use>\n") continue if client.features.label: sys.stderr.write("[%d] %s\n" % (i, client.features.label)) else: sys.stderr.write("[%d] <no label>\n" % i) client.close() i += 1 sys.stderr.write("----------------------------\n") sys.stderr.write("Please choose device to use:") try: device_id = int(input()) return devices[device_id] except Exception: raise ValueError("Invalid choice, exiting...")
def _connect(self): self.wirelink = get_transport(self.path) self.client = ( TrezorClientDebugLink(self.wirelink) if self.debug else TrezorClient(self.wirelink, ui=ui.ClickUI()) )
def find_trezor(self): u"""Selects a trezor device and initialize the client.""" devices = TrezorDevice.enumerate() if len(devices) == 0: raise NoTrezorFoundError('No Trezor device was found. Make sure it' ' is plugged.') transport = devices[0] trezor = TrezorClient(transport, ui=ui.ClickUI()) return trezor
def main(): try: transport = get_transport() except Exception as e: print(e) return client = TrezorClient(transport=transport, ui=ui.ClickUI()) print() print('Confirm operation on TREZOR') print() masterKey = getMasterKey(client) # print('master key:', masterKey) fileName = getFileEncKey(masterKey)[0] # print('file name:', fileName) home = os.path.expanduser('~') path = os.path.join(home, 'Dropbox', 'Apps', 'TREZOR Password Manager') # print('path to file:', path) encKey = getFileEncKey(masterKey)[2] # print('enckey:', encKey) full_path = os.path.join(path, fileName) parsed_json = decryptStorage(full_path, encKey) # list entries entries = parsed_json['entries'] printEntries(entries) entry_id = input('Select entry number to decrypt: ') entry_id = str(entry_id) plain_nonce = getDecryptedNonce(client, entries[entry_id]) pwdArr = entries[entry_id]['password']['data'] pwdHex = ''.join([hex(x)[2:].zfill(2) for x in pwdArr]) print('password: '******'safe_note']['data'] safeNoteHex = ''.join([hex(x)[2:].zfill(2) for x in safeNoteArr]) print('safe_note:', decryptEntryValue(plain_nonce, bytes.fromhex(safeNoteHex))) return
def main() -> None: try: transport = get_transport() except Exception as e: print(e) return client = TrezorClient(transport=transport, ui=ui.ClickUI()) print() print("Confirm operation on Trezor") print() masterKey = getMasterKey(client) # print('master key:', masterKey) fileName = getFileEncKey(masterKey)[0] # print('file name:', fileName) home = os.path.expanduser("~") path = os.path.join(home, "Dropbox", "Apps", "TREZOR Password Manager") # print('path to file:', path) encKey = getFileEncKey(masterKey)[2] # print('enckey:', encKey) full_path = os.path.join(path, fileName) parsed_json = decryptStorage(full_path, encKey) # list entries entries = parsed_json["entries"] printEntries(entries) entry_id = input("Select entry number to decrypt: ") entry_id = str(entry_id) plain_nonce = getDecryptedNonce(client, entries[entry_id]) pwdArr = entries[entry_id]["password"]["data"] pwdHex = "".join([hex(x)[2:].zfill(2) for x in pwdArr]) print("password: "******"safe_note"]["data"] safeNoteHex = "".join([hex(x)[2:].zfill(2) for x in safeNoteArr]) print("safe_note:", decryptEntryValue(plain_nonce, bytes.fromhex(safeNoteHex)))
def main(): try: client = TrezorClient(get_transport(), ui=ui.ClickUI()) except Exception as e: print(e) return arg1 = sys.argv[1] # output file arg2 = int(sys.argv[2], 10) # total number of how many bytes of entropy to read step = 1024 if arg2 >= 1024 else arg2 # trezor will only return 1KB at a time with io.open(arg1, 'wb') as f: for i in range(0, arg2, step): entropy = misc.get_entropy(client, step) f.write(entropy) client.close()
def __getClient(self): if self.client is None: devices = self.__waitForDevices() transport = self.__chooseDevice(devices) self.client = TrezorClient(transport=transport, ui=ui.ClickUI())
# Tested with SLIP-0014 allallall seed (slip-0014.md) # User Provided Fields; These are pulled from test scripts # CHANGE THESE!!! chain_id = 1 #EIP-155 address = "m/44'/60'/0'/0/0" gas_limit = 200000 gas_price = 5000000000 nonce = 11 token_address = "0xa74476443119A942dE498590Fe1f2454d7D4aC0d" #EIP-55 to_address = "0xA6ABB480640d6D27D2FB314196D94463ceDcB31e" #EIP-55 amount = 5000000000000000 # Nothing changes below here device = get_transport() client = TrezorClient(transport=device, ui=ui.ClickUI()) fw = client.features fw_min = min_version[fw.model] py_min = (3,6,0) tl_min = [0,12,0] if (fw_min > (fw.major_version, fw.minor_version,fw.patch_version) or tl_min > [int(i) for i in lib_version.split('.')] or py_min > py_ver): m = "Requires at least Python rev {}, trezorlib rev {}, and FW rev {}" print(m.format(py_min, tl_min, fw_min)) exit(1) w3 = Web3() address_n = tools.parse_path(address) from_address = ethereum.get_address(client, address_n)
async def amain(): parser = argparse.ArgumentParser(description="Trezor address loader") parser.add_argument("--trezor-path", dest="trezor_path", default=None, help="Trezor device path") parser.add_argument("--trezor-idx", dest="trezor_idx", default=None, help="Trezor path idx") parser.add_argument("--pin", dest="pin", default="", help="Trezor PIN protection") parser.add_argument( "--passphrase", dest="passphrase", default=False, action="store_const", const=True, help="Enable passphrase", ) parser.add_argument( "--debug", dest="debug", default=False, action="store_const", const=True, help="Debug", ) parser.add_argument( "--debug-link", dest="debug_link", default=False, action="store_const", const=True, help= "Debug link with Trezor. May skip some dialogs (e.g., passphrase entry)", ) args = parser.parse_args() try: if args.debug: coloredlogs.install(level=logging.DEBUG, use_chroot=False) else: coloredlogs.install(level=logging.INFO, use_chroot=False) except Exception as e: pass debug_mode = args.debug_link if args.trezor_path: path = args.trezor_path elif args.trezor_idx: path = "bridge:web01" if args.trezor_idx == "usb" else "udp:127.0.0.1:21324" else: path = os.environ.get("TREZOR_PATH", "bridge:web01") wirelink = get_transport(path) client = (TrezorClientDebugLink(wirelink) if debug_mode else TrezorClient(wirelink, ui=ui.ClickUI())) # client.transport.session_begin() trezor_proxy = tmanager.Trezor(path=path, debug=args.debug_link) network_type = NetworkTypes.MAINNET agent = agent_lite.Agent(trezor_proxy, network_type=network_type) res = await agent.get_address() print(res) # client.transport.session_end() client.close() sys.exit(0)
def main(): parser = argparse.ArgumentParser(description="Trezor initializer") parser.add_argument( "--trezor-path", dest="trezor_path", default=None, help="Trezor device path" ) parser.add_argument( "--trezor-idx", dest="trezor_idx", default=None, help="Trezor path idx" ) parser.add_argument( "--mnemonic-idx", dest="mnemonic_idx", default=0, type=int, help="Trezor mnemonic index (testing indices)" ) parser.add_argument( "--mnemonic", dest="mnemonic", default=None, help="Trezor mnemonic" ) parser.add_argument( "--pin", dest="pin", default="", help="Trezor PIN protection" ) parser.add_argument( "--label", dest="label", default="", help="Trezor label - on display" ) parser.add_argument( "--language", dest="language", default="english", help="Seed language" ) parser.add_argument( "--passphrase", dest="passphrase", default=False, action="store_const", const=True, help="Enable passphrase", ) parser.add_argument( "--debug", dest="debug", default=False, action="store_const", const=True, help="Debug", ) parser.add_argument( "--debug-link", dest="debug_link", default=False, action="store_const", const=True, help="Debug link with Trezor. May skip some dialogs (e.g., passphrase entry)", ) args = parser.parse_args() try: if args.debug: coloredlogs.install(level=logging.DEBUG, use_chroot=False) else: coloredlogs.install(level=logging.INFO, use_chroot=False) except Exception as e: pass mnemonic12 = ( "alcohol woman abuse must during monitor noble actual mixed trade anger aisle" ) mnemonic24 = ( "permit universe parent weapon amused modify essay borrow tobacco budget walnut " "lunch consider gallery ride amazing frog forget treat market chapter velvet useless topple" ) debug_mode = args.debug_link if args.trezor_path: path = args.trezor_path elif args.trezor_idx: path = "bridge:web01" if args.trezor_idx == "usb" else "udp:127.0.0.1:21324" else: path = os.environ.get("TREZOR_PATH", "bridge:web01") mnemonic = mnemonic24 if args.mnemonic_idx == 1 else mnemonic12 if args.mnemonic: mnemonic = mnemonic wirelink = get_transport(path) client = ( TrezorClientDebugLink(wirelink) if debug_mode else TrezorClient(wirelink, ui=ui.ClickUI()) ) #client.transport.session_begin() device.wipe(client) debuglink.load_device_by_mnemonic( client=client, mnemonic=mnemonic, pin=args.pin, passphrase_protection=args.passphrase, label=args.label, language=args.language, ) #client.transport.session_end() client.close()