Server Help

ASSS Custom Projects - shawnbot-1.0

Gondola - Thu Jun 15, 2006 7:06 pm
Post subject: shawnbot-1.0
Hey guys. I found shawnbot-1.0 floating around, and I'm trying to use it with the latest version of ASSS, but it's not working.

I get the following error:
Code: Show/Hide
M <game> [pid=0] bad position packet len=21
M <game> [pid=0] bad position packet len=21
M <game> [pid=0] bad position packet len=21


Until I stop it or it gets booted from the game.

Here's the player position packet sending code from the bot:
Code: Show/Hide
sub send_position {
  # Offset  Length  Description
  # 0       1       Type Byte 0x03
  # 1       1       Direction   (0 ... 360)
  # 2       4       Timestamp
  # 6       2       X Velocity
  # 8       2       Y Pixels    (0 ... 16384)
  # 10      1       Checksum
  # 11      1       Togglables *1
  # 12      2       X Pixels    (0 ... 16384)
  # 14      2       Y Velocity
  # 16      2       Bounty
  # 18      2       Energy
  # 20      2       Weapon Info *2
  #
  # 22      2       Energy *4       (Optional)
  # 24      2       S2C Latency *4  (Optional)
  # 26      2       Timer *4        (Optional)
  # 28      4       Item info *3 *4 (Optional)

  my (@spacket, $rpacket, $ticks, $csum, $i);
  $ticks = int(bc_handleproto::getTicks() / 10);

  $spacket[0] = bc_enc::enc_byte(0x03);
  $spacket[1] = bc_enc::enc_byte(0x00);
  @spacket[2 .. 5] = bc_enc::ence_int($ticks);
  @spacket[6 .. 7] = bc_enc::ence_short(bc_enc::short(0x00));
  @spacket[8 .. 9] = bc_enc::ence_short(bc_enc::short($bc_global::posY));
  $spacket[10] = bc_enc::enc_byte(0x00);
  $spacket[11] = bc_enc::enc_byte(0x00);
  @spacket[12 .. 13] = bc_enc::ence_short(bc_enc::short($bc_global::posX));
  @spacket[14 .. 15] = bc_enc::ence_short(bc_enc::short(0x00));
  @spacket[15 .. 16] = bc_enc::ence_short(bc_enc::short(0x00));
  @spacket[17 .. 18] = bc_enc::ence_short(bc_enc::short(0x00));
  @spacket[19 .. 20] = bc_enc::ence_short(bc_enc::short(0x00));

  for ($i = 0; $i < scalar(@spacket); $i++) {
    $csum = $csum ^ $spacket[$i];
  }
  $spacket[10] = bc_enc::enc_byte($csum);
  $rpacket = bc_enc::encrypt(@spacket);
  bc_handleproto::C2S_send($rpacket);
}


Here's the relevant code from ASSS core.c:
Code: Show/Hide
#ifdef CFG_RELAX_LENGTH_CHECKS
    if (len < 22)
#else
    if (len != 22 && len != 32)
#endif
    {   
        lm->LogP(L_MALICIOUS, "game", p, "bad position packet len=%i", len);
        return;
    }


I'm not experienced with packet handling, so this stuff goes over my head. Is there an easy fix to this?

I tried to recompile ASSS so I could skip the length check, but I had a lot of errors. But that's another topic. I think it would be much easier to just "fix" Shawnbot, but I'm not sure how to do it. I changed the "19 .. 20" to "19 .. 21" and it said bad client version and refused to let it log in.

Thanks!
Smong - Thu Jun 15, 2006 7:19 pm
Post subject:
Quote:
$spacket[0] = bc_enc::enc_byte(0x03);
$spacket[1] = bc_enc::enc_byte(0x00);
@spacket[2 .. 5] = bc_enc::ence_int($ticks);
@spacket[6 .. 7] = bc_enc::ence_short(bc_enc::short(0x00));
@spacket[8 .. 9] = bc_enc::ence_short(bc_enc::short($bc_global::posY));
$spacket[10] = bc_enc::enc_byte(0x00);
$spacket[11] = bc_enc::enc_byte(0x00);
@spacket[12 .. 13] = bc_enc::ence_short(bc_enc::short($bc_global::posX));
@spacket[14 .. 15] = bc_enc::ence_short(bc_enc::short(0x00));
@spacket[15 .. 16] = bc_enc::ence_short(bc_enc::short(0x00));
@spacket[17 .. 18] = bc_enc::ence_short(bc_enc::short(0x00));
@spacket[19 .. 20] = bc_enc::ence_short(bc_enc::short(0x00));
That line should be 16 .. 17, and all the following indexes incremented by 1; 18 .. 19, 20 .. 21.
Gondola - Thu Jun 15, 2006 7:55 pm
Post subject:
Rock on! Thanks much.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group