Lvl4Sword / Killer

🔪 System tamper detector for USB, Bluetooth, AC, Battery, Disk Tray, and Ethernet.
https://pypi.org/project/killer/
GNU Affero General Public License v3.0
71 stars 11 forks source link

Consider using libusb instead of running commands #42

Closed jomo closed 2 years ago

jomo commented 5 years ago

libusb works basically everywhere and provides a single interface to list and interact with usb devices.

Lvl4Sword commented 5 years ago

Thanks for the issue. Will look at this when I'm not as swamped!

GhostofGoes commented 5 years ago

This doesn't seem to work on Windows. I can't get pyusb to work without having to install the driver manually, and pip install libusb doesn't help either. If we can't pull in everything needed with Python dependencies, then that's a hard stop.

Lvl4Sword commented 5 years ago

@jomo What do you think about what @GhostofGoes said? To me this looks like a no go if the driver has to be manually installed.

pep7 commented 5 years ago

@GhostofGoes did your try pip install libusb1?

libusb is a lib written in C with Haiku in C++. https://github.com/libusb/libusb

libusb1 is a python module for libusb and can be found via the following urls:

According to this, windows is supported https://pypi.org/project/libusb1/1.6.4/#supported-oses

Installation https://pypi.org/project/libusb1/1.6.4/#installation

@jomo I think you have a great idea.

GhostofGoes commented 5 years ago

No, I wasn't aware of libusb1. I'll give it a try in a day or two once I'm on a Windows box.

GhostofGoes commented 5 years ago

It installed fine into a virtual environment with pip install libusb1. However, it failed to import due to an issue loading a DLL. Full traceback below:

(killer) Killer master $ python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import usb1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\goesc\.virtualenvs\killer\lib\site-packages\usb1\__init__.py", line 61, in <module>
    from . import libusb1
  File "C:\Users\goesc\.virtualenvs\killer\lib\site-packages\usb1\libusb1.py", line 199, in <module>
    libusb = _loadLibrary()
  File "C:\Users\goesc\.virtualenvs\killer\lib\site-packages\usb1\libusb1.py", line 173, in _loadLibrary
    return dll_loader('libusb-1.0' + suffix, **loader_kw)
  File "C:\Users\goesc\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

As I said before, we want something that is able to be installed via pip with no any extra dependencies, like requiring the user to separately download and install a library or other package.

Lvl4Sword commented 3 years ago

What with Windows not being an issue anymore, this issue and #58 need to be consolidated.

Lvl4Sword commented 2 years ago

This is fixed in the new branch