Project Rainbow TCP [R63, Habbo.Com/Client]

Results 1 to 17 of 17
  1. #1
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Project Rainbow TCP [R63, Habbo.Com/Client]

    Hello guys, past week(s) I've been working on Project Rainbow, still in development, and I want to give you the TCP I use, it works on Habbo.COM/client.

    Go to your hosts file and add:
    127.0.0.1 game-us.habbo.com

    Here are all the files you need: (copyright to Project Rainbow)

    GameConnection.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.Net.Sockets;
    using Rainbow.Game.Game_Accounts;
    
    namespace Rainbow.Sockets
    {
        public class GameConnection
        {
            private Socket mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            private IPEndPoint mIPEndPoint = new IPEndPoint(IPAddress.Any, 0);
            private AsyncCallback mAsyncCallback;
            private int SecretID = 0;
    
            public GameConnection(int Port, string IP)
            {
                mIPEndPoint = new IPEndPoint(IPAddress.Parse(IP), Port);
                mSocket.Bind(mIPEndPoint);
                mSocket.Listen(5);
    
                mAsyncCallback = new AsyncCallback(OnAccept);
                mSocket.BeginAccept(mAsyncCallback, null);
            }
    
            private void OnAccept(IAsyncResult mIAsyncResult)
            {
                SecretID = SecretID++;
                Socket UserSocket = mSocket.EndAccept(mIAsyncResult);
                Environment.RainbowConsole.WriteLine("[SocketInformation] : Received connection [" + SecretID + "] from [" + UserSocket.AddressFamily.ToString() + "]");
                AccountClient Client = new AccountClient(SecretID, UserSocket);
                mSocket.BeginAccept(mAsyncCallback, null);
            }
        }
    }
    AccountClient.cs
    Code:
    using mSystem = System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net.Sockets;
    using Rainbow.System;
    using Rainbow.Messages;
    
    namespace Rainbow.Game.Game_Accounts
    {
        public partial class AccountClient
        {
            private Socket mSocket;
            private readonly int SocketID;
            private mSystem.AsyncCallback mAsyncCallback;
            private byte[] Buffer = new byte[50000]; // not important I guess..
            private AccountClient Session;
            private delegate void Packet();
            private Packet[] mPacket;
    
    
            public AccountClient(int SocketID, Socket Socket)
            {
                this.SocketID = SocketID;
                this.mSocket = Socket;
                this.mAsyncCallback = new mSystem.AsyncCallback(ReceivePacketsFromUSClient);
                this.Session = this;
    
                this.mPacket = new Packet[50000];
    
                //begin!
                RegisterPrelogin();
    
                this.mSocket.BeginReceive(Buffer, 0, Buffer.Length, 0, this.mAsyncCallback, null);
            }
    
            private void ReceivePacketsFromUSClient(mSystem.IAsyncResult IAS)
            {
                int BytesReceived = (int)mSocket.EndReceive(IAS);
    
                StringBuilder SB = new StringBuilder();
                SB.Append(mSystem.Text.Encoding.Default.GetString(Buffer, 0, BytesReceived));
    
                if (SB.ToString().Contains("<policy-file-request/>"))
                {
                    SendPolicy("<?xml version=\"1.0\"?>\r\n" +
                    "<!DOCTYPE cross-domain-policy SYSTEM \"/xml/dtds/cross-domain-policy.dtd\">\r\n" +
                    "<cross-domain-policy>\r\n" +
                    "<allow-access-from domain=\"*\" to-ports=\"*\" />\r\n" +
                    "</cross-domain-policy>\x0");
                    return;
                }
    
                if (BytesReceived > 0)
                {
                    HandlePacket(SB.ToString());
                }
    
                mSocket.BeginReceive(Buffer, 0, Buffer.Length, 0, new mSystem.AsyncCallback(ReceivePacketsFromUSClient), null);
            }
    
            public void HandlePacket(string Packet)
            {
                clientMessage Message = new clientMessage(Packet);
                Console.mWriteLine(Message.Header().ToString());
                PacketWriter.WritePacketToFile(Packet);
    
                if (mPacket[Message.Header()] == null)
                {
                }
                else
                {
                    mPacket[Message.Header()].Invoke();
                }
            }
    
            public void SendPolicy(string Packet)
            {
                Console.mWriteLine("[" + SocketID + "] sent " + Packet);
                Packet = Packet + mSystem.Convert.ToChar(0);
                byte[] Bytes = mSystem.Text.Encoding.Default.GetBytes(Packet);
                mSocket.BeginSend(Bytes, 0, Bytes.Length, 0, new mSystem.AsyncCallback(Hassend), null);
            }
    
            public void SendPacket(string Packet)
            {
                Console.mWriteLine("[" + SocketID + "] sent " + Packet);
                Packet = Packet + mSystem.Convert.ToChar(1);
                byte[] Bytes = mSystem.Text.Encoding.Default.GetBytes(Packet);
                mSocket.BeginSend(Bytes, 0, Bytes.Length, 0, new mSystem.AsyncCallback(Hassend), null);
            }
    
            public void Hassend(mSystem.IAsyncResult ias)
            {
                mSocket.EndSend(ias);
            }
        }
    }
    clientMessage.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Rainbow.Encoding;
    
    namespace Rainbow.Messages
    {
        public class clientMessage
        {
            public static string cypherShort(int v) // str len, packet len, packet header -- b64
            {
                string t = "";
                t += (char)((v >> 8) & 0xFF);
                t += (char)((v >> 0) & 0xFF);
                return t;
            }
    
            public static string cypherInt(int v)
            {
                string t = "";
                t += (char)((v >> 24) & 0xFF);
                t += (char)((v >> 16) & 0xFF);
                t += (char)((v >> 8) & 0xFF);
                t += (char)((v >> 0) & 0xFF);
                return t;
            }
    
            public static int DecodeBit24(string v)
            {
                if ((v[0] | v[1] | v[2] | v[3]) < 0)
                    return -1;
                return ((v[0] << 24) + (v[1] << 16) + (v[2] << 8) + (v[3] << 0));
            }
    
            public static int DecodeBit8(string v)
            {
                if ((v[0] | v[1]) < 0)
                    return -1;
                return ((v[0] << 8) + (v[1] << 0));
            }
    
            public String oString;
            public String oData;
    
            public clientMessage(string Data)
            {
                oData = Data.Substring(4);
            }
            public int Header()
            {
                int Header = PacketEncoding.DecodeBit8(oData.Substring(0, 2));
                oData = oData.Substring(2);
                return Header;
            }
    
            public bool CanGetNextString()
            {
                try
                {
                    int len = PacketEncoding.DecodeBit8(oData.Substring(0, 2));
                    if (len > 0)
                    {
                        String Result = oData.Substring(0, len);
                        if (Result != "")
                            return true;
                        else
                            return false;
                    }
                    else
                        return false;
                }
                catch
                {
                    return false;
                }
            }
    
            public int NewNextInt()
            {
                int result = PacketEncoding.DecodeBit24(oData.Substring(1, 4));
                return result;
            }
    
            public int GetNextInt()
            {
                int result = PacketEncoding.DecodeBit24(oData.Substring(0, 4));
                oData = oData.Substring(4);
    
                return result;
            }
    
            public String GetNextString()
            {
                int len = PacketEncoding.DecodeBit8(oData.Substring(0, 2));
                oData = oData.Substring(2);
    
                String Result = oData.Substring(0, len);
                oData = oData.Substring(len);
    
                return Result;
            }
    
            public string PopFixedString
            {
                get { return GetNextString(); }
            }
    
            public int PopWiredInt
            {
                get { return NewNextInt(); }
            }
    
            public int MessageHeader
            {
                get { return Header(); }
            }
        }
    }
    fuseMessage.cs
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using Rainbow.Encoding;
    
    namespace Rainbow.Messages
    {
        public class fuseMessage
        {
            public StringBuilder PacketBuilder = new StringBuilder();
    
            public fuseMessage(int Packet)
            {
                PacketBuilder.Append(clientMessage.cypherShort(Packet));
            }
    
            public void Append(int Integer)
            {
                PacketBuilder.Append(clientMessage.cypherInt(Integer));
            }
    
            public void Append(string String)
            {
                PacketBuilder.Append(clientMessage.cypherShort(String.Length));
                PacketBuilder.Append(String);
            }
    
            public void AppendLong(string LongString)
            {
                PacketBuilder.Append(clientMessage.cypherInt(LongString.Length));
                PacketBuilder.Append(LongString);
            }
    
            public void Append(bool Boolean)
            {
                PacketBuilder.Append((char)(Boolean ? 1 : 0));
            }
    
            public void Append()
            {
                PacketBuilder.Append((char)255 + (char)255 + (char)255 + (char)255);
            }
    
            public void Append(object Object)
            {
                PacketBuilder.Append(clientMessage.cypherShort(Object.ToString().Length));
                PacketBuilder.Append(Object.ToString());
            }
    
            public override string ToString()
            {
                StringBuilder NewPacketBuilder = new StringBuilder();
                NewPacketBuilder.Append(clientMessage.cypherShort(0));
                NewPacketBuilder.Append(clientMessage.cypherShort(PacketBuilder.Length));
                NewPacketBuilder.Append(PacketBuilder);
    
                return NewPacketBuilder.ToString();
            }
        }
    }
    Now use in the core of your program:

    GameConnection Connection = new GameConnection(993, "127.0.0.1");

    Login on Habbo.COM and connect to your own emulator.

    This is only for developers, or for beginners who want to be pushed forward. No cracked swfs yet, maybe my friend will do it.

    Like it or please go away, don't spam and if you like it like me and +rep me.

    Kind regards,

    George.


  2. #2
    C# | C++ Emerica is offline
    MemberRank
    Oct 2010 Join Date
    GermanyLocation
    437Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Isn't it the Tcp protocol off varoke packetlogger?
    Waves
    -Emerica
    Posted via Mobile Device

  3. #3
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Quote Originally Posted by Emerica View Post
    Isn't it the Tcp protocol off varoke packetlogger?
    Waves
    -Emerica
    Posted via Mobile Device
    Nop, completely from scratch made, I'm now coding the server fully with sending and receiving of packets, but it's hard and it's not working.

  4. #4
    Alpha Member Zak© is offline
    MemberRank
    Oct 2007 Join Date
    2,693Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Wanna see some real tcp sockets?
    [From RevEmulator]
    rSocket Server

    Code:
    namespace RevEmu.rSockets.Sockets
    {
        public class RServer : AppServer<RSession>
        {
            private Dictionary<string, List<string>> broadcastDict = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
            private object broadcastSyncRoot = new object();
    
            private Dictionary<string, RSession> broadcastSessionDict = new Dictionary<string, RSession>(StringComparer.OrdinalIgnoreCase);
            private object syncRoot = new object();
    
            public RServer()
            {
                lock (broadcastSyncRoot)
                {
                    var session = new RSession();
                    BroadcastMessage(session, "HEADER" + "Welcome To RevEmu Version 1 Build 4 Revision 2 [1.4.2]");
                }
            }
    
            internal void RegisterNewSession(RSession session)
            {
                //Get's Habbo ID And Checks If It Is 0 Or Nothing.
                if (string.IsNullOrEmpty(UserManager.GetID()))
                    return; // Decline The Request.
    
                //Start To Accept
                lock (syncRoot)
                {
                    //Load Packet Session For The ID [Load The HandShake Etc]
                    Handlers.LoadPacketSession();
                    //Load The ID To The Hotel [Accept It's Session]
                    broadcastSessionDict[UserManager.GetID()] = session;
                }
            }
    
            internal void RemoveOnlineSession(RSession session)
            {
                if (string.IsNullOrEmpty(UserManager.GetID()))
                    return;
    
                lock (syncRoot)
                {
                    broadcastSessionDict.Remove(UserManager.GetID());
                }
            }
    
            internal void BroadcastMessage(RSession session, string message)
            {
                List<string> targetDeviceNumbers;
    
                lock (broadcastSyncRoot)
                {
                    if (!broadcastDict.TryGetValue(UserManager.GetID(), out targetDeviceNumbers))
                        return;
                }
    
                if (targetDeviceNumbers == null || targetDeviceNumbers.Count <= 0)
                    return;
    
                var sessions = new List<RSession>();
    
                lock (syncRoot)
                {
                    RSession s = null;
    
                    sessions.AddRange(from key in targetDeviceNumbers where broadcastSessionDict.TryGetValue(key, out s) select s);
                }
    
                Async.Run(() => sessions.ForEach(s => s.SendResponse(message)));
            }
    
            
    
            protected override void OnAppSessionClosed(object sender, AppSessionClosedEventArgs<RSession> e)
            {
                RemoveOnlineSession(e.Session);
                base.OnAppSessionClosed(sender, e);
            }
        }
    }
    rSocket rSession
    Code:
    using System;
    using RevEmu.rMessage;
    using SuperSocket.SocketBase;
    using System.Net.Sockets;
    
    namespace RevEmu.rSockets.Sockets
    {
        public class RSession : AppSession<RSession>
        {
    
            #region Fields
            public AsyncCallback SendCallback { get; private set; }
            private Socket mSocket;
    
            public RSession(Socket mSocket)
            {
                this.mSocket = mSocket;
            }
    
            public RSession()
            {
                throw new NotImplementedException();
            }
    
            #endregion
    
            #region Override Voids
            public override void StartSession()
            {
                Console.WriteLine("Welcome to RevSockets!");
            }
    
            public override void HandleExceptionalError(Exception e)
            {
                Console.WriteLine("Server side error occurred!");
            }
            #endregion
    
        }
    }
    Feel free to look.

  5. #5
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Quote Originally Posted by Zak© View Post
    Wanna see some real tcp sockets?
    [From RevEmulator]
    rSocket Server

    Code:
    namespace RevEmu.rSockets.Sockets
    {
        public class RServer : AppServer<RSession>
        {
            private Dictionary<string, List<string>> broadcastDict = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);
            private object broadcastSyncRoot = new object();
    
            private Dictionary<string, RSession> broadcastSessionDict = new Dictionary<string, RSession>(StringComparer.OrdinalIgnoreCase);
            private object syncRoot = new object();
    
            public RServer()
            {
                lock (broadcastSyncRoot)
                {
                    var session = new RSession();
                    BroadcastMessage(session, "HEADER" + "Welcome To RevEmu Version 1 Build 4 Revision 2 [1.4.2]");
                }
            }
    
            internal void RegisterNewSession(RSession session)
            {
                //Get's Habbo ID And Checks If It Is 0 Or Nothing.
                if (string.IsNullOrEmpty(UserManager.GetID()))
                    return; // Decline The Request.
    
                //Start To Accept
                lock (syncRoot)
                {
                    //Load Packet Session For The ID [Load The HandShake Etc]
                    Handlers.LoadPacketSession();
                    //Load The ID To The Hotel [Accept It's Session]
                    broadcastSessionDict[UserManager.GetID()] = session;
                }
            }
    
            internal void RemoveOnlineSession(RSession session)
            {
                if (string.IsNullOrEmpty(UserManager.GetID()))
                    return;
    
                lock (syncRoot)
                {
                    broadcastSessionDict.Remove(UserManager.GetID());
                }
            }
    
            internal void BroadcastMessage(RSession session, string message)
            {
                List<string> targetDeviceNumbers;
    
                lock (broadcastSyncRoot)
                {
                    if (!broadcastDict.TryGetValue(UserManager.GetID(), out targetDeviceNumbers))
                        return;
                }
    
                if (targetDeviceNumbers == null || targetDeviceNumbers.Count <= 0)
                    return;
    
                var sessions = new List<RSession>();
    
                lock (syncRoot)
                {
                    RSession s = null;
    
                    sessions.AddRange(from key in targetDeviceNumbers where broadcastSessionDict.TryGetValue(key, out s) select s);
                }
    
                Async.Run(() => sessions.ForEach(s => s.SendResponse(message)));
            }
    
            
    
            protected override void OnAppSessionClosed(object sender, AppSessionClosedEventArgs<RSession> e)
            {
                RemoveOnlineSession(e.Session);
                base.OnAppSessionClosed(sender, e);
            }
        }
    }
    rSocket rSession
    Code:
    using System;
    using RevEmu.rMessage;
    using SuperSocket.SocketBase;
    using System.Net.Sockets;
    
    namespace RevEmu.rSockets.Sockets
    {
        public class RSession : AppSession<RSession>
        {
    
            #region Fields
            public AsyncCallback SendCallback { get; private set; }
            private Socket mSocket;
    
            public RSession(Socket mSocket)
            {
                this.mSocket = mSocket;
            }
    
            public RSession()
            {
                throw new NotImplementedException();
            }
    
            #endregion
    
            #region Override Voids
            public override void StartSession()
            {
                Console.WriteLine("Welcome to RevSockets!");
            }
    
            public override void HandleExceptionalError(Exception e)
            {
                Console.WriteLine("Server side error occurred!");
            }
            #endregion
    
        }
    }
    Feel free to look.
    No, it's too much text for me, it's giving me a headache.

    Also, thanks for your support :)

  6. #6
    Alpha Member Zak© is offline
    MemberRank
    Oct 2007 Join Date
    2,693Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Lol it's much cleaner then your tcp sockets.

    I don't see how it can give you a headache.

  7. #7
    The Sex Addict Poizone2 is offline
    MemberRank
    Oct 2011 Join Date
    UKLocation
    523Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    wtf is this?

  8. #8
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Quote Originally Posted by Zak© View Post
    Lol it's much cleaner then your tcp sockets.

    I don't see how it can give you a headache.
    I'm a noob I already had a headache and I don't understand..;P

  9. #9
    Alpha Member Zak© is offline
    MemberRank
    Oct 2007 Join Date
    2,693Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Wait you don't understand a interface and some dictionary's, then what the hell are you developing?

  10. #10
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Quote Originally Posted by Zak© View Post
    Wait you don't understand a interface and some dictionary's, then what the hell are you developing?
    I mean, you use some .dll for extra files.
    When I'm using RevEmu I can't even connect to any hotel (with right port and ip)

    I just use some files.

  11. #11
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Quote Originally Posted by George2000 View Post
    I mean, you use some .dll for extra files.
    When I'm using RevEmu I can't even connect to any hotel (with right port and ip)

    I just use some files.
    Where do you see .dll in the snippets

  12. #12
    Account Upgraded | Title Enabled! Wupz0r is offline
    MemberRank
    Oct 2011 Join Date
    RaGEZONELocation
    229Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    You're risking musch by using an array for Packets[];

    Code:
     private byte[] Buffer = new byte[50000]; // not important I guess..
    Its important. use: 512 (Regular buffer-size) / 1024

  13. #13
    Demi-god on these 'ere wa DominicGunn is offline
    MemberRank
    Jun 2011 Join Date
    347Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    These are looking alright for your own attempt! There's a few problems (the byte[50000] as already pointed out should immediately be changed. :P), but it's alot more thought out than some of the applications I was writing when I tried to properly write my own code!

  14. #14
    Alpha Member Zak© is offline
    MemberRank
    Oct 2007 Join Date
    2,693Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Quote Originally Posted by George2000 View Post
    I mean, you use some .dll for extra files.
    When I'm using RevEmu I can't even connect to any hotel (with right port and ip)

    I just use some files.
    That was a framework >.> it was not suppose to work fully.

    Anyway good release i guess.

  15. #15
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Need some help:

    for example"::

    [0][0][0]€[0]

    which part must I use for (de)cyphering into an int

  16. #16
    Account Upgraded | Title Enabled! =dj.matias= is offline
    MemberRank
    Apr 2008 Join Date
    FinlandLocation
    381Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Habbo Packet structure:
    [0] + Length + Header + String Length + String + sometimes([0])
    [0][0][0]%»[0] eb4745df058bc61a800125d7d99ca72b[0]

  17. #17
    Account Upgraded | Title Enabled! George2000 is offline
    MemberRank
    Jul 2011 Join Date
    The NetherlandsLocation
    1,150Posts

    Re: Project Rainbow TCP [R63, Habbo.Com/Client]

    Quote Originally Posted by =dj.matias= View Post
    Habbo Packet structure:
    [0] + Length + Header + String Length + String + sometimes([0])
    [0][0][0]%»[0] eb4745df058bc61a800125d7d99ca72b[0]
    Okay thanks.. so the length is 0 and the string length is 0 too?



Advertisement