Giter Club home page Giter Club logo

usb_log's Introduction

USB logging

Finds all USB devices and makes a log of them.

Intended use case

The main purpose of this program is to log all known drives.
This can be done by plugging all of the USB devices into the PC and store their ID in a log file.
Later, if a USB drive is inserted and is not in the logs, it should be blacklisted.

How it works

It looks at all drives on the PC, if a drive is identified as a USB, the program will get its information (that information can be used anywhere later).
During the program's runtime each device's serial number is stored in an array, hence it won't be logged twice.

Information stored

By default, the program will get the device's serial number, media type and bus type.

For this, the program uses STORAGE_DEVICE_DESCRIPTOR:
https://learn.microsoft.com/en-us/windows/win32/api/winioctl/ns-winioctl-storage_device_descriptor

    STORAGE_DEVICE_DESCRIPTOR* pDeviceDescriptor = reinterpret_cast<STORAGE_DEVICE_DESCRIPTOR*>(pOutBuffer.get());

From the above descriptor, the following data are taken:

   const DWORD dwSerialNumberOffset = pDeviceDescriptor->SerialNumberOffset;
   const char* serialNumber = reinterpret_cast<const char*>(pOutBuffer.get() + dwSerialNumberOffset);
   const BOOLEAN boRemovableMedia = pDeviceDescriptor->RemovableMedia;
   const STORAGE_BUS_TYPE  busType = pDeviceDescriptor->BusType

On boot

The program adds an entry named Pendrive to SOFTWARE\Microsoft\Windows\CurrentVersion\Run registry so, that on start-up the program will run automatically.

Background process

The program's window is hidden, therefore acts like a background process.

usb_log's People

Contributors

kristofhracza avatar

Stargazers

 avatar Koen avatar

Watchers

 avatar

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.