{"id":20095105,"url":"https://github.com/patilyashh/usb_key","last_synced_at":"2025-03-02T16:20:17.115Z","repository":{"id":238574865,"uuid":"796854357","full_name":"PATILYASHH/USB_KEY","owner":"PATILYASHH","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-07T08:58:37.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T03:33:18.284Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PATILYASHH.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-05-06T18:46:38.000Z","updated_at":"2024-09-24T04:20:42.000Z","dependencies_parsed_at":"2024-05-06T19:57:11.313Z","dependency_job_id":"93f48b92-0d23-4833-bcf7-ddb959aab815","html_url":"https://github.com/PATILYASHH/USB_KEY","commit_stats":null,"previous_names":["patilyashh/usb_key"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PATILYASHH%2FUSB_KEY","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PATILYASHH%2FUSB_KEY/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PATILYASHH%2FUSB_KEY/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PATILYASHH%2FUSB_KEY/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PATILYASHH","download_url":"https://codeload.github.com/PATILYASHH/USB_KEY/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241534448,"owners_count":19977970,"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-11-13T16:54:05.846Z","updated_at":"2025-03-02T16:20:17.096Z","avatar_url":"https://github.com/PATILYASHH.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# USB Device Event Handler\n\n## Description\n\nThe USB Device Event Handler program outlines a system login process that utilizes a USB device for user authentication. Here's a breakdown of the process:\n\n1. **USB Insertion**:\n   - The process begins when a USB device is inserted into the system.\n\n2. **Check USB Device**:\n   - The system verifies if the inserted USB device is the specific USB device designated for user authentication.\n\n3. **Specific USB Detected**:\n   - If the inserted USB device matches the specific USB device, the default user currently logged into the system is logged out.\n   - Subsequently, the system proceeds to log in the specific user associated with the detected USB device.\n\n4. **Default Session Resumption**:\n   - If the inserted USB device does not match the specific USB device, the system resumes the default user session without any changes.\n\n5. **User Logged In**:\n   - Once the specific user (presumably associated with the inserted USB device) is logged in, the system monitors for USB removal.\n\n6. **USB Removal Check**:\n   - The system continuously checks if the USB device is removed from the system.\n\n7. **USB Removed**:\n   - If the USB device is removed, indicating that the user has removed their authentication token, the specific user is logged out.\n   - Following this, the system logs in the default user, returning the system to its initial state.\n\n8. **Process Continues**:\n   - The process continues to monitor USB insertion and removal events, repeating the authentication and user login/logout cycle as necessary.\n\nThis flowchart suggests a security application where a USB key serves as a form of two-factor authentication, allowing access to a specific user account only when the corresponding USB device is present. This approach enhances system security by requiring both a password and physical possession of the USB device for user authentication.\n\n## Dependencies\n\nTo compile and run this program, you need:\n\n- Windows operating system\n- Visual Studio or another C compiler for Windows\n- Windows Driver Kit (WDK) for the required header files and libraries\n\n## Overview\n\nThe program performs the following tasks:\n\n1. Initializes COM library.\n2. Connects to the local WMI namespace.\n3. Sets security on the proxy.\n4. Creates an unsecured apartment.\n5. Creates a sink for event notifications.\n6. Requests notification for USB device insertion/removal events.\n7. Listens for events until the user exits.\n8. Cleans up resources before exiting.\n\n## How It Works\n\n- The program defines functions for specific actions to be taken when USB events occur, such as logging in/out users.\n- It defines a WMI event handler struct and implements its functions to handle event notifications.\n- Event notifications are received asynchronously using `ExecNotificationQueryAsync`.\n- When a USB event occurs, the corresponding action functions are called based on the event type.\n\n## Usage\n\n1. Compile the program using a C compiler.\n2. Run the compiled executable.\n3. The program will start listening for USB device events.\n4. Plug in or remove USB devices to trigger events.\n5. Press Enter to exit the program.\n\n## Remaining Work\n\nThe README should include:\n\n- Code snippets for specific functions (if not already provided).\n- Instructions on how to compile the program.\n- Any additional usage details or considerations.\n- Acknowledgment of external libraries or code references (if applicable).\n\n## Remaining Code to Write\n\n1. Implementation of specific action functions (e.g., `LogoutDefaultUser`, `LoginSpecificUser`, etc.).\n2. Code snippets for the WMI event handler struct and its functions.\n3. Instructions for compiling the program with necessary dependencies.\n\n## Disclaimer\n\nThis program is provided as-is and may need modifications to fit specific requirements or environments. Ensure proper permissions and test thoroughly before deploying it in a production environment.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatilyashh%2Fusb_key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatilyashh%2Fusb_key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatilyashh%2Fusb_key/lists"}