Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • ASDss: where do u download source and clients now
      August 18, 2017, 10:39:31 PM
    • ASDss: yo
      August 18, 2017, 10:39:20 PM
    • dan v jad: click me 4 da fun ;)[link]
      August 18, 2017, 04:39:58 PM
    • stCky: Palidinho is your OpenGL (was it OpenGL?) stuff open source anywhere?
      August 16, 2017, 09:07:22 PM
    • Travas:BUILD THE WALL
      August 15, 2017, 09:28:49 PM
    • Travas: i have ass cancer
      August 15, 2017, 09:23:29 PM
    • stCky: what are the fudge are you tryna ask?
      August 15, 2017, 08:21:35 PM
    • bader: what are the rsps community alive ?
      August 15, 2017, 05:46:16 PM
    • bader: yo guys
      August 15, 2017, 05:46:08 PM
    • Spacehost:[link] Updated our thread :)
      August 15, 2017, 09:40:34 AM
    • Adaro: The client is in Download section at Homepage
      August 15, 2017, 01:09:20 AM
    • FaTe_Of_GoDs: where do i get the client?????????????
      August 14, 2017, 05:23:14 PM
    • stCky: can anyone help me? I cant login to the shoutbox
      August 13, 2017, 05:45:15 PM
    • drubrkletern: appeal denied
      August 13, 2017, 02:35:27 PM
    • King_Trout:[link]
      August 13, 2017, 11:17:12 AM
    • Cole1497: no sorry
      August 13, 2017, 10:27:14 AM
    • ayz: yo can anyone explain something to me
      August 13, 2017, 08:08:51 AM
    • coolking12: Hi
      August 13, 2017, 04:16:06 AM
    • stCky: n+1
      August 11, 2017, 06:09:24 PM
    • PalidinoDH: How many more pages are going to show errors before this dude gets on and fixes shit
      August 11, 2017, 04:57:00 PM

    Author Topic: Understanding RSC protocol?  (Read 1798 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineCamHart

    • Member
    • **
    • Posts: 43
    • Thanks: +0/-0
      • View Profile
    Understanding RSC protocol?
    « on: November 15, 2015, 09:13:40 PM »
    I'm diving into trying to understand how to decode the rsc protocol used by the mopar classic client.

    Can anyone describe the order of the data that gets sent?  Right now I'm looking at the very first packet that gets sent from the client, which from my understanding requests a session.  Here's my guess for what I'm seeing getting sent (byte by byte).

    Code: [Select]
    0 ?
    66 length of message
    32 opcode - Session request
    //rest of this is payload ?
    0
    89
    111
    117
    32
    109
    117
    115
    116
    32
    101
    110
    116
    101
    114
    32
    98
    111
    116
    104
    32
    97
    32
    117
    115
    101
    114
    110
    97
    109
    101
    32
    97
    110
    100
    32
    97
    32
    112
    97
    115
    115
    119
    111
    114
    100
    32
    45
    32
    80
    108
    101
    97
    115
    101
    32
    116
    114
    121
    32
    97
    103
    97
    105
    110


    OfflineRSCRevolution

    • Member
    • **
    • Posts: 21
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #1 on: November 16, 2015, 06:03:43 AM »
    length 2
    opcode 1
    payload -> read length amount bytes
    length 2
    opcode 1
    payload

    You can't assume that the data you receive is only one packet. It almost never is. What you're looking at is most likely session request and login data since session request can be maximum of 4 bytes.

    Play RuneScape Classic on your Android device: www.RSCRevolution.com
    Replicated Quests, Auction House, bank notes and more!

    OfflineZach Knight

    • Member
    • **
    • Posts: 48
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #2 on: November 16, 2015, 01:56:00 PM »
    MoparClassic client packet structure and packet assembly has been modified from original RSClassic and is a bad model to do this under.  I believe eXemplar/vortex's 204 is a better model to start with, or an un-refactored deob of 202 or 204 would be okay.  I've had to fix a lot of packet builders to match real Classic and can help others out fixing them to match Classic behavior fixing various bugs if requested.

    OfflineCamHart

    • Member
    • **
    • Posts: 43
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #3 on: November 16, 2015, 02:35:26 PM »
    RSCRevolution thanks for the tip and the breakdown.  I assume when you say length 2 you mean the length is the first 2 bytes (so the 0 and the 66).

    Zach do you have the source code for a good 202/204 client?

    Edit:  Is the client from https://github.com/Zlacki/OpenRSCD the correct one?  Appears to be so.
    « Last Edit: November 16, 2015, 08:38:15 PM by CamHart »

    OfflineEcko

    • Member
    • ****
    • Posts: 662
    • Thanks: +0/-0
      • View Profile
      • Autobots
    Re: Understanding RSC protocol?
    « Reply #4 on: November 17, 2015, 10:13:37 AM »
    http://rscdump.com/eggsampler-rsc-204-d223fc6b77db.rar

    heres a bunch of his stuff #039;s-collection.rar

    OfflineCamHart

    • Member
    • **
    • Posts: 43
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #5 on: November 17, 2015, 01:25:52 PM »
    Awesome thanks.

    Another question.  Once the session request and login packets have been sent and responded to, does the server just need to send character data at that point?

    Instead of answering the question above, if someone could describe how they would figure out the answer to the question themselves that works too.  Teach me to fish.  Although I'll probably teach myself anyways.

    Offlinegawdz666

    • Member
    • ****
    • Posts: 514
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #6 on: November 17, 2015, 02:51:50 PM »
    What exactly are you trying to understand so i can help you a little better.
    Are you trying to understand when / where things happen or the structure of packets, or ???
    Quote from: xEnt
    At First I Was Like..."I came to the conclusion today that i am over RSC.."Then I Was all Like..."Official Moparscape RSC Server"

    OfflineCamHart

    • Member
    • **
    • Posts: 43
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #7 on: November 18, 2015, 02:01:01 AM »
    gawdz666 everything :D.

    Right now this is puzzling me within the client (exemplars, Packet.java)

    Code: [Select]
        public void sendPacket() {
            if (isaacOutgoing != null) {
                int i = packetData[packetStart + 2] & 0xff;
                packetData[packetStart + 2] = (byte) (i + isaacOutgoing.getNextValue());
            }
            if (packet8Check != 8) // what the fudge is this even for? legacy?
                packetEnd++;
            int j = packetEnd - packetStart - 2;
            if (j >= 160) {
                packetData[packetStart] = (byte) (160 + j / 256);
                packetData[packetStart + 1] = (byte) (j & 0xff);
            } else {
                packetData[packetStart] = (byte) j;
                packetEnd--;
                packetData[packetStart + 1] = packetData[packetEnd];
            }
            if (packetMaxLength <= 10000) // this seems largely useless and doesn't appear to do anything
            {
                int k = packetData[packetStart + 2] & 0xff;
                anIntArray537[k]++;
                anIntArray541[k] += packetEnd - packetStart;
            }
            packetStart = packetEnd;
        }

    Specifically
    Code: [Select]
                        if (j >= 160) {
                packetData[packetStart] = (byte) (160 + j / 256);
                packetData[packetStart + 1] = (byte) (j & 0xff);
            }
    I get that j is the length of the packet.  What does "(byte) (160 + j / 256); (byte) (j & 0xff);" do?  At first I thought maybe something to do with 2's complement...  but after looking at it I don't think so.

    And...
    Code: [Select]
    else {
                packetData[packetStart] = (byte) j;
                packetEnd--;
                packetData[packetStart + 1] = packetData[packetEnd];
            }
    Whats up with the bottom 2 lines there?  Why are we moving the last byte to the 2nd position?
    « Last Edit: November 18, 2015, 02:11:26 AM by CamHart »

    OfflineCodeForFame

    • Member
    • ****
    • Posts: 2,065
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #8 on: December 05, 2015, 02:54:42 AM »
    Instead of looking at the client, look at the server. MoparClassic logs all packets sent, and you can easily create a mapping back to human readable logs.

    OfflineLothy

    • Member
    • ****
    • *
    • *
    • Posts: 7,006
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #9 on: December 05, 2015, 04:06:11 PM »
    Example packet size: 32,767 (0111 1111 1111 1111)
    MSB = 32,767 / 256 = 127 (0111 1111, the left half of the bit mask).
    LSB = 32,767 & 0xff (255) = 255 (0000 0000 1111 1111, the right half of the bit mask). Note that this gets casted back to a signed byte.

    Anyway, I suspect the server checks the first byte to see if it's >= 160 when reading the packet back. So to ensure it's interpreted as a 2-byte integer server-side they add 160 to the first byte. Having any bit set in the MSB and adding 160 to it will always be equal to >= 160.

    Does that make sense?
    <&Speljohan_> i wouldnt want to live in a society where Mopman isnt monitored 24/7

    Offlinevortex

    • Member
    • ****
    • *
    • Posts: 1,368
    • Thanks: +0/-0
      • View Profile
    Re: Understanding RSC protocol?
    « Reply #10 on: December 13, 2015, 03:12:31 PM »
    MoparClassic client packet structure and packet assembly has been modified from original RSClassic and is a bad model to do this under.  I believe eXemplar/vortex's 204 is a better model to start with, or an un-refactored deob of 202 or 204 would be okay.  I've had to fix a lot of packet builders to match real Classic and can help others out fixing them to match Classic behavior fixing various bugs if requested.
    RSCRevolution thanks for the tip and the breakdown.  I assume when you say length 2 you mean the length is the first 2 bytes (so the 0 and the 66).

    Zach do you have the source code for a good 202/204 client?

    Edit:  Is the client from https://github.com/Zlacki/OpenRSCD the correct one?  Appears to be so.
    It's lcated here https://bitbucket.org/eggsampler/rsc

    http://rscdump.com/eggsampler-rsc-204-d223fc6b77db.rar

    heres a bunch of his stuff #039;s-collection.rar
    nooooob

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal