Coder Social home page Coder Social logo

errbufferoverfl / usb-canary Goto Github PK

View Code? Open in Web Editor NEW
572.0 33.0 67.0 62 KB

A Linux or OSX tool that uses psutil to monitor devices while your computer is locked. In the case it detects someone plugging in or unplugging devices it can be configured to send you an SMS or alert you via Slack or Pushover.

License: GNU General Public License v3.0

Python 100.00%
python detection monitoring slack twilio usb

usb-canary's Introduction

˖⁺‧₊˚❀˚₊‧⁺˖

If ever you think you’ve lost me, just go where flowers grow.
I will too. And we’ll always find each other again.

˖⁺‧₊˚❀˚₊‧⁺˖

[site]

usb-canary's People

Contributors

errbufferoverfl avatar helpstertee avatar timball 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  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  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

usb-canary's Issues

Misleading advertisement

The README sais about usb-canary that its function is to "monitor USB devices", just as its name suggests. However, as far as I can tell it is only monitoring mounted physical partitions.

  • Feature Request
  • Bug Report

Possible Solution

Clearly document what is monitored, under which conditions alerts will happen and what use this is applied to common threat models.

I would also highly suggest a note pointing out that usb-canary is experimental, early stage software and should absolutely not be relied upon in critical situations.

Context

usb-canary at least on first glance looks like a security tool. For any security tool, clear and precise communication as to its threat model and scope are necessary for it to be used correctly.

An important omission is that currently, usb-canary will not detect one of the most common classes of usb-based attacks, available to anyone: Fake HID-Class keyboard devices. In contrast, properly implemented even a change such as inserting a keylogger could be detected.

Pushover support

  • Feature Request
  • Bug Report

Expected Behavior

It would be nice to use Pushover as an alternative channel of notification transportation.

Current Behavior

usb-canary does not currently use Pushover as a channel of notification transportation.

Possible Solution

Implement Pushover as a channel of notification transportation

Steps to Reproduce (for bugs)

N/A

Context

I like to use Pushover for notification transportation. Unfortunately this is currently not supported.

usb-canary will exit due to errors

In several places, usb-canary will quietly exit depending on external conditions. One such place is the twilio message handler. If a mere network error occurs, it will quietly exit.

  • Feature Request
  • Bug Report

Expected Behavior

When a messaging channel is configured and errors occur, usb-canary should asynchronously retry as many times as necessary to send the message. Under no conditions should failure of one messaging channel prevent other intact channels from working.

Current Behavior

If e.g. twilio and slack are enabled, and the twilio code raises an error, usb-canary will exit without even attempting to use slack.

Possible Solution

Handle all messaging asynchronously with appropriate back-off.

Steps to Reproduce (for bugs)

Context

usb-canary at least on first glance looks like a security tool. Thus it should be secure.

Your Environment

This is independent of operating system.

ImportError No Module named daemon.daemon

I tried running the tool on Kali Linux, but I get this error message. I installed all the dependencies and configured the settings.json file and put it in the root directory as specified but I still get this error.
Did I miss something ?

# ./usb-canary.py start
Traceback (most recent call last):
File "./usb_canary.py", line 34, in <module>
from canary.daemon.daemon import Daemon
ImportError: No module named daemon.daemon

check_state will not catch changes that don't change the total number of mounted file systems

canary.operating_system.helpers.check_state will fail to catch any change in mounted file systems that does not change the total number of mounted file systems (as seen by psutil).

  • Feature Request
  • Bug Report

Expected Behavior

Consider a laptop with usb-canary running during screen lock, and the screen being locked while a usb disk containing a single ntfs partition is attached and that partition is mounted. Automount is enabled.

Now consider an attacker unplugs the ntfs usb disk and plugs in another ntfs-formatted, single-partition usb-disk. This other disk is auto-mounted. Note that this is a common scenario when a device has limited USB ports available.

usb-canary should immediately raise hell.

Current Behavior

usb-canary will not notice anything happened provided the change happened quick enough between two checks (likely).

Possible Solution

Properly compare states. Compare more than just device name, mountpoint, filesystem type and options. At least also monitor:

  • Device path (usb port number and path through hubs)
  • Device serial number from USB descriptors
  • Filesystem UUID where available
  • Partition and device UUIDs where available
  • Other device parameters such as size and additional usb descriptor fields

Steps to Reproduce (for bugs)

(no poc provided)

Context

usb-canary at least on first glance looks like a security tool. Thus it should be secure.

Your Environment

This is independent of operating system.

use udev instead of compare prev and now state

Hi,
It's better for this project use from udev capability instead compare state.
We can use pydev that monitor all ports in computer. Ex,

import pyudev
context = pyudev.Context()
monitor = pyudev.Monitor.from_netlink(context)
monitor.filter_by('block')
def log_event(action, device):
    if 'ID_FS_TYPE' in device:
        print('{0} - {1}'.format(action, device.get('ID_FS_LABEL'))

observer = pyudev.MonitorObserver(monitor, log_event)
observer.start()
# when connect a device print below messsage, Ex
# add - Hard1

by above example, when connected or disconnect a device to computer run log_event function and can run any action!

Possible DOS due to blocking network handling

Since all message sending is done in a blocking manner, inlined with the actual detection logic and since that is running in an infinite loop (side note: a delay or even better, some asynchronous notification systems such as inotify might be in order here), an attacker able to disrupt usb-canary may be able to stall it, preventing detection.

  • Feature Request
  • Bug Report

Expected Behavior

usb-canary should operate and correctly log regardless of network conditions that might make the message sending code block.

Current Behavior

usb-canary will hang during bad network conditions.

Possible Solution

Handle message sending asynchronously, ideally with one asynchronous channel for every configured message channel.

Steps to Reproduce (for bugs)

Context

usb-canary at least on first glance looks like a security tool. Thus it should be secure.

Your Environment

This will likely affect all supported operating systems.

Non-automounted filesystems are ignored

usb-canary only monitors what psutil considers "physical", mounted partitions. This means any attached device that does not automount while usb-canary is active (e.g. while the screen is locked) will not be caught.

  • Feature Request
  • Bug Report

Expected Behavior

Consider the following setup: There is a laptop, with usb-canary configured to monitor while the screen is locked. Automounting is disabled. The user locks the screen, goes away. During her absence, a coworker of her goes near the laptop and finds a USB stick lying on the ground. Thinking the USB stick fell out, she picks it up and plugs it in. Later, the user returns to unlock her laptop. At this point, usb-canary will not have picked up on the additional device since it is not mounted yet. However, now that the laptop is unlocked, she or some automatism might inadvertently mount the filesystem of the usb stick.

Current Behavior

usb-canary does not pick up on the new device absent automounting.

Possible Solution

Monitor physical block devices, or even better, monitor physical USB devices instead of mounted partitions.

Steps to Reproduce (for bugs)

Context

usb-canary at least on first glance looks like a security tool. Thus it should be secure.

Your Environment

I'm no mac expert, but this issue will very likely persist on mac since this "list only mounted filesystems thing" is the documented behavior of psutil's list_partitions.

Windows version

What will it be...?

usbcanary.exe
--install --- install as service and start it
--uninstall --- remove service
--config X:/y/z.config --- pick other config file(if not set, read ./usbcanary.config file)

usbcanary.config
UseWebAPI false
UseHTTPProxy 1.2.3.4:5
PlaySoundOnDetect true
Soundfile X:/y/z/p.mp3
RunCommandOnDetect true
RunCommand "shutdown -s -t 0"

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.