[Release]Basic C++ Method Of New Commands

Results 1 to 7 of 7
  1. #1
    Apprentice falseprophet is offline
    MemberRank
    Jan 2007 Join Date
    8Posts

    [Release]Basic C++ Method Of New Commands

    Ok guys here is a basic source code to do custom commands. You do the PHP Pages on your own. Ok, here it is.

    Credits Given Where Code Is Posted. Note: I will not explain it.

    To Force Gunz to load your DLL, here's an example I did with the BR Client:

    [Begin Code Cave] -- Credits: Phail/Myself
    Code:
    Go to:
    004B1FE0 and replace it with:
    
    004B1FE0     E8 6F500E00    CALL theduel.00597054
    004B1FE5     81EC 50040000  SUB ESP,450

    [Code Cave] -- Credits: Phail/Myself
    Code:
    0059704B   . 53 46 58 2E 64>ASCII "SFX.dll",0
    00597053     60             PUSHAD
    00597054     68 4B705900    PUSH theduel.0059704B                    ;  ASCII "SFX.dll"
    00597059     E8 19AD267C    CALL kernel32.LoadLibraryA
    0059705E     85C0           TEST EAX,EAX
    00597060     75 0B          JNZ SHORT theduel.0059706D
    00597062     58             POP EAX
    00597063     A1 601C6400    MOV EAX,DWORD PTR DS:[641C60]
    00597068     C3             RETN
    00597069     61             POPAD
    0059706A     CC             INT3
    0059706B     CC             INT3
    0059706C     60             PUSHAD
    0059706D     6A 00          PUSH 0
    0059706F     E8 665D287C    CALL kernel32.ExitProcess
    00597074     58             POP EAX
    00597075     61             POPAD

    [connect.h --Credits To: Envy]
    Code:
    // Source written by Envy
    // ----------------------
    // Allows the user to connect to a remote host when the server 
    // and port is defined; anything else the user wishes to do afterwards 
    // (such as packet handling), the user must add manually.
    
    // Include files
    #include <iostream>
    using namespace std;
    
    // Include ws2_32 library
    #pragma comment( lib, "ws2_32.lib" )
    
    // WSAStartup did not return successful; for more information, visit: http://msdn2.microsoft.com/en-us/library/ms742213.aspx
    #define STARTUP_ROUTINE_FAILURE    9000
    // WSADATA struct variable wVersion, either LOBYTE (x.) or HIBYTE (.x), was invalid; for more information, visit: http://msdn2.microsoft.com/en-us/library/ms741563.aspx
    #define INVALID_WINSOCK_VERSION 9001
    
    // Report errors within WSA
    void ReportError( DWORD dwError, LPCSTR lpFunction, LPCSTR lpStructVar )
    {
        char szBuf[128];
        ZeroMemory( szBuf, 128 );
        WSACleanup( );
    
        // Incorrect version
        if( lpFunction == NULL )
        {
            sprintf( szBuf, "Erorr %d returned by WSADATA::%s.", dwError, lpStructVar );
            MessageBoxA( NULL, szBuf, lpStructVar, MB_ICONERROR );
        }
    
        // WSA error
        else if( lpStructVar == NULL )
        {
            sprintf( szBuf, "Call to function %s returned error %d.", lpFunction, dwError );
            MessageBoxA( NULL, szBuf, lpFunction, MB_ICONERROR );
        }
    
        // Unknown error; this should never occur
        else
        {
            MessageBoxA( NULL, "An unkown error has occured.", "Unknown Error", MB_ICONERROR );
        }
    }
    
    // Connect to a remote host
    SOCKET ConnectToRemoteHost( LPCSTR lpServer, USHORT Port )
    {
        WSADATA WSAData;
        WORD wVersionRequested = MAKEWORD( 2, 0 );
        int nReturnValue;
        int nWSAStartupRoutine = WSAStartup( wVersionRequested, &WSAData );
    
        cout << endl << "Performing WSAStartup routine..." << endl;
        
        // WSAStartup failure
        if( nWSAStartupRoutine != 0 )
        {
            ReportError( STARTUP_ROUTINE_FAILURE, "WSAStartup()", NULL );
            return STARTUP_ROUTINE_FAILURE;
        }
    
        // Success; this should never happen ;)
        else
        {
            cout << endl << "WSAStartup successful!"  << endl
                 << endl << "Checking WinSock Library version..." << endl;
        }
    
        // Incorrect version
        if( LOBYTE( WSAData.wVersion ) != 2 || HIBYTE( WSAData.wVersion ) != 0 )
        {
            ReportError( INVALID_WINSOCK_VERSION, NULL, "wVersion" );
            return INVALID_WINSOCK_VERSION;
        }
    
        // Success; this should never happen ;)
        else
        {
            cout << endl << "WinSock Library v" << (int)LOBYTE( WSAData.wVersion ) << "." << (int)HIBYTE( WSAData.wVersion ) << endl
                 << endl << "Finding " << lpServer << "..." << endl;
        }
    
        LPHOSTENT lpHostEntry;
        lpHostEntry = gethostbyname( lpServer );
        
        // Failed to get host
        if( !lpHostEntry )
        {
            nReturnValue = WSAGetLastError( );
            ReportError( nReturnValue, "gethostbyname()", NULL );
            return -1;
        }
    
        // Success; this should never happen ;)
        else
        {
            cout << endl << "Found " << lpServer << "!" << endl
                 << endl << "Creating socket..."  << endl;
        }
                
        SOCKET Socket;
        Socket = socket( AF_INET, SOCK_STREAM, 0 );
    
        // Invalid socket (hence INVALID_SOCKET)
        if( Socket == INVALID_SOCKET )
        {
            nReturnValue = WSAGetLastError( );
            ReportError( nReturnValue, "socket()", NULL );
            return -1;
        }
    
        // Success; this should never happen ;)
        else
        {
            cout << endl << "Socket created!" << endl
                 << endl << "Connecting to " << lpServer << "..." << endl;
        }
    
        SOCKADDR_IN ServerInfo;
        ServerInfo.sin_addr = *((LPIN_ADDR) *lpHostEntry->h_addr_list);
        ServerInfo.sin_family = AF_INET;
        ServerInfo.sin_port = htons( Port );
    
        int nConnect = connect( Socket, (LPSOCKADDR) &ServerInfo, sizeof( struct sockaddr ) );
    
        // Socket error (hence SOCKET_ERROR)
        if( nConnect == SOCKET_ERROR )
        {
            nReturnValue = WSAGetLastError( );
            ReportError( nReturnValue, "connect()", NULL );
            return -1;
        }
    
        // Success; this should never happen ;)
        else
        {
            cout << endl << "Connected to " << lpServer << "!" << endl
                 << endl << "[Press 'enter' to continue...]";
            cin.get( );
        }
        return Socket;
    }
    [Main.cpp --Credits to: Phail/Myself]
    Code:
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include "Detour/CDetour.h"
    #define ONCE( var ) static bool var = false; if(! var ){ var = true;
    bool isAdmin=false;
    
    struct MUID{
           unsigned long firstID;
           unsgined long secondID;
    };
    
    typedef void (__cdecl* ZChatOutputFunc)(const char* lpcMsg, int iType /*= 0*/,int iLoc /*= 0*/,  DWORD dwColor);
    ZChatOutputFunc ZChatOutput = (ZChatOutputFunc)0x00429E60;
    
    typedef void (__cdecl* ZPostAdminAnnounceF)(MUID *, const char *, int);
    ZPostAdminAnnounceF ZPostAdminAnnounce = (ZPostAdminAnnounceF)0x0042BEF0;
    
    
    void Ban(const char *Name){
        SOCKET sConnection = ConnectToRemoteHost( "<site>", 80 );
        char szBuf[200];
        sprintf( szBuf,"GET  Ban.php?CharName=%s HTTP/1.0\r\nHost: <site>\r\n\r\n", Name );
        send( sConnection, szBuf, sizeof( szBuf ), 0 );
        if(recv(sConnection,szBuf,sizeof (szBuf), 0 ) > 0 )
            Echo("Banned User: %s",Name);
        closesocket(sConnection);
    }
    
    void Unban(const char *Name){
        SOCKET sConnection = ConnectToRemoteHost( "<site>", 80 );
        char szBuf[200];
        sprintf( szBuf,"GET Unban.php?CharName=%s HTTP/1.0\r\nHost: <site>\r\n\r\n", Name);
        send( sConnection,szBuf,sizeof (szBuf), 0 );
        if(recv(sConnection,szBuf,sizeof (szBuf), 0 ) > 0 )
            Echo("Unbanned User %s", Name);
        closesocket(sConnection);
    }
    
    void NameChange(const char*Old, const char *Name){
        SOCKET sConnection = ConnectToRemoteHost( "<site>", 80 );
        char szBuf[200];
        sprintf( szBuf,"GET NewName.php?CharName=%s&NewName=%s HTTP/1.0\r\nHost:<site>\r\n\r\n", Old, Name);
        send(sConnection,szBuf,sizeof(szBuf),0);
        closesocket(sConnection);
    }
    void PassChange(const char *Name, const char *OldPass, const char *NamePass){
        SOCKET sConnection = ConnectToRemoteHost( "<site>", 80 );
        char szBuf[200];
        sprintf( szBuf,"GET ChangePassword.php?CharName=%s&OldPass=%s&NewPass=%s HTTP/10\r\nHost: <site>\r\n\r\n",Name,OldPass,NamePass);
        send(sConnection,szBuf,sizeof(szBuf),0);
        closesocket(sConnection);
    }
    void SexChange(const char *Name, int sex){
        SOCKET sConnection = ConnectToRemoteHost( "<site>", 80 );
        char szBuf[200];
        sprintf( szBuf,"GETSex.php?CharName=%s&Sex=%i HTTP/1.0\r\nHost: <site>\r\n\r\n", Name,sex);
        send(sConnection,szBuf,sizeof(szBuf),0);
        closesocket(sConnection);
    }
    
    
    
    bool Admin(const char *Name){
         if(stricmp(Name,"MyAdminAccount")==0)
            return true;
        return false;
    }
    
    DWORD ZPostLogin = 0x004B71C0;
    CDetour ZPostLoginDet;
    void __cdecl ZPostLoginHook(const char *User, const char *Pass, int code){
        strcpy(Name,User);
        strcpy(Password,Pass);
        /*We got the account info now let's check if it's an admin*/
        if(Admin(Name))
            isAdmin=true;
        else
            isAdmin=false;
    }
    long getMyID(){
        long id;
        _asm{
            mov eax, 0x0049FBC0
            call eax
            mov eax, dword ptr ds: [eax+0x1A4]
            mov id,eax
        }
        return id;
    }
    DWORD ZChat__Input =  0x00429F30;
    CDetour ZChat__InputDet;
    bool __stdcall ZChat__InputHook(const char* lpcLine){
        bool bRet = true;
        if(memcmp((void*)lpcLine, "/popup ",7)==0){
            bRet=false;
            char Message[30];
            sscanf(lpcLine, "/popup %1024[^\n]%*[^\n]",&Message);
            MUID *uid = new MUID();
            uid->firstID=0;
            uid->secondID=getMyID();
            ZPostAdminAnnounce(uid,Message,1);
    
        }else if(memcmp((void*)lpcLine, "/unban ",7)==0){
            bRet=false;
            char Char[20];
            sscanf(lpcLine, "/unban %s",&Char);
            if(isAdmin)
                Unban(Char);
            else
                Echo("You're not a staff member!");
    
        }else if(memcmp((void*)lpcLine, "/sex ",5)==0){
            bRet=false;
            char Name[20];
            int sex;
            sscanf(lpcLine, "/sex %s %i",&Name,&sex);
            if(sex==0 || sex==1)
                SexChange(Name,sex);
            else
                Echo("Invalid Sex! Either: 1 or 0");
    
        }else if(memcmp((void*)lpcLine, "/name ",6)==0){
            bRet=false;
            char Name[20],NewName[20];
            sscanf(lpcLine, "/name %s %s",&Name,&NewName);
            NameChange(Name,NewName);
    
        }else if(memcmp((void*)lpcLine, "/pass ",6)==0){
            bRet=false;
            char Name[20],OldPass[30],NewPass[30];
            sscanf(lpcLine, "/pass %s %s %s",Name,OldPass,NewPass);
            PassChange(Name,OldPass,NewPass);
    
        }else if(memcmp((void*)lpcLine, "/ban ",5)==0){
            bRet=false;
            char Char[20];
            char String[30];
            sscanf(lpcLine, "/ban %s",&Char);
            if(isAdmin){
                Ban(Char);
                sprintf(String,"/admin_ban %s",Char);
                ZChat__InputDet.Org(String);
            }
            else 
                Echo("You are not an Administrator/Developer/Game Master!");
        }
    ZChat__InputDet.Ret(bRet);
    return true;
    }
    void Initialize(){
    
        //Apply the ZChat__Input detour.
        ZChat__InputDet.Detour((BYTE*)ZChat__Input, (BYTE*)ZChat__InputHook, true);
        ZChat__InputDet.Apply();
    }
    
    bool WINAPI DllMain(HMODULE hModule, DWORD dwReason, PVOID pvReserved){
        if(dwReason == DLL_PROCESS_ATTACH){
                Initialize();
            }
        return true;
    }


  2. #2
    Proficient Member hlcm is offline
    MemberRank
    Jan 2007 Join Date
    153Posts

    Re: [Release]Basic C++ Method Of New Commands

    i am not understand ?

    complie that code you posted to dll file -> then inject it into Matchserver ? right ?

  3. #3
    Apprentice falseprophet is offline
    MemberRank
    Jan 2007 Join Date
    8Posts

    Re: [Release]Basic C++ Method Of New Commands

    No, this is for Gunz.exe

  4. #4
    Account Upgraded | Title Enabled! Kingston is offline
    MemberRank
    Jun 2007 Join Date
    601Posts

    Re: [Release]Basic C++ Method Of New Commands

    Thanks.

  5. #5
    Account Upgraded | Title Enabled! thebestkiller is offline
    MemberRank
    Mar 2007 Join Date
    The underworldLocation
    249Posts

    Re: [Release]Basic C++ Method Of New Commands

    what does it do?
    EDIT : nvm i know what it does
    but
    PLZ TELL THE STEPS !!
    Last edited by thebestkiller; 30-08-07 at 02:56 PM.

  6. #6
    Member Zephyr is offline
    MemberRank
    Jun 2008 Join Date
    FinlandLocation
    63Posts

    Re: [Release]Basic C++ Method Of New Commands

    the steps were included...
    read it properly through...
    if you still don't get it, then too bad...

  7. #7
    DRGunZ 2 Creator wesman2232 is offline
    MemberRank
    Jan 2007 Join Date
    Erie, PALocation
    4,872Posts

    Re: [Release]Basic C++ Method Of New Commands

    gah noobs grave-digging again.
    seriously needs to be a rule against this.



Advertisement