Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Programming
You last visited: Today at 05:19

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Proxy Library Version 2.0

Discussion on Proxy Library Version 2.0 within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jan 2007
Posts: 118
Received Thanks: 20
Proxy Library Version 2.0

This is the major revamp of my old version. Additionally this new library also include the interface of cryptography which is defined in the "connection" class and which is having the signature function of Decrypt and Encrypt. This cryptography interface can be implemented outside the parent class therefore making this proxy library a very flexible tools for creating a proxy with different type of encryption.

Cryptography Interface signature:
Code:
        public interface Icrypto
        {
            void Decrypt(ref byte[] data, bool IsRemServer);
            void Encrypt(ref byte[] data, bool IsRemServer);
        }
We know that we have an interface installed inside the connection class which can implemented on the parent class but we don't know how and when is the right time to initialize it. Well this can be done perfectly during when the proxy established the connection between remote-proxy-client such as the example below.
Code:
        private void myProxy_NewConnectionEvent(object sender, int sessionid)
        {
            //Initialized the encryptor here
            CrypImplementer cryptImp = new CrypImplementer();
            myProxy.SetCryptImp((object)cryptImp, sessionid);

        }

        private class CrypImplementer : connection.Icrypto
        {
            public CrypImplementer() { }

            public void Decrypt(ref byte[] data, bool IsRemServer)
            { 
                /*Define your Decryption here
                 * IrRemServer is true when the data is coming from server 
                 * otherwise it is false
                */
            }
            public void Encrypt(ref byte[] data, bool IsRemServer)
            {
                /*Define your Encryption here
                 * IrRemServer is true when the data is coming from server 
                 * otherwise it is false
                */
            }
 
        }
When the cryptography will be incorporated correctly, a decrypted packet shall be available on the Data arrival events and you can do whatever you want on that packet.
Code:
        private void myProxy_DataArrivalEvent(
            object sender,
            object data,
            int sessionid,
            Boolean IsRemServer)
        {
            connection conn = (connection)sender;
            if (IsRemServer)
            {
                // You can add packet handler here
                conn.SendPC(data);
            }
            else
            {
                // You can add packet handler here
                conn.SendPS(data);
            }
        }
Please take note that I have added the sessionid on each events which also corresponds to the connection id for each remote-proxy-client session. This sessionid is just an incremental value of integer. The purpose of this sessionid is if you want to control the specific connection and if you want to access its public method from the parent class such as the example below.
Code:
connection tmpcon=myProxy.GetConn(sessionid);
tmpcon.SendPC((object) byte); // send data from proxy to client for connection id= sessionid
tmpcon.SendPS((object) byte); // send data from proxy to remote host for  connection id= sessionid

General Implementation of the library:

Importing the library
Code:
using xmenproxy;
Initializing the library.
Code:
/*
* If you have more proxy listening at different port then you can defined different instance for it
*/
ProxyServer myProxy = new ProxyServer();

//ProxyServer myProxy2 = new ProxyServer();
//ProxyServer myProxy3 = new ProxyServer();
//etc
Starting the proxy and defining the events
Code:
            myProxy.RemoteIP = "remotehostip";
            myProxy.RemotePort = 9960;
            myProxy.LocalPort = 9960;
            myProxy.LocalIP = "localhost";
            myProxy.DataArrivalEvent += new ProxyServer.DataArrival(myProxy_DataArrivalEvent);
            myProxy.NewConnectionEvent += new ProxyServer.NewConnection(myProxy_NewConnectionEvent);
            myProxy.StartServer();
Events Callback
Code:
        private void myProxy_NewConnectionEvent(object sender, int sessionid)
        {
            //Initialized the encryptor here
            CrypImplementer cryptImp = new CrypImplementer();
            myProxy.SetCryptImp((object)cryptImp, sessionid);

        }
        private void myProxy_DataArrivalEvent(
            object sender,
            object data,
            int sessionid,
            Boolean IsRemServer)
        {
            connection conn = (connection)sender;
            if (IsRemServer)
            {
                conn.SendPC(data);
            }
            else
            {
                conn.SendPS(data);
            }
        }
See also the attached test proxy example. If you find any bugs please let me know.
Attached Files
File Type: rar xmenproxy v2.0.rar (51.1 KB, 128 views)
xmen01235 is offline  
Thanks
4 Users
Old 09/04/2012, 18:36   #2
 
elite*gold: 0
Join Date: Jan 2007
Posts: 118
Received Thanks: 20
Proxy Library Implementation for Authentication Server:

Code:
private ProxyServer AuthSE;
Code:
        private void btnStartServer_Click(object sender, EventArgs e)
        {
            AuthSE = new ProxyServer();
            AuthSE.RemoteIP = "208.96.34.46";            
            AuthSE.RemotePort = 9960;
            AuthSE.LocalPort = 9960;
            AuthSE.LocalIP = myLocalhost.GetmyIP();
            AuthSE.DataArrivalEvent+=new ProxyServer.DataArrival(AuthSE_DataArrivalEvent);
            AuthSE.NewConnectionEvent+=new ProxyServer.NewConnection(AuthSE_NewConnectionEvent);            
            AuthSE.StartServer();
         }
Code:
        private void AuthSE_NewConnectionEvent(object sender, int sessionid)
        { 
            AuthCrypt authcryp=new AuthCrypt();
            AuthSE.SetCryptImp((object)authcryp, sessionid);
        }


        private void AuthSE_DataArrivalEvent(
            object sender,             
            object data,             
            int sessionid,
            Boolean IsRemServer)
        {
            byte[] bytedata = (byte[])data;
            connection conn = (connection)sender;
            if(IsRemServer)
            {
                myPacket SPacket = new myPacket(ref bytedata);
                if (AuthResponce.IsThisType(SPacket))
                {
                    AuthResponce auth = new AuthResponce(ref SPacket);
                    auth.GameServerIp = myLocalhost.GetmyIP();
                }
                conn.SendPC((object)bytedata);
            }
            else
            {
                myPacket CPacket = new myPacket(ref bytedata);
                if (LoginInformation.IsThisType(CPacket))
                {
                    LoginInformation logInfo = new LoginInformation(ref CPacket);
                }

                conn.SendPS((object)bytedata);
            }
        }
Code:
    class AuthCrypt : connection.Icrypto
    {
        private AuthCrypto AutCrypthSP;
        private AuthCrypto AutCrypthCP;

        public AuthCrypt()
        {
            this.AutCrypthSP = new AuthCrypto();
            this.AutCrypthCP = new AuthCrypto();
        }

        public void Decrypt(ref byte[] data, bool IsRemServer)
        {
            if (IsRemServer)
            {
                this.AutCrypthSP.Decrypt(ref data);
            }
            else
            {
                this.AutCrypthCP.Decrypt(ref data);
            }
        }
        public void Encrypt(ref byte[] data, bool IsRemServer)
        {
            if (IsRemServer)
            {
                this.AutCrypthSP.Encrypt(ref data);
            }
            else
            {
                this.AutCrypthCP.Encrypt(ref data);
            }

        }
    }

public class AuthCrypto
    {
        private class crypCounter
        {
            private UInt16 mcounter;
            public crypCounter()
            {
                this.mcounter = 0;
            }
            public byte mkey1()
            {
                return ((byte)(mcounter & 0xFF));
            }
            public byte mkey2()
            {
                return ((byte)(mcounter >> 8));
            }
            public void increment()
            {
                mcounter++;
            }

        }
        private byte[] crypKey1;
        private byte[] crypKey2;
        private crypCounter encryptCounter = new crypCounter();
        private crypCounter decryptCounter = new crypCounter();

        public AuthCrypto()
        {
            crypKey1 = new byte[256];
            crypKey2 = new byte[256];
            byte ikey1 = 0x9D;
            byte ikey2 = 0x62;

            for (int i = 0; i < 256; i++)
            {
                crypKey1[i] = ikey1;
                crypKey2[i] = ikey2;
                ikey1 = (byte)((0x0F + (byte)(ikey1 * 0xFA)) * ikey1 + 0x13);
                ikey2 = (byte)((0x79 - (byte)(ikey2 * 0x5C)) * ikey2 + 0x6D);
            }
        }
        public void Encrypt(ref byte[] buffer)
        {
            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i] ^= (byte)(0xAB);
                buffer[i] = (byte)(buffer[i] >> 4 | buffer[i] << 4);
                buffer[i] ^= (byte)(this.crypKey1[this.encryptCounter.mkey1()] ^ this.crypKey2[this.encryptCounter.mkey2()]);
                this.encryptCounter.increment();
            }

        }
        public void Decrypt(ref byte[] buffer)
        {
            for (int i = 0; i < buffer.Length; i++)
            {
                buffer[i] ^= (byte)(this.crypKey2[this.decryptCounter.mkey2()] ^ this.crypKey1[this.decryptCounter.mkey1()]);
                buffer[i] = (byte)(buffer[i] >> 4 | buffer[i] << 4);
                buffer[i] ^= (byte)(0xAB);
                this.decryptCounter.increment();
            }
        }
    }
For Game server, you can follow the same but you need to change the encryption type and you need to add the DH handshaking.
xmen01235 is offline  
Thanks
2 Users
Old 09/04/2012, 19:10   #3


 
KraHen's Avatar
 
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
I like the idea, but I really don`t like your API design. I`m used to creating APIs for my personal projects as well, but I tend to use waaaay more abstraction.

Nevertheless, I`m sure there are people who can and are willing to use this, and it truly is a good contribution. I salute you.
KraHen is offline  
Old 09/04/2012, 19:38   #4
 
elite*gold: 0
Join Date: Jan 2007
Posts: 118
Received Thanks: 20
Quote:
Originally Posted by KraHen View Post
I like the idea, but I really don`t like your API design. I`m used to creating APIs for my personal projects as well, but I tend to use waaaay more abstraction.

Nevertheless, I`m sure there are people who can and are willing to use this, and it truly is a good contribution. I salute you.
I tend to program on VB style but I am getting so addicted with c# ... Honestly I am not a programmer in profession and this is just my hobby but I learned a lot from you guys. But I studied a lot the style of coding from each programmer and tend to follow on their style if I like it. I know you will laugh at me but I still don't have any idea what really abstraction is lol. But I am going to research on that until I will get a full grasp on that matter and going to implement on my program.

Thanks for cheering me up ...
xmen01235 is offline  
Old 09/04/2012, 21:56   #5
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Great to see this, quite a few proxy stuff coming out lately as well other stuff It's just amazing
I don't have a username is offline  
Old 09/06/2012, 02:31   #6
 
JohnHeatz's Avatar
 
elite*gold: 150
Join Date: Apr 2010
Posts: 9,739
Received Thanks: 8,981
I really like this one, maybe due to me being using VB.Net as well for quite some time now, yet I am getting into C# step by step, hope to see some more about this soon, and be able to develop my own soon too.
JohnHeatz is offline  
Reply


Similar Threads Similar Threads
Proxy Library
08/08/2012 - CO2 Programming - 22 Replies
Implementation: 1.) Add Reference XmenProxy.dll and don't forget to add it in the header using XmenProxy; 2.) Redirecting the conquer client(Change the pathname of the conquer.exe according to the instalation path of conquer in your PC)
need cid proxy old version
06/09/2009 - Conquer Online 2 - 5 Replies
Hello all, I playing on private server.That private server using pach 5065. I never shared my id and pw to someone but there was the server mistake I with my id and pw loged to other acc and she loged to mine.So she scammed me. Now I want get my dbs again with cid proxy :D I searched for old version long time but found only 1.0.0.9 it's too new... IF someone know where to find or someone have cid proxy working with pach 5065 please help me. Ty.
New version of proxy?
03/23/2007 - Conquer Online 2 - 2 Replies
I heard rumors from people that there is a new version of the known QOProxy. Which apperently has the function to set hotkeys to activate it and turn it off. (on that way if people ask to type !aimbot ur possible to do it) I want conformation if it's true.
.NET 2.0/c# - CO2 Proxy Library
08/12/2006 - CO2 Exploits, Hacks & Tools - 29 Replies
Hi, As I spent a good days work writing this, and I got a lot of help from reading through posts from this forum to get it going I feel I should contribute something back! Maybe some of you could help me expand this code by sharing some your knowledge of the structure of the packets. I will cover the following in this post: 1) What this code does, and how to use it 2) What I know about different packets types (and what I'm assuming, I may be wrong!) 3) What I want to know! If anyone...



All times are GMT +2. The time now is 05:20.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.