EOSERV Forum > Lounge 2.0 > EOBOT issues
Page: << 1 >>
EOBOT issues
Author Message
Post #201932 EOBOT issues

Hi guys, I've decided to play around with the ES EOBOT source code v2.2.  I've always been interested in learning more client/server interactions, I've always had an interest in these bots.

Anyways, attempting to login to an eoserv server (they allow bots).  Their seems to be an issue when connecting to the server.  I believe my issue lies in this piece of code. http://pastebin.com/XmZcJSNz

At first I thought their might have been a slight packet issue, but this doesn't always occur.  The error I get is "Invalid username/password" but my information is correct.  Sometimes it logs in; sometimes it doesn't (most of the time it doesn't).

The reply I get isn't LOGIN_OK.

Is it possibly a timing / tick issue? If so what can I do to resolve this?

Thanks

7 years, 49 weeks ago
Post #201934 Re: EOBOT issues

I'm pretty sure its the enforced packet sequence server side.You will have to adjust a few things I currently dont have my working source to show you but it should be in bots code in packet.cpp in the Encode function

if (rawstr[1] != 255)
    {

fullstr += rawstr.substr(0,4);
//fullstr += the correct sequence here

fullstr += rawstr.substr(4);

    }


At that point it switches from 2 bytes to 1...maybe test the bot on main or on server that doesnt enforce the packet seq!

7 years, 49 weeks ago
Post #201935 Re: EOBOT issues

I haven't fucked with eoserv /  or c++ in months but i will try to do my best.


The main(clone) actually forces the seq bytes.

Sequence number is a number that the server excepts to be sent correctly after the Packet action/family bytes.

-----------

For illustration :

*Base sequence : 

-At initialization , when the server sends INIT_OK , it will send two bytes S1 and S2 which are used to calculate the base sequence.


-When the server sends the connection packet,it will send two values used to calculate the base sequence so every time the client receives a connection packet it should change it's base sequence as it did in the initialization  


*Sequence number = base sequence + I , where I is a number ranging from 0 to 9 ( the I counter should go back to 0 instead of reaching 10)

*I is initially 0

*I increases by 1 , before the client sends a packet.

*If the sequence number is equals or exceeds 253 , it should be sent as Short else as Char


------

The problem in your case is that bot sends a constant seq number (which is mostly a number less than 253,a byte) , if the server excepts a short ( 2x bytes) sequence number even if the server does not force sequence bytes , it will eat a byte from the packet structure itself , that's when you get an invalid ID/PASS reply.

But if it expects a byte , that's when you are able to log in.

7 years, 49 weeks ago
Post #201940 Re: EOBOT issues

Well this definitely gave me a point in the right direction! Thanks guys!  I knew eoserv was definitely more strict, couldn't figure out exactly what was different.

I'll take a look at packet.cpp.  Completely forgot the official server was still technically online.  When i get a chance to look at it again i'll report back!

Cheers

7 years, 49 weeks ago
Post #201943 Re: EOBOT issues

I need a bot that works, since I found this one, but it gives me the following error that I show in the image. I have configured everything well when it wants to enter and work but when reconnect stops working, can someone help me?


7 years, 49 weeks ago
Post #201950 Re: EOBOT issues

The method I posted prior was onlyworking correctly if the server was sending 1 byte sequences.I had to adjust the length of the packet to fit the switch bytes.

EDITED 1/6/17

in packet.cpp under the includes add


unsigned short seqstart;
unsigned char seqval = 1;

unsigned short Sequence()
{
    unsigned short val = seqval;

    if (++seqval >= 10)
    {
        seqval = 0;//was 0
    }

    return seqstart + val;
}

void SetSeqStart(unsigned short val)
{
    seqstart = val;
}


and remove these variables and functions


PacketProcessor::seqstart

PacketProcessor::seqval

unsigned short PacketProcessor::Sequence()
{
    unsigned short val = seqval;

    if (++seqval >= 10)
    {
        seqval = 0;//was 0
    }

    return seqstart + val;
}

void PacketProcessor::SetSeqStart(unsigned short val)
{
    seqstart = val;
}


Replace your packet encode function with this


std::string PacketProcessor::Encode(const std::string &rawstr)
{

    std::string str = this->DickWinderE(rawstr);
    std::string newstr;
    int length = str.length();

    int i = 2;
    int ii = 2;

    newstr.resize(length);

    newstr[0] = str[0];
    newstr[1] = str[1];

    while (i < length)
    {
        newstr[i] = (unsigned char)str[ii++] ^ 0x80;
        i += 2;
    }

    i = length - 1;

    if (length % 2)
    {
        --i;
    }

    while (i >= 2)
    {
        newstr[i] = (unsigned char)str[ii++] ^ 0x80;
        i -= 2;
    }

    for (int i = 2; i < length; ++i)
    {
        if (static_cast<unsigned char>(newstr[i]) == 128)
        {
            newstr[i] = 0;
        }
        else if (newstr[i] == 0)
        {
            newstr[i] = 128;
        }
    }

    return newstr;
}


Near the bottom replace your PacketBulder::Get function with this


std::string PacketBuilder::Get()
{
    std::string retdata;
    util::pairchar id = PacketProcessor::EPID(this->id);

    int extra = (id[1] != 255);
    unsigned short sequence =  0;
    int bytes_ = 1;
    std::string seqdata = "";

    if(extra)
    {
        sequence = Sequence();

        if(sequence >= 253)
            bytes_ = 2;

        util::quadchar seq_ = PacketProcessor::ENumber(sequence);

        if(bytes_ == 1)
        {
             seqdata += seq_[0];
        }
        else
        {
            seqdata += seq_[0];
            seqdata += seq_[1];
        }
    }

    util::quadchar length = PacketProcessor::ENumber(this->length + 2 + (extra + bytes_ -1));

    retdata += length[0];
    retdata += length[1];
    retdata += id[0];
    retdata += id[1];
    retdata += seqdata;
    retdata += this->data;
    return retdata;
}

In packet.hpp under the includes place

extern unsigned short seqstart;
extern unsigned char seqval;

unsigned short Sequence();
void SetSeqStart(unsigned short val);

in the PacketProcessor class remove

seqstart;
seqval;
Sequence();
SetSeqStart(unsigned short val);


I've been on 2 different servers today and they both have different variations of the sequence enabled no problems :D good luck!!

7 years, 49 weeks ago
Page: << 1 >>

EOSERV Forum > Lounge 2.0 > EOBOT issues