Ejemplo n.º 1
0
 def on_filename(filename):
     # FIXME? "filename" might contain ".." (etc) and hence sketchy path traversals are possible
     nonlocal temp_storage
     temp_storage = None
     msg = None
     if filename:
         path = os.path.join(wallet_folder, filename)
         wallet_from_memory = get_wallet_from_daemon(path)
         try:
             if wallet_from_memory:
                 temp_storage = wallet_from_memory.storage  # type: Optional[WalletStorage]
             else:
                 temp_storage = WalletStorage(path)
         except (StorageReadWriteError, WalletFileException) as e:
             msg = _('Cannot read file') + f'\n{repr(e)}'
         except Exception as e:
             self.logger.exception('')
             msg = _('Cannot read file') + f'\n{repr(e)}'
     else:
         msg = ""
     self.next_button.setEnabled(temp_storage is not None)
     user_needs_to_enter_password = False
     if temp_storage:
         if not temp_storage.file_exists():
             msg =_("This file does not exist.") + '\n' \
                   + _("Press 'Next' to create this wallet, or choose another file.")
         elif not wallet_from_memory:
             if temp_storage.is_encrypted_with_user_pw():
                 msg = _("This file is encrypted with a password.") + '\n' \
                       + _('Enter your password or choose another file.')
                 user_needs_to_enter_password = True
             elif temp_storage.is_encrypted_with_hw_device():
                 msg = _("This file is encrypted using a hardware device.") + '\n' \
                       + _("Press 'Next' to choose device to decrypt.")
             else:
                 msg = _("Press 'Next' to open this wallet.")
         else:
             msg = _("This file is already open in memory.") + "\n" \
                 + _("Press 'Next' to create/focus window.")
     if msg is None:
         msg = _('Cannot read file')
     msg_label.setText(msg)
     widget_create_new.setVisible(
         bool(temp_storage and temp_storage.file_exists()))
     if user_needs_to_enter_password:
         pw_label.show()
         pw_e.show()
         pw_e.setFocus()
     else:
         pw_label.hide()
         pw_e.hide()
Ejemplo n.º 2
0
    def __init__(self, *, config: 'SimpleConfig', daemon: 'Daemon',
                 plugins: 'Plugins'):
        BaseElectrumSysGui.__init__(self,
                                    config=config,
                                    daemon=daemon,
                                    plugins=plugins)
        self.network = daemon.network
        storage = WalletStorage(config.get_wallet_path())
        if not storage.file_exists():
            print("Wallet not found. try 'electrumsys create'")
            exit()
        if storage.is_encrypted():
            password = getpass.getpass('Password:'******'')
        self.encoding = locale.getpreferredencoding()

        self.stdscr = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        curses.use_default_colors()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN)
        curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_WHITE)
        self.stdscr.keypad(1)
        self.stdscr.border(0)
        self.maxy, self.maxx = self.stdscr.getmaxyx()
        self.set_cursor(0)
        self.w = curses.newwin(10, 50, 5, 5)

        self.tab = 0
        self.pos = 0
        self.popup_pos = 0

        self.str_recipient = ""
        self.str_description = ""
        self.str_amount = ""
        self.str_fee = ""
        self.history = None
        self.txid = []

        util.register_callback(self.update,
                               ['wallet_updated', 'network_updated'])

        self.tab_names = [
            _("History"),
            _("Send"),
            _("Receive"),
            _("Addresses"),
            _("Contacts"),
            _("Banner")
        ]
        self.num_tabs = len(self.tab_names)
Ejemplo n.º 3
0
            num_tested += 1
            if num_tested % 5000 == 0:
                print(
                    f"> tested {num_tested} passwords so far... most recently tried: {password!r}"
                )


if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("ERROR. usage: bruteforce_pw.py <path_to_wallet_file>")
        sys.exit(1)
    path = sys.argv[1]

    config = SimpleConfig()
    storage = WalletStorage(path)
    if not storage.file_exists():
        print(f"ERROR. wallet file not found at path: {path}")
        sys.exit(1)
    if storage.is_encrypted():
        test_password = partial(test_password_for_storage_encryption, storage)
        print(f"wallet found: with storage encryption.")
    else:
        db = WalletDB(storage.read(), manual_upgrades=True)
        wallet = Wallet(db, storage, config=config)
        if not wallet.has_password():
            print("wallet found but it is not encrypted.")
            sys.exit(0)
        test_password = partial(test_password_for_keystore_encryption, wallet)
        print(f"wallet found: with keystore encryption.")
    password = bruteforce_loop(test_password)
    print(f"====================")