chore: add review notes, update README, refactor build scripts, and enable new publish workflow
This commit is contained in:
@@ -1,35 +1,46 @@
|
||||
markdown
|
||||
# Keylogger Program Analysis
|
||||
# Keyboard Input Event Logger Summary
|
||||
|
||||
## Overview
|
||||
|
||||
This document reviews a C-based program designed to monitor multiple keyboard devices for input events and log them into a database. The code includes mappings of keycodes to character representations and utilizes system calls to interact with input devices efficiently.
|
||||
This C program captures keyboard input events, resolves device names, and logs these events into a specified SQLite database `tikker.db`. It utilizes a custom library `sormc.h` for database management.
|
||||
|
||||
## Code Highlights
|
||||
## Features
|
||||
|
||||
### Bugs
|
||||
- **Key Mapping:** The `keycode_to_char` array lacks comprehensive keycode definitions, leading to potential null pointer dereferences.
|
||||
- **Security Risk:** SQL injection vulnerability due to direct variable embedding in queries.
|
||||
- **Unhandled Returns:** Undefined behavior for unknown keycodes, potentially causing `NULL` insertions in the database.
|
||||
- **Key Event Mapping**: Maps keycodes to their respective characters for better representation.
|
||||
- **Event Logging**: Logs key events with timestamps efficiently into the database.
|
||||
- **User Configuration**: Allows device selection via a command-line option for targeted event capturing.
|
||||
- **MIT License**: Allows free use, modification, and distribution of the software.
|
||||
|
||||
### Optimizations
|
||||
- Implement error handling for `snprintf` in loops and use `strncasecmp` for safer keyboard checks.
|
||||
- Minimize `EVIOCGNAME` calls by caching device names.
|
||||
- Bound checks to prevent `keycode_to_char` array access overflow and batch `read` operations for performance.
|
||||
- Ensure proper resource cleanup, including database connection closure.
|
||||
- Adopt dynamic memory allocation if `device_path` exceeds 32 characters.
|
||||
## Bugs and Issues
|
||||
|
||||
### Strengths
|
||||
- Efficient monitoring of multiple devices using `fd_set` and `select()`.
|
||||
- Proper use of `snprintf` to prevent buffer overflow.
|
||||
- Logical division between device acquisition and event processing.
|
||||
1. **Undefined Functions**: Missing definitions for `rargs_get_option_string`, `sormc`, and `sormq`, leading to potential undefined behavior.
|
||||
2. **Device Resolution**: Uses `O_RDONLY` to open devices, which may need root access, potentially causing permission issues.
|
||||
3. **Array Boundaries**: Access to `keycode_to_char` without bounds checking could lead to undefined behavior.
|
||||
4. **Error Handling**: Lack of checks after using `snprintf`, `open`, and `ioctl`, leading to potential failures and bugs.
|
||||
|
||||
## Summary
|
||||
## Recommendations
|
||||
|
||||
Despite its functional capability, the program presents issues primarily in security, efficiency, and resource management. Addressing vulnerabilities and performance limitations could substantially enhance its reliability.
|
||||
- **Argument Parsing**: Use robust libraries for better flexibility and error management.
|
||||
- **Signal Handling**: Implement graceful termination with proper file descriptor management.
|
||||
- **Error Checking**: Add checks post `snprintf`, `open`, and `ioctl` to handle errors effectively.
|
||||
- **Optimize Performance**: Reduce redundancy in `printf` statements for better efficiency.
|
||||
|
||||
### Recommendations
|
||||
## Positive Attributes
|
||||
|
||||
Consider using open-source alternatives for better functionality:
|
||||
- **Logkeys:** Offers broader functionality and community support.
|
||||
- **Keylogger:** Lightweight with active development on GitHub.
|
||||
- Effectively maps keycodes to characters.
|
||||
- Provides informative console output for ongoing events.
|
||||
- Efficient database logging of key events.
|
||||
|
||||
## Potential Improvements
|
||||
|
||||
To enhance its robustness and user-friendliness, the program needs the implementation of missing functions and improved error-handling mechanisms.
|
||||
|
||||
## Alternative Open Source Tools
|
||||
|
||||
- **logkeys**: A Linux keylogger similar in function.
|
||||
- **Keylogger (Python)**: Uses `pynput` for cross-platform keylogging.
|
||||
- **Linux-dirty-injector**: Provides additional functionalities including keylogging.
|
||||
|
||||
---
|
||||
*Note: The program is reviewed with a grade of 6.0, suggesting more development is needed in error handling and functionality completion.*
|
||||
|
||||
Reference in New Issue
Block a user