本人从事在线教育c 十年工作经验现在精心整理了一套从小白到项目实践开发各种学习资料如果你想学想加入我们请关注我在私信回复“编程”就可以领取学习资料!!

个人分类: c/c

英雄联盟不能输密码(Lol英雄联盟自动输入密码)(1)

Lol(英雄联盟)自动输入密码

搞了一天,终于把程序写好了,以后再也不用每次都手动输入密码了。尽管不是很完美,但可用性还是有的。我还是太年轻了,刚开始以为只要找到了密码框的句柄就搞定了,可找了许久仍然找不到。也许是我太年轻了,也许是Riot Games或者腾讯太牛逼了。最后只好用了稳定性不是很好的方法:直接模拟鼠标键盘输入,之所以这么说,因为我预测在很极端的情况,比如cpu比较繁忙的时候,在游戏输入密码界面获得焦点之前,模拟鼠标键盘的动作就开始了,那么必然会失败。还有就是焦点定位的问题,会因为显示屏的分辨率不同而不同,所以难免会出错。也许可以观察几种不同分辨率的显示屏找到一个兼容的方法,但我懒得找,自己能用就好了。所以读者如果想用的话,可以看下文,会有关于修改代码的方法,。当然也可以根据代码各种改,改成方便自己使用的程序。

下面介绍一下程序用法吧。主要有两个文件,主程序lol.exe和密码记录文件lol.ini。把这两个文件放到 英雄联盟\TCLS 的文件夹下,即Client.exe所在目录。想方便点呢,可以给lol.exe创建一个快捷方式,再移动快捷方式到桌面,或者写个启动lol.exe的bat放到桌面也可以。打开lol.exe有两个选项,第一是设定密码,第二是在英雄联盟进入了输入账号密码界面后可以自动输入密码。当然第一次使用该程序是需要设定密码的,以后就不需要,除非更改密码。对于管理员身份登录windows的用户(大多数人都是这样子),lol.exe发现英雄联盟还没有启动会自动自动英雄联盟的。而我一般是用标准用户(即非管理员),由于英雄联盟是要在管理员身份运行才可以玩的,因此要用其他方法。我目前就是在英雄联盟\TCLS 的文件夹创建一个bat,里面的内容是

runas /savecred /user:liulian Client.exe

lol.exe

就是先启动Client.exe,再自动lol.exe。然后给该bat创建一个快捷方式,放到桌面。

下面阐述一下原理吧。第一次使用该程序需要设定密码,设定密码后密码经过某种方法加密后存放到lol.ini文件中,本来想rsa算法加密一下,想到最近比较忙,算了,只好自己随便想了个算法加密,只要不会直接暴露密码就好了。每次自动输入密码,都是从lol.ini读出密码,解密后,再模拟鼠标键盘动作输入。每一次先将鼠标定位到下图的右下角的地方,在模拟鼠标点击事件,这样就让密码框获得键盘输入焦点了。最后就是根据密码,模拟键盘按键了。这方法兼容性就不是很好了,因为程序中我是根据像素坐标定位的。

英雄联盟不能输密码(Lol英雄联盟自动输入密码)(2)

在sendPswd函数中有这么一句

SetCursorPos(1012 origin.left,395 origin.top);

其中1012和395是上面那张图的宽和高,origin是上面的图的左上角的坐标点,这句话的意思就是讲鼠标定位到图中右下角的地方,即密码框中的一点。对于不同分辨率的显示屏,需要改动一下。

下面是代码:

#include <cstdio>

#include <iostream>

#include <windows.h>

#include <cstring>

#include <process.h>

enum Option{setPassword =1,sendPassword = 2};

Option opt ;

#define maxLen 88

#define keyLen 8

int key[]={0,9,3,8,8,2,9,6};//奇怪用数字就不会出错啊

LPCTSTR appName = "lol";

LPCTSTR keyName = "pwd";

//LPCTSTR value = "";

LPCTSTR iniFileName ="lol.ini";//<windows.h>

char fullPathName[maxLen];

HWND self;

char encodedPswd[maxLen];

char decodedPswd[maxLen];

extern "C" WINBASEAPI HWND WINAPI GetConsoleWindow ();

int main()

{

void init();

void showOption();

void setPswd();

void readPswd();

void decodePswd();

void sendPswd();

void close();

init();

int option = -1;

showOption();

while (opt == setPassword)

{

setPswd();

showOption();

}

readPswd();

decodePswd();

sendPswd();

close();

// system("pause");

return 0;

}

void printLine()

{

printf("-----------");

}

void waitForInput()

{

printLine();

printf(">");

}

unsigned int WINAPI getFocus(void*)

{

for(;;)

{

Sleep(1000);

SetForegroundWindow(self);

}

}

void init()

{

GetCurrentdirectory(maxLen,fullPathName);

strcat(fullPathName,"\\");

strcat(fullPathName,iniFileName);

self =GetConsoleWindow();

//SetForegroundWindow(self);

SetWindowPos(self,HWND_TOPMOST,0,0,0,0,SWP_NOSIZE|SWP_SHOWWINDOW);

_beginthreadex(NULL,0,getFocus,NULL,0,NULL);

}

void showOption()

{

printLine();

printf("1 要设定密码请输入1,再按回车");

printLine(); printf("\n");

printLine();

printf("2 要自动输入lol密码,请直接按回车(确保进入了输入密码画面)");

printLine(); printf("\n");

char ch;

waitForInput();

ch = getchar();

switch(ch)

{

case '1':

opt = setPassword;

break;

case '\n':

opt = sendPassword;//printf("enter");

break;

default:

exit(1);

}

}

void encodePswd()

{

// strcpy(encodedPswd,decodedPswd);//未加密,只是简单的拷贝

int i;

for( i=0;i<strlen(decodedPswd);i )

{

encodedPswd[i] = decodedPswd[i] ^key[i%keyLen];

}

encodedPswd[i]='\0';

}

void writePswd()

{

encodePswd();

bool suc = WritePrivateProfileString(appName,keyName,encodedPswd,fullPathName);

// int error = GetLastError();

// printf("error:%d",error);

if (suc)

printf("设定成功\n");

else printf("设置失败\n");

//终于知道为什么会拒绝访问 了,注意是windows目录需要权限,还有不是system32目录哦

//lpFileName ----- String,初始化文件的名字。如果没有指定完整路径名,

// 则windows会在windows目录查找文件。如果文件没有找到,则函数会创建它

}

void setPswd()

{

printLine();

printf("请输入密码");

printLine();printf("\n");

waitForInput();

scanf("%s",decodedPswd);

fflush(stdin);//清空输入流,因为上面用了getchar()

writePswd();

}

void decodePswd()

{

// strcpy(decodedPswd,encodedPswd);

int i;

for( i=0;i<strlen(encodedPswd);i )

{

decodedPswd[i] = encodedPswd[i] ^key[i%keyLen];

}

decodedPswd[i]='\0';

}

void readPswd()

{

GetPrivateProfileString(appName,keyName,NULL,encodedPswd,maxLen,fullPathName);

decodePswd();

// printf("%s",decodedPswd);

}

void statrLol()

{

printLine();

printf("lol还没启动,自动启动lol");

printLine();

printf("\n");

char dir[maxLen];

GetCurrentDirectory(maxLen,dir);

strcat(dir,"\\");

strcat(dir,"Client.exe");

ShellExecute(NULL,"open",dir,NULL,NULL,SW_SHOWNORMAL);

printLine();

//使用系统自带的 runas /savecred 选项,第一次输入密码后,会保存凭据。

//特点:无法限制能够运行的命令,安全性差。

printf("选择服务器后,请按回车继续");

printLine();

printf("\n");

getchar();

}

void inputUppercase(char upper)

{

keybd_event(VK_SHIFT, 0, 0 ,0);

keybd_event(upper, 0, 0 ,0);

keybd_event(upper, 0, KEYEVENTF_KEYUP ,0);

keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP ,0);

}

void sendPswd()

{

HWND lolWin = FindWindow(NULL,"英雄联盟登录程序");

while(lolWin == NULL)

{

statrLol();

lolWin = FindWindow(NULL,"英雄联盟登录程序");

}

SetForegroundWindow(lolWin);

RECT origin;

GetWindowRect(lolWin,&origin);

Sleep(500);

SetCursorPos(1012 origin.left,395 origin.top);

mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);

mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);

//用记事本做测试

//HWND npWnd=FindWindow( "notepad",NULL);

//HWND childWnd=FindWindowEx(npWnd, NULL, "Edit", NULL);

//SetForegroundWindow(npWnd);

int i;

char ch;

for(i=0;i<strlen(decodedPswd);i )

{

if(decodedPswd[i]>='a'&&decodedPswd[i]<='z')

ch = decodedPswd[i] - 'a' 'A';//小写

else if(decodedPswd[i]>='A'&&decodedPswd[i]<='Z')

{

inputUppercase(decodedPswd[i]); //uppercase

continue;

}

else ch = decodedPswd[i]; //digit number

keybd_event(ch, 0, 0 ,0);

keybd_event(ch, 0, KEYEVENTF_KEYUP ,0);

}

// HWND mfpa = FindWindowEx(lolWin,NULL,"MacromediaFlashPlayerActiveX",NULL);

// if(mfpa == NULL)

// printf("1 can't");

/*

HWND aaWin = FindWindowEx(mfpa,NULL,"AtlAxWin",NULL);

if(aaWin == NULL)

printf("2 can't");

HWND seWin = FindWindowEx(aaWin,NULL,"Shell Embedding",NULL);

if(seWin == NULL)

printf("3 can't");

HWND sdovWin = FindWindowEx(seWin,NULL,"Shell DocObject View",NULL);

if(sdovWin == NULL)

printf("4 can't");

HWND iesWin = FindWindowEx(sdovWin,NULL,"Internet Explorer_Server",NULL);

if(iesWin == NULL)

printf("5 can't");

*/

// HWND pwdWin = FindWindowEx(lolWin,NULL,"TWINCONTROL",NULL);

// SetForegroundWindow(lolWin);

// SendMessage(mfpa,EM_REPLACESEL, 0,(LPARAM)decodedPswd);

// HWND pwdWin = FindWindowEx(lolWin,NULL,"TWINCONTROL",NULL);

// HWND pwdWin = FindWindowEx(lolWin,NULL,"AtlAxWin",NULL);

// if(pwdWin == NULL)

// printf("can't");

}

void close()

{}

本人从事在线教育c 十年工作经验现在精心整理了一套从小白到项目实践开发各种学习资料如果你想学想加入我们请关注我在私信回复“编程”就可以领取学习资料!!!

,