Giter VIP home page Giter VIP logo

killer's Introduction

killer's People

Contributors

ghostofgoes avatar gitter-badger avatar lvl4sword avatar markkoz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

killer's Issues

Add systemd support

Would be great to add support for starting with systemctl and documenting it in the README.md.

Vagrant

Create a Vagrantfile with: Windows 7, Windows 10, Ubuntu 16, Ubuntu 18, and Fedora. Any others TBD and can be added as needed. This will make testing much easier since a lot of us don't have access to systems with all of the platforms we want to support, and creating VMs by hand is a pain.

Bluetooth Detection

Current Windows test system I have doesn't have Bluetooth, so will need some help on this.

Ethernet support [Windows]

import subprocess
import json
a = subprocess.check_output(["powershell.exe" ,"Get-NetAdapter | select Name, MacAddress, Status |  ConvertTo-Json -Compress"])
b = json.loads(a)
print(b)

is a good beginning to this

CD Tray Detection

for each in wmi.WMI().Win32_CDROMDrive():
    print(each)

should be a good start for this.

PyPI Packaging

Once Killer has full Linux/Windows/Mac support, I'd like to get this formally packaged so others may pip install it.

Automated testing (CI)

Add automated testing of all commits on all supported platforms. We can do this with the traditional TravisCI + Appveyor, or go with Azure Pipelines.

Preventing "USB Kill"

USB Kill ( https://usbkill.com/ - not afilliated ) is something that charges from the USB port and sends this electricity back into the port.

lsusb -v will show you Per-port overcurrent protection if a port can prevent this.
But having had not done any testing whatsoever with a system that has this, no clue if this type of detection can be trusted.

Testing will need to be done and it would need to happen on a system that could potentially be destroyed.
So, not any time soon unless someone wants to donate.

Use udev events

On Linux, we could take advantage of udev and avoid polling for changes.

Detect USB Devices [Windows]

Shout out to Chris Dent from https://www.experts-exchange.com/questions/27513069/powershell-command-to-identify-the-usb-device-id-based-upon-drive-letter-or-volume-name.html for the original script.

Get-WmiObject Win32_LogicalDisk -Filter 'DriveType=2' | ForEach-Object {
    $_ | Select-Object VolumeSerialNumber
}

This will get all VolumeSerialNumber of USB devices ( dictated by the filter DriveType=2 )

Only issue is that this takes about 3.5 seconds to run on a Windows 10, 1.8GHz i3 3rd gen CPU, 4GB RAM. May have to set the default time for USB checks to around 5 seconds for Windows because of this..

Supported Systems

Killer is only supported on Linux. If you're using something else, you're on your own.

Improve Windows distribution packaging

The current Windows installation story is non-standard for a typical Windows user. We should instead distribute it as either a stand-alone executable or a installer. The advantage of an installer is we can install a persistent background Service that the user can toggle on/off, which reduces user disruption (there's no terminal window open). The advantage of a plain exe is it's easy to run and very portable. We could also do both.

Implementation of the exe will be done with PyInstaller and installer with pynsist.

The current flow is:

  1. Download the right version of Python from python.org
  2. Install Python (and pray the default options work)
  3. Open a terminal
  4. pip install Killer (and hope they read the docs properly and use --user
  5. open terminal as Administrator and run killer (and hope it got put on the path)

Goal for standalone exe:

  1. Download killer_portable.exe from GitHub releases (eventually linked from github.io page)
  2. Run killer_portable.exe (and request admin rights with UAC when run)

Goal for installer:

  1. Download killer_installer.exe from GitHub releases (eventually linked from github.io page)
  2. Install killer_installer.exe (and request admin rights with UAC when run)
  3. Click "Enable Killer" and "Disable Killer" in start menu, "Configure Killer" to edit the configuration file (open it in Notepad++), and "Killer help" which hyperlinks to docs (GitHub wiki?).

Verify disk is encrypted before continuing

Killer is useless on a system that isn't encrypted. So, this should be checked.

import subprocess

physical_volumes = subprocess.check_output(['pvs', '-o', 'pv_name']).decode().split('\n')[1:-1]
for physical_volume in physical_volumes:
    physical_volume = physical_volume.strip()
    cryptsetup_status = subprocess.check_output(['cryptsetup', 'status', physical_volume]).decode().split('\n')
    _, type = cryptsetup_status[1].split()
    if type == 'LUKS2':
        print(f'{physical_volume} is encrypted with LUKS!')

the above is a great first step. Will need to do verification/checks on external drives that are encrypted, though.
Looks like it works just fine on an external drive connected via USB, as the external doesn't show up.
But am unsure ( and can't test ) on two or more internal drives that are encrypted.

Make first run/debug enjoyable for the user

Right now there's a lot that needs to be manually done.
Currently on first run the user needs to:

  1. Run debug
  2. Manually input what was displayed into the configuration file
  3. Hope they didn't get it wrong because otherwise the system is shutting off

This should be far more smoother than it is now.

expand on lsusb [Linux]

import subprocess
import re
a = re.compile(r'\bID \S+ (.+)')
b = re.findall(a, subprocess.check_output('lsusb', shell=False).decode('utf-8'))
print([each.strip() for each in b])

Would like to follow more than device ids and this is a good start.

Better README

Better explain what Killer does/is.
(Un)plugging devices, whitelists, USB connected whitelist, etc

Remove Windows Support

I've decided to stop supporting Windows. I've spent nearly 2 years trying to find out a speedy way of handling the Bluetooth/CD tray issues and it's just not worth it to me.

If you find a way to support both of these, @ me.


This issue will be closed when everything with Windows is torn out.

ScreamLock

Shamelessly stolen from @PowerPress via github/usbkill:
Have the app monitor the decibels coming from the microphone and let the user set a threshold. If the threshold is passed shut down the PC. Example being prevented from touching your PC but by screaming or a loud noise would trigger the shutdown allowing a hands free system.

Incorrect Config Parsing

Lists are not parsed properly. There is no concept of a list in configparser. The canonical way of having lists is to delimit the elements and then split the string by the delimiter when parsing.

Also, the default config is missing some keys for windows. Namely USB_ID_WHITELIST and USB_CONNECTED_WHITELIST.

Package killer for Debian

This would be a nice addition to PureOS from Purism, which is based on Debian, so it can be integrated for the Librem 5 for example.

Firewire Detection

It would be nice to have this. Though, considering I don't have a system that supports it, this is going to be a while.

Add NFC Support

NFC is very short range so by adding NFC support you could wear and NFC ring or bracelet and once you get about a foot away it will lose connection making it a great way to shutdown the pc.

Connected USB Whitelist Bypass

Someone could easily connect a device that has the same Vendor/Product IDs as a device already connected, as this isn't checked. This should be checked and shutdown if detected/attempted.

Realistically you're not going to have two devices with the same Product/Vendor IDs ( please present proof to the contrary ).

Detect battery status ( present / not present ) [Windows]

import ctypes
from ctypes import wintypes

class SYSTEM_POWER_STATUS(ctypes.Structure):
    _fields_ = [
        ('ACLineStatus', ctypes.c_ubyte),
        ('BatteryFlag', ctypes.c_ubyte),
    ]

SYSTEM_POWER_STATUS_P = ctypes.POINTER(SYSTEM_POWER_STATUS)

GetSystemPowerStatus = ctypes.windll.kernel32.GetSystemPowerStatus
GetSystemPowerStatus.argtypes = [SYSTEM_POWER_STATUS_P]
GetSystemPowerStatus.restype = wintypes.BOOL

status = SYSTEM_POWER_STATUS()
if not GetSystemPowerStatus(ctypes.pointer(status)):
    raise ctypes.WinError()
else:
    print('ACLineStatus', status.ACLineStatus)
    print('BatteryFlag', status.BatteryFlag)

Pulled from https://stackoverflow.com/questions/6153860/in-python-how-can-i-detect-whether-the-computer-is-on-battery-power#6156606 and using ctypes.c_ubyte rather than BYTE.

From https://docs.microsoft.com/en-us/windows/desktop/api/winbase/ns-winbase-_system_power_status the following are valid for the battery being present: [0, 1, 2, 4, 8, 9, 10, 12] , while 128 is if a battery cannot be detected.

AC Status [Windows]

WMI doesn't seem to provide this, so am shelving this until a way can be found.

Broken

Yes, I know the package is currently not working.
I'll leave this up and just change the label whenever something has been broken.

Fixed

Power is incorrectly parsed

Due to the following code, located at https://github.com/Lvl4Sword/Killer/blob/main/killer/posix/power.py#L68

def _get_property(device_path: Union[Path, str], property_name: str) -> str:
    """Gets the given property for a device."""
    with open(str(Path(device_path, property_name))) as file:
        return file.readline().strip()

online/present will return as a string, and thus bool() will count them as True regardless.
This issue is being created for transparency sake, and to inform that it's known and will be fixed in the new branch.

Logging

Should probably have logging.

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.