Revolution Emulator [C#, R63B, Encryption Cracked, DAO, Fluent NHibernate, Lua Plugin, Mono]

Status
Not open for further replies.

Zak

Posting Freak
Mar 12, 2011
847
453
ServerMessage Updates.
Code:
 public Sm(Int32 header)
        {
            _header = header;
            header = RCrypto.DecodeBit8(SClientMessage.OString.Substring(4, 6));
            _contentBuilder = new StringBuilder();

            AppendInt(header);
        }

RCrypto Updates.
Code:
 public class RCrypto
    {
        #region RCrypto Required Fields
        private static string _data;
        private static int _header;
        private static int _lenght;
        private static string[] _extraDatas;
        private static int _e1 = 0;
        private static int _e2 = 0;
        #endregion

        #region Encode Int32,Int16

        public static void cypherInt(int v)
        {
            HabboEncoding.HabboEncoding.cypherInt(v);
        }

        public static void cypherShort(int v)
        {
            HabboEncoding.HabboEncoding.cypherShort(v);
        }

        #endregion

        #region Decode Int32,Int16

        public static void decypherInt(string v)
        {
            HabboEncoding.HabboEncoding.decypherInt(v);
        }

        public static void decypherShort(string v)
        {
            HabboEncoding.HabboEncoding.decypherShort(v);
        }

        #endregion

        #region Encode Bit8,Bit32

        public static string EncodeBit32(string v)
        {
            return EncodeBit32(v.Length);
        }

        public static string EncodeBit32(int v) // int
        {
            string t = "";
            t += (char) 0; // 4 bytes
            t += (char) ((v >> 24) & 0xFF); // 3 bytes
            t += (char) ((v >> 16) & 0xFF); // 2 bytes
            t += (char) ((v >> 8) & 0xFF); // 1 byte
            t += (char) ((v) & 0xFF);
            return t;
        }

        #endregion

        #region Decode Bit8,Bit32

        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));
        }

        #endregion

        #region Encoding Etc

        public static void Init(string publicKey, string privateKey)
        {
            HabboEncoding.HabboEncoding.init(publicKey, privateKey);
        }

        #endregion

        #region Crypto Utilities

        public static void PrepareCryptoSystem()
        {
            HabboEncoding.CryptoUtils.PrepareCryptoSystem();
        }

        #endregion

        #region LJ282 Setup Crypto

        public static void SetUpCrypto(string cryptoHash)
        {
            HabboEncoding.LJ382.SetupCyrpto(cryptoHash);
        }

        #endregion

        #region LJ282 Encode String

        public static void EncodeString(string str)
        {
            HabboEncoding.LJ382.EncodeString(str);
        }

        #endregion

        #region LJ282 Decode String

        public static void DecodeString(string str)
        {
            HabboEncoding.LJ382.DecodeString(str);
        }

        #endregion

        #region CryptoSystem Functions
        public static bool IsValidString(string inputStr)
        {
            if (string.IsNullOrEmpty(inputStr))
            {
                return false;
            }

            for (int i = 0; i < inputStr.Length; i++)
            {
                string s = inputStr[i].ToString();
                if (s == "." || s == "," || s == ";" || s == ":" || s == "<" || s == ">" || s == "@" || s == @"\" || s == "/")
                {
                    return true;
                }
                else if (!(IsLetter(s)))
                {
                    return false;
                }
            }

            return true;
        }

        public static bool IsValidInt(string inputStr)
        {
            if (string.IsNullOrEmpty(inputStr))
            {
                return false;
            }

            for (int i = 0; i < inputStr.Length; i++)
            {
                string s = inputStr[i].ToString();
                if (!(char.IsNumber(inputStr[i])))
                {
                    return false;
                }
            }

            return true;
        }


        public static bool IsValidName(string inputStr)
        {
            if (string.IsNullOrEmpty(inputStr))
            {
                return false;
            }

            for (int i = 0; i < inputStr.Length; i++)
            {
                string s = inputStr[i].ToString();
                if (s == "." || s == "," || s == ";" || s == ":" || s == "<" || s == ">" || s == "@" || s == @"\" || s == "/" || s == "#")
                {
                    return true;
                }
                else if (!(IsLetter(s)) && !(char.IsNumber(inputStr[i])))
                {
                    return false;
                }
            }

            return true;
        }

        public static bool IsLetter(string s)
        {
            s = s.ToLower();
            if (s == "a" || s == "b" || s == "c" || s == "d" || s == "e" || s == "f" || s == "g"
                 || s == "h" || s == "i" || s == "j" || s == "k" || s == "l" || s == "m" || s == "n" || s == "ñ"
                 || s == "o" || s == "p" || s == "q" || s == "r" || s == "s" || s == "t" || s == "u" || s == "v"
                 || s == "w" || s == "x" || s == "y" || s == "z" || s == "¡" || s == "!" || s == "¿" || s == "?" || s == "á"
                 || s == "é" || s == "í" || s == "ó" || s == "ú" || s == "|" || s == "#" || s == "-" || s == "_" ||
                    s == "[" || s == " " || s == "]")
                return true;
            else
                return false;
        }
        #endregion

        #region Habbo new Crypto: 'char Encode' by Itachi

        public RCrypto(string internalData)
        {
            _data = internalData;
            string conn = _data.ToString();
            conn = conn.Replace("{char0}", Convert.ToChar(0).ToString());
            conn = conn.Replace("{char1}", Convert.ToChar(1).ToString());
            conn = conn.Replace("{char2}", Convert.ToChar(2).ToString());
            conn = conn.Replace("{char13}", Convert.ToChar(13).ToString());
            string final = conn.Select(C => "{char" + (int) C + "}").Aggregate("", (current, zC) => current + zC);
            final = final.Replace("{char", "");
            final = final.Substring(0, final.Length - 1);
            final = final.Replace("}", ";");
            string[] toSepare = final.Split(';');
            int sLenght = DecodeBit8(internalData.Substring(2, 2));
            int sHeader = DecodeBit8(internalData.Substring(4, 2));
            string extra = "";
            for (int i = 6; i != toSepare.Length; i++)
            {
                string s = Convert.ToChar(int.Parse(toSepare[i])).ToString();
                string fs = "";
                if (toSepare.Length > i + 1)
                    fs = Convert.ToChar(int.Parse(toSepare[i + 1])).ToString();
                if (IsValidName(s))
                {
                    extra += Convert.ToChar(int.Parse(toSepare[i]));
                    if (!IsValidName(fs))
                        extra += ";";
                }
                else
                    extra += toSepare[i] + ";";

            }
            _header = sHeader;
            _lenght = sLenght;
            _extraDatas = extra.Split(';');
        }

        internal static int CharEncodeGetHeader()
        {
            return _header;
        }

        internal static int CharEncodeGetLenght()
        {
            return _lenght;
        }

        internal static string CharEncodeGetNextString()
        {
            while (true)
            {
                if (_extraDatas.Length < _e1)
                    return null;

                if (IsValidString(_extraDatas[_e1]))
                    return _extraDatas[_e1];
                else
                    _e1++;
            }
        }

        internal static int CharEncodeGetNextInt()
        {
            while (true)
            {
                if (_extraDatas.Length < _e1)
                    return -1;

                if (IsValidInt(_extraDatas[_e1]))
                    return int.Parse(_extraDatas[_e1]);
                else
                    _e1++;
            }
        }

        #endregion
    }

-Another update will be added on, due to the limit of characters per post.
 

Zak

Posting Freak
Mar 12, 2011
847
453
ClientMessage Rechanged

Code:
    class Cm
    {

        public String OString;
        public String OData;

        public Cm(string data)
        {
            OData = data.Substring(4);
        }
        public int Header()
        {
            var header = RCrypto.DecodeBit8(OData.Substring(0, 2));
            OData = OData.Substring(2);
            return header;
        }

        public bool CanGetNextString()
        {
            try
            {
                int len = RCrypto.DecodeBit8(OData.Substring(0, 2));
                if (len > 0)
                {
                    var result = OData.Substring(0, len);
                    if (result != "")
                        return true;
                    else
                        return false;
                }
                else
                    return false;
            }
            catch
            {
                return false;
            }
        }

        public int NewNextInt()
        {
            int result = RCrypto.DecodeBit24(OData.Substring(1, 4));
            return result;
        }

        public int GetNextInt()
        {
            int result = RCrypto.DecodeBit24(OData.Substring(0, 4));
            OData = OData.Substring(4);

            return result;
        }

        public String GetNextString()
        {
            int len = RCrypto.DecodeBit8(OData.Substring(0, 2));
            OData = OData.Substring(2);

            String result = OData.Substring(0, len);
            OData = OData.Substring(len);

            return result;
        }
    }

DatabaseType system Updated.

Code:
        public CatalogueItems()
        {
            //List
            _cacheColumns = new List<CatalogueItems>();

            //Get Columns
            foreach (DataRow catalogItems in GetTable.Invoke("").Rows)
            {
             
                _cacheColumns.Add((int)catalogItems["id"], (int)catalogItems["page_id"], (string)catalogItems["item_ids"],(string)catalogItems["catalog_name"], (int)catalogItems["cost_credits"], (int) catalogItems["cost_pixels"], (int) catalogItems["cost_snow"] , (int) catalogItems["amount"]);
            }
        }

        public CatalogueItems(int cId, int cPageId, string cItemIds, string cCatalogName, int cCostCredits, int cCostPixels, int cCostSnow, int cAmount)
        {
            Id = cId;
            PageId = cPageId;
            ItemIds = cItemIds;
            CatalogName = cCatalogName;
            CostCredits = cCostCredits;
            CostPixels = cCostPixels;
            CostSnow = cCostSnow;
            Amount = cAmount;
        }
 

Zak

Posting Freak
Mar 12, 2011
847
453
Sorry, for the lack of updates.

Well a main feature i just coded incase of hacking, is a backup-database system.

It stores dumps of your database to your selected location. Also you can setup to store backups like every week, every hour, every day, etc.
I've almost finished doing the fields for the Phoenix database. I just gotta figure a way to return them efficiently.
I'll show you a sneak peak of the backup system in a few hours.

Also once the multiple database system is done, i can finally start on the SSO.
 

SkeetEmUp

Habpl.us
May 16, 2011
326
112
Backup system sounds great but will this lag it at all? I know backups can cause ingame lag. If it will then maybe have it send a hotel alert saying backup is happening or something.

Looks amazing :) Also the green ticks at the start mean that its completed or will be added? I've only skimmed this thread so sorry if you have already answered.
 

Adil

DevBest CEO
May 28, 2011
1,276
714
Isn't Manuel working on a cron job for backing up the database in the cms?
Anyway, good luck Zak!
 

Livar

Now 35% cooler!
Oct 15, 2010
846
86
Backup system sounds great but will this lag it at all? I know backups can cause ingame lag. If it will then maybe have it send a hotel alert saying backup is happening or something.

Looks amazing :) Also the green ticks at the start mean that its completed or will be added? I've only skimmed this thread so sorry if you have already answered.
You'd have to close the Emulator, so you can save it at one specific point.
 

Zak

Posting Freak
Mar 12, 2011
847
453
Backup system sounds great but will this lag it at all? I know backups can cause ingame lag. If it will then maybe have it send a hotel alert saying backup is happening or something.

Looks amazing :) Also the green ticks at the start mean that its completed or will be added? I've only skimmed this thread so sorry if you have already answered.

Nope it shouldn't even lag as it's coded efficiently. And normally it shows on the console of the emulator that it's been saved.

Isn't Manuel working on a cron job for backing up the database in the cms?
Anyway, good luck Zak!
No idea.

You'd have to close the Emulator, so you can save it at one specific point.
Don't worry you don't need to close the emulator, it just dumps it via file stream.
 

Zak

Posting Freak
Mar 12, 2011
847
453
Thanks to Mr. Christ for he's support that i have managed to code a new way of coding coding
The way i was coding was pretty simple and advanced. BUT Rev is all pro ;p [I can't fall back to RevCMS's aswesome coding!]
So i will be recoding most of the source using Linq style!

What the fuck is Linq style of coding?

Example of getting some querys using Unix expressions.

Normal Coding
Code:
            foreach (DataRow catalogItems in GetTable.Invoke("").Rows)
            {
                // Instead of using the Convert class from system, i decided to use explict casts for quick and clean conversions.
                // Example of running this would be to do the follow code: var catalogueItemCoulmns = new CataLogueItems(); Then do catalogueItemsColumns.[Column] This selects it directly from the Sql database.

                var id = (int) catalogItems["id"];
                var pageId = (int) catalogItems["page_id"];
                var itemIds = (string) catalogItems["item_ids"];
                var catalogName = (string) catalogItems["catalog_name"];
                var costCredits = (int) catalogItems["cost_credits"];
                var costPixels = (int) catalogItems["cost_pixels"];
                var costSnow = (int) catalogItems["cost_snow"];
                var amount = (int) catalogItems["amount"]; 
            }

Linq Expressions used coding

Code:
       foreach (var amount in from DataRow catalogItems in GetTable.Invoke("").Rows let id = (int) catalogItems["id"] let pageId = (int) catalogItems["page_id"] let itemIds = (string) catalogItems["item_ids"] let catalogName = (string) catalogItems["catalog_name"] let costCredits = (int) catalogItems["cost_credits"] let costPixels = (int) catalogItems["cost_pixels"] let costSnow = (int) catalogItems["cost_snow"] select (int) catalogItems["amount"])
            {
                // Set Data Here
            }
 

Zak

Posting Freak
Mar 12, 2011
847
453
I also spotting something interesting in msdn.

I can run my querys like this


IEnumerable<int> orderingQuery =
from num in numbers
where num < 3 || num > 7
orderby num ascending
select num;
 

Supersup

Member
Dec 23, 2010
43
5
Been quite a while since the development started. Any idea of when the development is going to function? even a slight?
 

Zak

Posting Freak
Mar 12, 2011
847
453
I am making this best as possible rushed projects won't get no where.

I need to code this as effiecntly as possible we don't want it to collapse when you just enter the sso?
The thing that's just taking time is the doing all the columns.
So i decided just to do the phoenix columns for the sso and work on the Database system, so i'll just change the querys.

Why am i doing this?
People are asking for in-game pics.

Also THIS PROJECT IS NOT DUMPED.
i have not been updating as i have been studying and re doing the Linq expressions through out the whole source.

And yes it does function in various of ways.
For starters it's Socket Reciving and handling, Base and Engline of the sockets are functioning well, also Config Parser, HandShake, PacketSession [Best going so far].
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
I am making this best as possible rushed projects won't get no where.

I need to code this as effiecntly as possible we don't want it to collapse when you just enter the sso?
The thing that's just taking time is the doing all the columns.
So i decided just to do the phoenix columns for the sso and work on the Database system, so i'll just change the querys.

Why am i doing this?
People are asking for in-game pics.

Also THIS PROJECT IS NOT DUMPED.
i have not been updating as i have been studying and re doing the Linq expressions through out the whole source.

And yes it does function in various of ways.
For starters it's Socket Reciving and handling, Base and Engline of the sockets are functioning well, also Config Parser, HandShake, PacketSession [Best going so far].

Don't worry, take your time.
I rather have a stable, feature-rich emulator in 2 years than an unstable and crappy one in 5 months.

( Date are totally random )
 

Heaplink

Developer & Designer
Nov 9, 2011
510
173
Thumbs up for you Zak. I'm looking forward to use this for my hotel, so my community can enjoy a great and fast server ;-)
 

Brennen

hippopotomonstrosesquipedaliophobia
Nov 6, 2011
291
36
Not complaining, but @ Christ, I know you picked random, but within that 2 years, I bet it would go from R63 to R64 or maybe even R65, anyways,

Not trying to be a bitch but,

Also, I cannot WAIT for in games. Dont rush it please, i agree with christ just not the dates ;)
 

Zak

Posting Freak
Mar 12, 2011
847
453
RevEmu is programmed to support the newest revision.

Not the a certain revision.
 
Status
Not open for further replies.

Users who are viewing this thread

Top