- Joined
- Jul 7, 2011
- Messages
- 944
- Reaction score
- 205
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
AccountClient.cs
clientMessage.cs
fuseMessage.cs
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.
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.