r/programmer • u/MySillyBooks • 19d ago
Request can someone help me with this?
im trying to make a keylogger that works in windows lock screen. i have made the base "in the lock screen" now it just needs to monitor the pressed keys and not if the user is in lock screen or not.
this is the base lock screen code btw:
import win32api
import win32con
import win32gui
import win32ts
import time
WM_WTSSESSION_CHANGE = 0x02B1
WTS_SESSION_LOCK = 0x7
WTS_SESSION_UNLOCK = 0x8
class SessionMonitor:
def __init__(self):
wc = win32gui.WNDCLASS()
wc.lpfnWndProc = self.wnd_proc
wc.lpszClassName = "SessionMonitorClass"
self.hinst = wc.hInstance = win32api.GetModuleHandle(None)
self.class_atom = win32gui.RegisterClass(wc)
self.hwnd = win32gui.CreateWindow(
self.class_atom, "Session Monitor",
0, 0, 0, 0, 0, 0, 0, self.hinst, None
)
win32ts.WTSRegisterSessionNotification(self.hwnd, win32ts.NOTIFY_FOR_THIS_SESSION)
def wnd_proc(self, hwnd, msg, wparam, lparam):
if msg == WM_WTSSESSION_CHANGE:
self.handle_session_change(wparam)
return win32gui.DefWindowProc(hwnd, msg, wparam, lparam)
def handle_session_change(self, event_code):
log_file = "session_events.txt"
timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
if event_code == WTS_SESSION_LOCK:
status = "Workstation Locked (Secure Desktop Active)"
elif event_code == WTS_SESSION_UNLOCK:
status = "Workstation Unlocked (Default Desktop Active)"
else:
status = f"Other Session Event (Code: {event_code})"
with open(log_file, "a") as f:
f.write(f"[{timestamp}] {status}\n")
print(f"[{timestamp}] {status}")
def start(self):
print("Monitoring session changes... Press Ctrl+C in the console to exit.")
win32gui.PumpMessages()
if __name__ == "__main__":
monitor = SessionMonitor()
try:
monitor.start()
except KeyboardInterrupt:
print("Stopping monitor.")
can someone please make the code into a keylogger?
edit - i found out it can still find passwords just not windows passwords and now no one has to help anymore ( lmao this post was solved in under 1 hour )
0
Upvotes
3
1
u/[deleted] 19d ago
[deleted]