WIP keylogger

This commit is contained in:
James S 2023-01-06 13:16:30 -08:00
parent 665333bbbe
commit 0c57e4e021
2 changed files with 77 additions and 18 deletions

View File

@ -7,18 +7,21 @@ namespace FemboyWatchdog
{
static class GlobalHooks
{
public delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
public static IntPtr SetHook(LowLevelMouseProc proc)
public static IntPtr SetHook(int idHook, HookProc proc)
{
using (Process curProcess = Process.GetCurrentProcess())
using (ProcessModule curModule = curProcess.MainModule)
{
return SetWindowsHookEx(WH_MOUSE_LL, proc,
return SetWindowsHookEx(idHook, proc,
GetModuleHandle(curModule.ModuleName), 0);
}
}
public const int WH_KEYBOARD = 2;
public const int WH_KEYBOARD_LL = 13;
public const int WH_MOUSE = 7;
public const int WH_MOUSE_LL = 14;
public enum MouseMessages
@ -31,6 +34,11 @@ namespace FemboyWatchdog
WM_RBUTTONUP = 0x0205
}
public enum KeyboardMessages
{
WM_CHAR = 0x0102
}
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
@ -50,7 +58,7 @@ namespace FemboyWatchdog
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SetWindowsHookEx(int idHook,
LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);
HookProc lpfn, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]

View File

@ -9,6 +9,7 @@ using System.Net;
using System.Runtime.InteropServices;
using System.Speech.Synthesis;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using AForge.Video;
using AForge.Video.DirectShow;
@ -18,7 +19,7 @@ namespace FemboyWatchdog
public partial class Monitor : Form
{
private DateTime clockIn = DateTime.Now;
private LocationProvider tracker;
private SpamProvider spammer;
@ -26,27 +27,39 @@ namespace FemboyWatchdog
private VideoCaptureDevice videoDevice;
private VideoCapabilities[] videoCapabilities;
private Timer labelBlinkTimer;
private Timer ttsTimer;
private Timer mousemvmtTimer;
private System.Windows.Forms.Timer labelBlinkTimer;
private System.Windows.Forms.Timer ttsTimer;
private System.Windows.Forms.Timer mousemvmtTimer;
private int mousemvmtCount = 0;
/* mouse movements come in as a stream, so we'll say a mouse movement is "over" by waiting
a certain time with no movement */
private Timer lastmousemvmtTimer;
private System.Windows.Forms.Timer lastmousemvmtTimer;
private SpeechSynthesizer ss;
private SolidBrush brush = new SolidBrush(Color.Red);
private Font font = new Font(FontFamily.GenericSansSerif, 24);
private GlobalHooks.LowLevelMouseProc _proc;
private static IntPtr _hookID = IntPtr.Zero;
private GlobalHooks.HookProc _mouseProc;
private static IntPtr _mouseHookID = IntPtr.Zero;
private GlobalHooks.HookProc _kbProc;
private static IntPtr _kbHookID = IntPtr.Zero;
private string keyloggerBuffer;
private static string[] keyloggerKeywords = {
"fembooru", "femboyfinancial", "femboywatchdog", "accounts payable",
"femboycliquere", "femboybanking", "femboygeometry"
};
public Monitor()
{
_proc = OnMouseMessage;
GlobalHooks.SetHook(_proc);
_mouseProc = OnMouseMessage;
GlobalHooks.SetHook(GlobalHooks.WH_MOUSE_LL, _mouseProc);
_kbProc = OnKeyboardMessage;
GlobalHooks.SetHook(GlobalHooks.WH_KEYBOARD_LL, _kbProc);
InitializeComponent();
ss = new SpeechSynthesizer();
@ -54,14 +67,14 @@ namespace FemboyWatchdog
tracker = new LocationProvider();
spammer = new SpamProvider();
ttsTimer = new Timer();
ttsTimer = new System.Windows.Forms.Timer();
ttsTimer.Interval = 15000;
labelBlinkTimer = new Timer();
labelBlinkTimer = new System.Windows.Forms.Timer();
labelBlinkTimer.Interval = 1000;
mousemvmtTimer = new Timer();
mousemvmtTimer = new System.Windows.Forms.Timer();
mousemvmtTimer.Interval = 60000;
mousemvmtTimer.Start();
lastmousemvmtTimer = new Timer();
lastmousemvmtTimer = new System.Windows.Forms.Timer();
lastmousemvmtTimer.Interval = 500;
// hook events
@ -75,6 +88,44 @@ namespace FemboyWatchdog
ttsTimer.Start();
}
private IntPtr OnKeyboardMessage(Int32 code, IntPtr wParam, IntPtr lParam)
{
Int32 msgType = wParam.ToInt32();
Int32 charCode = wParam.ToInt32();
Int32 repeatCount = lParam.ToInt32() & 0xFFFF;
string key = "";
if (code >= 0 && msgType == GlobalHooks.WM_CHAR)
{
charCode = Marshal.ReadInt32(lParam);
}
buf += keys.ToString();
foreach (string keyword in keywords)
{
if (buf.ToLower().Contains(keyword))
{
ShowBonusBalloon(keyword);
buf = "";
break;
}
}
}
private void ShowBonusBalloon(string keyword)
{
NotifyIcon ni = new NotifyIcon();
ni.Visible = true;
ni.Icon = SystemIcons.Application;
ni.BalloonTipTitle = "Bonus earned!";
ni.BalloonTipText = string.Format(
"Thank you for discussing {0}! +0.05 USD has been deposited into your account.",
keyword
);
ni.ShowBalloonTip(10000);
Thread.Sleep(15000);
ni.Dispose();
}
private void lastmousemvmtTimer_Tick(object sender, EventArgs e)
{
++mousemvmtCount;
@ -117,7 +168,7 @@ namespace FemboyWatchdog
if (!lastmousemvmtTimer.Enabled)
lastmousemvmtTimer.Start();
}
return GlobalHooks.CallNextHookEx(_hookID, nCode, wParam, lParam);
return GlobalHooks.CallNextHookEx(_mouseHookID, nCode, wParam, lParam);
}
private void OpenCamera()