Code Monkey home page Code Monkey logo

nitrokey-app2's Introduction

Nitrokey App 2

This application allows to manage Nitrokey 3 devices. To manage Nitrokey Pro and Nitrokey Storage devices, use the older Nitrokey App.

Installation

These are the preferred installation methods for the following operating systems:

Windows

Download and run the prebuilt .msi available inside releases.

Linux

Flathub lists the Nitrokey App2 to be used for an easy install within your prefered Linux distribution.

macOS

Currently there is no official support for macOS, you might want to try installing through pypi using pip and/or pipx.

Features

The following features are currently implemented.

  • Firmware update
  • Passwords
    • TOTP
    • HOTP

Download

Executable binaries for Linux and Windows as well as a MSI installer for Windows can be downloaded from the releases.

Compiling for Linux and macOS

This project uses Poetry as its dependency management and packaging system. See the documentation of Poetry for available commands.

The application can be compiled by executing:

git clone https://github.com/Nitrokey/nitrokey-app2.git
cd nitrokey-app2
make init
make build
poetry shell
nitrokeyapp

Dependencies

Author

Nitrokey GmbH, Jan Suhr and contributors.

nitrokey-app2's People

Contributors

mmerklinger avatar daringer avatar niklap97 avatar jj-so avatar robin-nitrokey avatar jans23 avatar runcom avatar nestire avatar bsdlme avatar returntoreality avatar

Stargazers

Bernardo Melo avatar XC avatar  avatar naskya avatar Laurent Rineau avatar Matthias Domke avatar  avatar David Marzal avatar JR avatar  avatar Dave @ CH avatar  avatar Peter Schuller avatar  avatar  avatar Sebastian Oeste avatar Sascha Xander avatar  avatar Raphael Fiedler avatar Marcin Wrochna avatar  avatar A.Z. avatar  avatar  avatar Austin Songer,MIS,CEH,ESCA,Project+ (Navy Veteran) avatar George Kontridze avatar  avatar Michal Lesniewski avatar  avatar Jan avatar  avatar Felix Schröter avatar  avatar Joel Purra avatar Jörn Franke avatar Jannek avatar 1MathArt avatar Arnab Biswas avatar  avatar Morten Kristensen avatar Anand Prabhu avatar Savely Krasovsky avatar Alexander Puck Neuwirth avatar Marc Hefter avatar Matt Schultz avatar Dominic Shelton avatar Dominik Rathmer avatar Michael Pardatscher avatar Yohan avatar Walter C avatar David Runge avatar Markus Schicker avatar Saša Janiška avatar Felix Kronlage-Dammers avatar  avatar TheMoltenJack avatar  avatar Elia KopfKrieg avatar Sebastian Schuberth avatar Parham Mohammadi avatar OliverK avatar Arne Böttger avatar  avatar Luigi 'Comio' Mantellini avatar Secu-Design® avatar birds.swim avatar Vadim Efimov avatar Alberto Gireud avatar boldsuck avatar Martin Schröder avatar  avatar Samuel avatar Kizmo avatar psi avatar Szczepan Zalega avatar

Watchers

James Cloos avatar  avatar Laurent Rineau avatar lennard avatar  avatar  avatar  avatar Kizmo avatar  avatar

nitrokey-app2's Issues

App crashes on start if Nitrokey in bootloader mode

The app crashes with attached traceback, when a Nitrokey in bootloader mode is entcountered.

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/user/Projects/nitrokey-app2/nitrokeyapp/__main__.py", line 25, in <module>
    main()
  File "/home/user/Projects/nitrokey-app2/nitrokeyapp/__main__.py", line 21, in main
    GUI(app)
  File "/home/user/Projects/nitrokey-app2/venv/lib64/python3.9/site-packages/nitrokeyapp/gui.py", line 199, in __init__
    self.init_gui()
  File "/home/user/Projects/nitrokey-app2/venv/lib64/python3.9/site-packages/nitrokeyapp/gui.py", line 301, in init_gui
    self.detect_nk3()
  File "/home/user/Projects/nitrokey-app2/venv/lib64/python3.9/site-packages/nitrokeyapp/gui.py", line 240, in detect_nk3
    Nk3Button(
  File "/home/user/Projects/nitrokey-app2/venv/lib64/python3.9/site-packages/nitrokeyapp/nk3_button.py", line 42, in __init__
    self.version = self.device.version()
AttributeError: 'Nitrokey3BootloaderNrf52' object has no attribute 'version'
Exception ignored in: <function Nk3Button.__del__ at 0x7f47c236e1f0>
Traceback (most recent call last):
  File "/home/user/Projects/nitrokey-app2/venv/lib64/python3.9/site-packages/nitrokeyapp/nk3_button.py", line 130, in __del__
    self.tabs.hide()
RuntimeError: wrapped C/C++ object of type Nk3Button has been deleted

No error message if insufficient rights to update firmware

Fails to update firmware, app message:

Exception ignored in: <generator object Updater._get_bootloader at 0x7f7a569b29e0>
Traceback (most recent call last):
  File "/home/martin/projects/nitrokey-app2/venv/lib/python3.11/site-packages/nitrokeyapp/pynitrokey_for_gui.py", line 223, in nk3_update
    info_frame.set_text("Failed to update Nitrokey 3.")
RuntimeError: generator ignored GeneratorExit

Right after touching the nitrokey to start the update, it reconnects to the computer with a different idProduct.

[ 5238.198952] usb 1-6: new full-speed USB device number 15 using xhci_hcd
[ 5238.368019] usb 1-6: New USB device found, idVendor=20a0, idProduct=42b2, bcdDevice= 1.02
[ 5238.368025] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 5238.368028] usb 1-6: Product: Nitrokey 3
[ 5238.368030] usb 1-6: Manufacturer: Nitrokey
[ 5238.505140] hid-generic 0003:20A0:42B2.000E: hiddev100,hidraw9: USB HID v1.11 Device [Nitrokey Nitrokey 3] on usb-0000:05:00.1-6/input1
[ 5238.508052] cdc_acm 1-6:1.2: ttyACM0: USB ACM device
[ 5358.775169] usb 1-6: USB disconnect, device number 15
[ 5359.037111] usb 1-6: new high-speed USB device number 16 using xhci_hcd
[ 5359.178500] usb 1-6: New USB device found, idVendor=20a0, idProduct=42dd, bcdDevice= 3.00
[ 5359.178507] usb 1-6: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 5359.178510] usb 1-6: Product: USB COMPOSITE DEVICE
[ 5359.178511] usb 1-6: Manufacturer: NXP SEMICONDUCTOR INC.
[ 5359.264147] hid-generic 0003:20A0:42DD.000F: hiddev100,hidraw10: USB HID v1.00 Device [NXP SEMICONDUCTOR INC. USB COMPOSITE DEVICE] on usb-0000:05:00.1-6/input0

note USB disconnect, device number 15 , which signals I allowed the Nitrokey to update.

After physically reconnecting the nitrokey, nitropy nk3 test runs successfully, so I presume the nitrokey isn't dead :)

PyQt5.sip missing from linux binary

Traceback (most recent call last):
  File "nitrokeyapp/__main__.py", line 3, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
[1869441] Failed to execute script '__main__' due to unhandled exception!

If CTAP communication is corrupted nitrokey-app2 will not start

(using the single binary linux version)

This is likely a rare case for the end-user, but a busy ctap channel can easily occur during development. The actual issue to solve here is to move the communication with the device into a separate thread to ensure that any errors during communication does not crash the entire app.

example output (directly after starting):

Traceback (most recent call last):
  File "nitrokeyapp/__main__.py", line 20, in <module>
  File "nitrokeyapp/__main__.py", line 16, in main
  File "nitrokeyapp/gui.py", line 149, in __init__
  File "nitrokeyapp/gui.py", line 290, in init_gui
  File "nitrokeyapp/gui.py", line 202, in detect_nk3
  File "pynitrokey/nk3/__init__.py", line 25, in list
  File "pynitrokey/nk3/device.py", line 146, in list
  File "pynitrokey/nk3/device.py", line 73, in __init__
  File "pynitrokey/nk3/admin_app.py", line 71, in status
  File "pynitrokey/nk3/admin_app.py", line 58, in _call
  File "pynitrokey/nk3/device.py", line 133, in _call
  File "fido2/hid/__init__.py", line 216, in call
fido2.ctap.CtapError: CTAP error: 0x06 - CHANNEL_BUSY
[1924370] Failed to execute script '__main__' due to unhandled exception!

Change package and binary names

The current binary name nitrokeyapp is very close to the legacy Nitrokey App, nitrokey-app. We should change it to nitrokey-app2. We might also want to change the Python package name (nitrokey_app? nitrokey_app2?) for consistency.

Move main logic out of Nk3Button

Most of the code that is currently in Nk3Button should be either be decentralized and moved to other components that update themselves, e. g. the overview tab, or centralized in Gui.

Remove unused UI files

As far as I see, pynitrokey/ui still contains some unused files. These should be moved to pynitrokey/bak or deleted.

Nitrokey-app2 v2.0.1 does not run on Fedora 37 (Workstation)

When running on a fully updated Fedora 37 Workstation (Wayland)

$ ./nitrokey-app-v2.0.1-x64-linux-binary
./nitrokey-app-v2.0.1-x64-linux-binary: error while loading shared libraries: libz.so.1: failed to map segment from shared object

I see no applicable logs in the journal.

Here is the version of libz.so that is being used:

ls -l /usr/lib64/libz.so.1
lrwxrwxrwx. 1 root root 14 Aug 31  2022 /usr/lib64/libz.so.1 -> libz.so.1.2.12

cannot run linux binary

./nitrokey-app-v2.0.1-x64-linux-binary vnc
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted

There are those of us who don't use wayland because its a trash heap. And in some cases, people even use xenocara, a better version of xorg that has better design.

I don't know if that is why or not, but yeah, just thought I would toss that out there.

I don't know what the specific problem is.

Pyinstaller build broken due to missing metadata

The builds from pyinstaller break during start with the following error.

Traceback (most recent call last):
  File "nitrokeyapp/__main__.py", line 35, in <module>
    main()
  File "nitrokeyapp/__main__.py", line 28, in main
    log_environment()
  File "nitrokeyapp/logger.py", line 46, in log_environment
    logger.info(f"{x} version: {package_version(x)}")
  File "importlib/metadata.py", line 569, in version
  File "importlib/metadata.py", line 542, in distribution
  File "importlib/metadata.py", line 196, in from_name
importlib.metadata.PackageNotFoundError: nitrokeyapp
[638397] Failed to execute script '__main__' due to unhandled exception!

The logger tries to print the package version of *nitrokeyapp`. The metadata of this package is not included in the builds.

include "how to install" for Mac

It is basically the same as the linux howto but requires the make build-ui step before running the program, perhaps right after make init.

Tested on MacOS Ventura 13.3.1

Improve update UI

  • Avoid focus changes between the info frame at the bottom and popup dialogs.
  • Include extra information from pynitrokey
  • Indicate overall progress (e. g. step x of y)

Strange KDE-related error exposing malware-like behavior

lupe@XXXX:/sw/archive/Nitrokey$ ./nitrokey-app-v2.0.1-x64-linux-binary
kde-open5: /tmp/_MEIvnI6L7/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libKF5KIOCore.so.5)
kde-open5: /tmp/_MEIvnI6L7/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libKF5CoreAddons.so.5)
kde-open5: /tmp/_MEIvnI6L7/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libKF5Service.so.5)
kde-open5: /tmp/_MEIvnI6L7/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libKF5ConfigWidgets.so.5)
kde-open5: /tmp/_MEIvnI6L7/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libKF5WindowSystem.so.5)
kde-open5: /tmp/_MEIvnI6L7/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libKF5ConfigCore.so.5)
kde-open5: /tmp/_MEIvnI6L7/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /lib/x86_64-linux-gnu/libQt5Xml.so.5)

The strange thing is that the error is triggered by a version of libstdc++.so in a somewhat randomly named subdirectory of /tmp. This something that point to malware behavior. Please explain. BTW, please note that the files I'm attaching are from a later run of the Nitrokey App, so the name of the subdirectory differs.

The message above are triggered by clicking the (?) symbol in the App's window. OS is Ubuntu 22.10 (Kinetic Kudu) with up to date patches.

I'm attaching the nitrokey-app2.log and an strace of the run producing the error messages. Since this made me aware that I had forgotten to secure /tmp, I did that. Which prevents the error from occurring:

lupe@alanya:/sw/archive/Nitrokey$ ./nitrokey-app-v2.0.1-x64-linux-binary
./nitrokey-app-v2.0.1-x64-linux-binary: error while loading shared libraries: libz.so.1: failed to map segment from shared object

I'm attaching an strace log for this as well.

Let me repeat that putting executable code in /tmp or /var/tmp and running it from there is a deplorable practice. Please rewrite your code to avoid this.

I have not yet analyzed the straces, so I do not yet know how your code wants to work. I'm glad it pointed me at the lack of security on my /tmp and /var/tmp. Thank you for that!

ImportError: cannot import name 'main' from 'nitrokeyapp'

Reproducer 1:

$ make update-venv
$ ./venv/bin/nitrokeyapp 
Traceback (most recent call last):
  File "/home/robin/reps/nitrokey-app2/./venv/bin/nitrokeyapp", line 5, in <module>
    from nitrokeyapp import main
ImportError: cannot import name 'main' from 'nitrokeyapp' (/home/robin/reps/nitrokey-app2/venv/lib/python3.9/site-packages/nitrokeyapp/__init__.py)

Reproducer 2:

$ pipx install git+https://github.com/Nitrokey/nitrokey-app2
$ nitrokeyapp 
Traceback (most recent call last):
  File "/home/robin/.local/bin/nitrokeyapp", line 5, in <module>
    from nitrokeyapp import main
ImportError: cannot import name 'main' from 'nitrokeyapp' (/home/robin/.local/pipx/venvs/nitrokeyapp/lib/python3.9/site-packages/nitrokeyapp/__init__.py)

Disable UI during operations

To avoid conflicts between operations, we should disable the main window while an operation is running (GUI.set_busy).

Crash while updating firmware under wayland.

nitrokey-app kills itself while updating firmware under a wayland compositor (kwin in my case), after the window becoming unresponsive for a wile.

Running with QT_QPA_PLATFORM=xcb ./venv/bin/nitrokeyapp makes it behave more sanely.

Handle devices without UUID

Devices with firmware version 1.0.0 do not report a UUID. We should detect this and show an error message recommending a firmware upgrade with pynitrokey.

Fix tab styling

Fix the style for the current and selected tabs of the main tab widget.

Does not work on MacOS X 12.6.3 Monterey - ModuleNotFoundError: No module named 'nitrokeyapp.ui.resources_rc'

Installation according to the instructions on MacOS X 12.6.3 Monterey does not work. Is this a known issue or expected?

I get the following error message:

(venv) xxxx@xxxx nitrokey-app2 % nitrokeyapp
Traceback (most recent call last):
File "/Users/xxxx/src/nitrokey-app2/venv/bin/nitrokeyapp", line 5, in
from nitrokeyapp.main import main
File "/Users/xxxx/src/nitrokey-app2/venv/lib/python3.9/site-packages/nitrokeyapp/main.py", line 5, in
import nitrokeyapp.ui.resources_rc # noqa: F401
ModuleNotFoundError: No module named 'nitrokeyapp.ui.resources_rc'

% nitropy version
Command line tool to interact with Nitrokey devices 0.4.35
0.4.35

% python --version
Python 3.9.6

% uname -a
Darwin xxxx 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64 x86_64

Feature Request: Flatpak Support (Linux)

Hello!

Please consider Flatpak support for your new Nitro App 2. I think this would be the most accessible way for Linux users to enjoy your software. Flatpak has become the de-facto standard across all Linux distros. I think it'd be really great and I would totally use your app on FlatHub.

Can't run on linux (neither from sources nor published binaries

Once I start the app, whether from sources or from the binary I get:

Auto configuration failed
139728798517056:error:25FFF06C:DSO support routines:CRYPTO_internal:functionality not supported:dso/dso_lib.c:226:
139728798517056:error:0EFFF06E:configuration file routines:CRYPTO_internal:error loading dso:conf/conf_mod.c:273:module=providers, path=providers
139728798517056:error:0EFFF071:configuration file routines:CRYPTO_internal:unknown module name:conf/conf_mod.c:214:module=providers

Smells like some symbols aren't the ones expected?

.ui to .py file conversion problem

Currently the .py files are not part of the repository and must be generated after checkout using make build-ui, this approach was chosen to avoid checking in generated files.

This approach introduces the drawback that an additional step is needed to run the app. Best case we find a way to use the .ui files directly within python so no additional (make) step is needed ...

Improve log handling

  • There should be a way to determine the log location for the current run.
  • Unhandled exceptions should be caught and shown to the user.
  • There should be a helper dialog for submitting a log file if an exception occurred (or triggered manually).

Add OTP support

  • list OTP credentials
  • create and delete OTP credentials
  • generate OTP for credential

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.