Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
[C++] Proxy
Results 1 to 2 of 2

Thread: [C++] Proxy

  1. #1
    Senior Member
    Join Date
    Oct 2009
    Location
    Poland, Świebodzin
    Posts
    233

    [C++] Proxy

    I decided to learn something about winsocks. I found somewhere on my computer old sources then I tried to login on OpenTibia. Everything goes fine to the moment when I choose character. When it trying to connect server without ANY result.

    [code=cpp]#define LOGIN_SERVER_IP "127.0.0.1"
    #define LOGIN_SERVER_PORT 7171
    #define GAME_SERVER_PORT 7172

    DWORD initBot(LPVOID lpParam)
    {
    if(!mem.gameWindowExists())
    SendMessage(mainDlg, WM_DESTROY, 0, 0);
    else
    {
    addConsoleMsg(">> Game window has been found!");
    if(!utils.changeLoginServers(LOGIN_SERVER_IP, LOGIN_SERVER_PORT))
    addConsoleMsg(">> Couldn't change login servers!");
    else
    {
    addConsoleMsg(">> Login servers has been changed to: %s:%i", LOGIN_SERVER_IP, LOGIN_SERVER_PORT);
    addConsoleMsg(">> Now you can log in!");
    SOCKET proxySocket = con.createServer(LOGIN_SERVER_PORT);
    if(proxySocket != 0)
    {
    addConsoleMsg(">> Proxy server has been created!");
    serverSock = con.connectTo(SERVER_IP, SERVER_PORT);
    if(serverSock != 0)
    {
    addConsoleMsg(">> Connected to game server.");

    NetworkMessage nm;
    if(nm.ReadFromSocket(proxySocket))
    {
    nm.WriteToSocket(serverSock);
    //nm.useEncryption(true);
    if(nm.ReadFromSocket(serverSock))
    {
    //show_packet((uint8_t*)nm.getBuffer());
    BYTE packetID = nm.GetByte();
    std::string motdMsg;
    if(packetID == 0x14)
    motdMsg = nm.GetString();

    uint16_t charCount;
    if(nm.GetByte() == 0x64)
    {
    charCount = nm.GetByte();
    addConsoleMsg(">> %i characters found.", charCount);
    }

    for(int i = 0; i < charCount; i++)
    {
    charlist[i].name = nm.GetString();
    charlist[i].world = nm.GetString();
    for(int j = 0; j < 4; j++)
    charlist[i].serverIP[j] = nm.GetByte();
    charlist[i].serverPort = nm.GetU16();

    sprintf(charlist[i].ip, "%i.%i.%i.%i", charlist[i].serverIP[0], charlist[i].serverIP[1], charlist[i].serverIP[2], charlist[i].serverIP[3]);
    addConsoleMsg("> %s on %s (%s:%i)", charlist[i].name.c_str(), charlist[i].world.c_str(), charlist[i].ip, charlist[i].serverPort);
    }

    uint16_t premTime = nm.GetU16();

    nm.Reset();
    nm.AddByte(0x14);
    nm.AddString("1\nTest\nTest");
    nm.AddByte(0x64);
    nm.AddByte(charCount);
    char* ipAddr = new char[128];
    for(int i = 0; i < charCount; i++)
    {
    nm.AddString(charlist[i].name.c_str());
    nm.AddString(charlist[i].world.c_str());
    nm.AddU32(0x0100007F); // 16777343 = 127.0.0.1 (in long)
    nm.AddU16(GAME_SERVER_PORT);
    memcpy(ipAddr, charlist[i].ip, strlen(charlist[i].ip) + 1);
    }
    nm.AddU16(premTime);

    nm.WriteToSocket(proxySocket);

    closesocket(serverSock);
    closesocket(proxySocket);
    WSACleanup();

    gameServer = con.createServer(GAME_SERVER_PORT);
    if(gameServer != 0)
    {
    gameClient = con.connectTo("127.0.0.1", GAME_SERVER_PORT);
    if(gameClient != 0)
    {
    addConsoleMsg(">> Game Server has been created also you're connected to it!");
    if(nm.ReadFromSocket(gameServer))
    {
    if(nm.getMessageLength() == 0)
    {
    addConsoleMsg(">> Packet length is 0!");
    ExitProcess((UINT)lpParam);
    }
    else
    {
    nm.WriteToSocket(gameClient);
    addConsoleMsg(">> Okay, we send it!");
    }
    addConsoleMsg(">> Ah, it's ok!");
    }
    else
    {
    addConsoleMsg(">> Ah, it's NOT ok!");
    }
    }
    }
    }
    }
    }
    }
    }
    }
    //ExitProcess((UINT)lpParam);
    //return 0;
    }[/code]

    It goes to the moment:
    [code=cpp]addConsoleMsg(">> Game Server has been created also you're connected to it!");[/code]

    Any suggestion what should I do?

    Regards, Czepek!

  2. #2
    Junior Member
    Join Date
    Mar 2007
    Posts
    24

    RE: [C++] Proxy

    if(nm.ReadFromSocket(gameServer))
    waiting for a ping?
    anyway, i dont know what the problem is, but if i where you, id launch WPE/rPE, record the exact packets the client would send to the server (for logging in), then compare with the exact packets your app send..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •