{"id":22961978,"url":"https://github.com/mathiscode/usb-see","last_synced_at":"2025-04-02T03:23:39.563Z","repository":{"id":264934403,"uuid":"829029606","full_name":"mathiscode/usb-see","owner":"mathiscode","description":"A simple tool written in C to detect changes in USB devices, and optionally execute a command when a change is detected","archived":false,"fork":false,"pushed_at":"2024-07-15T16:09:58.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T22:16:00.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathiscode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-15T15:59:04.000Z","updated_at":"2024-11-08T12:03:00.000Z","dependencies_parsed_at":"2024-11-29T01:19:35.668Z","dependency_job_id":null,"html_url":"https://github.com/mathiscode/usb-see","commit_stats":null,"previous_names":["mathiscode/usb-see"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiscode%2Fusb-see","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiscode%2Fusb-see/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiscode%2Fusb-see/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiscode%2Fusb-see/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathiscode","download_url":"https://codeload.github.com/mathiscode/usb-see/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246748299,"owners_count":20827302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T19:14:40.405Z","updated_at":"2025-04-02T03:23:39.541Z","avatar_url":"https://github.com/mathiscode.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# usb-see\n\nA simple tool written in C to detect changes in USB devices, and optionally execute a command when a change is detected.\n\nThis is designed to be used in scripts or other applications, or running as a daemon with the `watch` command.\n\nYou may alternatively use `udev` rules to monitor USB events, but this tool is more lightweight and easier to use.\n\nIf your goal is to mitigate the risk of USB-based attacks, consider using [usbguard](https://usbguard.github.io), which allows you to define policies for USB devices.\n\n## Installation\n\nDownload the latest release from the [releases page](https://github.com/mathiscode/usb-see/releases) and extract the binary to a directory in your PATH.\n\n-- OR --\n\n```sh\ngit clone --depth=1 https://github.com/mathiscode/usb-see.git\ncd usb-see\n\nmake \u0026\u0026 make install-user\n# or\nmake \u0026\u0026 sudo make install-system\n\nwhich usb-see # should show the path to the installed binary\n```\n\nTo uninstall, run `make uninstall-user` or `sudo make uninstall-system` in the usb-see repository, or simply delete the `usb-see` binary.\n\n## Usage\n\nusb-see *[OPTIONS]* **COMMAND**\n\n## Options\n\n- `--file` or `-f` - Path to the USB state file. Default: ~/.config/usb.state\n- `--exec` or `-e` - Command to execute when a change is detected. Default: false\n  - The command may contain the following placeholders:\n    - `_USB_` - The USB device line from `lsusb`\n    - `_ACTION_` - The action that occurred (`added` or `removed`)\n\n## Commands\n\n- `freeze` - Freeze the current USB state to the state file\n- `scan` - Scan for any added or removed USB devices\n- `watch` - Watch for changes in USB devices and execute a command when a change is detected\n\n## Examples\n\n- Freeze the current USB state to the default state file and scan for changes\n\n  ```sh\n  usb-see freeze\n  usb-see scan\n  ```\n\n- Freeze the current USB state to a custom state file\n\n  ```sh\n  usb-see --file /tmp/usb.state freeze\n  ```\n\n- Watch for changes in USB devices and execute a command when a change is detected\n\n  ```sh\n  usb-see --exec 'echo \"_USB_ was _ACTION_\"' watch\n  ```\n\n## Scan Exit Codes\n\n- 0: Success; no changes detected\n- 1: Device added\n- 2: Device removed\n- 255: An error occurred, most likely file access\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiscode%2Fusb-see","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathiscode%2Fusb-see","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiscode%2Fusb-see/lists"}