Register for your free account! | Forgot your password?

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

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

Advertisement



Help with proxy code

Discussion on Help with proxy code within the CO2 Programming forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
tkblackbelt's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 266
Received Thanks: 85
Help with proxy code

Ok so I started to make my own proxy and have got the client to connect to it but when I connect to the AuthServer I get the output -597210518-11065-488, I'm not sure if thats the right output. Ill post my code so far. I would appreciate it if someone pointed out what I'm doing wrong. thanks

Java

Code:
package lightproxy;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main{

    public static void main(String args[]) throws IOException{



        //Client Port number
        final int PORT = 9959;
        String AuthIp = "208.96.34.46";

        //Connects to client
        ServerSocket Client = new ServerSocket(PORT);
        System.out.println(getTime() + "Waiting for connections on Port : " + PORT);
        Socket Clientsoc = Client.accept();
        
        
        System.out.println(getTime() +  "Client connected");

        //Connects to Auth Server
        Socket s = new Socket(AuthIp,PORT);
     
        BufferedInputStream in = new BufferedInputStream(s.getInputStream());

        while(true){
            int end = in.read();
            if(end == -1)
                break;
            else{
            byte b = (byte)end;
            System.out.print(b);
            }
        }

       }

    public static String getTime(){
        Calendar cal = java.util.GregorianCalendar.getInstance (  ) ;
        SimpleDateFormat sdf = new SimpleDateFormat ( "yyyy/MM/dd hh:mm:ss" ) ;
        return (sdf.format(cal.getTime())) + " : ";
    }
}
tkblackbelt is offline  
Old 10/16/2010, 21:28   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
First of all I don't know java syntax but it looks like you're combining the entire values for the packet and printing them out...

#1 It's a byte array which then needs to be structured and read using REVERSED BYTE ORDER

Eg

uint with value of 1 is

1 0 0 0

IIRC java's default 'readers' for that type of stuff (binary reader for files did it) where it wouldn't reverse the order so you get funky values. You need java's equivalent of a bitconverter. You will also need to think of an efficient method for writing packets. Something like writeuint32(value, offset, destination); is what I use... one of impulse's methods (and others use it) but anything will work really.

Also keep in mind you will need to decrypt the incoming information using AuthEncryption (it's posted in every source ever and is incredibly simple) and Blowfish for the game server.

Check out the proxy sticky if you need more information. It's all been posted basically.
pro4never is offline  
Thanks
1 User
Old 10/16/2010, 22:33   #3
 
tkblackbelt's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 266
Received Thanks: 85
Ok so if I'm understanding you correctly every time I get incoming byte I have to reverse it and not add bytes together but have the bytes go one after another, then I have to structure and decrypt the array of bytes.

Actually I'm struggling with the encryption in java. So I think I'm going to learn c# since you were saying theres lots info and sources about proxies, Thanks for your help though pro4never.

Sweet I just started c# and its almost exactly like java. I've already made a tic tac toe game xD
tkblackbelt is offline  
Old 10/17/2010, 05:05   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
C# and Java are VERY similar.

And you... sort of place them in order. It's not quite that simple.

Convert your bytes to hex and it will make more sense than as dec. Something like this..

String Output = "";
for(int I = 0; I < Data.Length; I++)
Output += Convert.ToString(Data[I], 16) + " " ;
Console.WriteLine("Packet dump for type: " + BitConverter.ToUInt16(Data, 2) + " \n" + Output);

That will give you a hex dump of your packet including the packet type (assuming it's already decrypted!)



If you look at the proxy sticky I link to a VERY good explanation of packet structuring. Basically you 'chunk' things together. This is done through logic and trial and error mostly. I go into it a little in that thread but basically each packet has various values you are looking for. These include but are not limited to...

Packet Length (always there, always first 2 bytes. USHORT)
Packet type (always there, always second 2 bytes. USHORT)
Character UID UINT
Target UID UINT
X/Y/Map USHORT
TimeStamp UINT
String (usually contains a length byte preceding it. EG names have a byte listing length of string to read)

There are other things you may want to 'chunk' out of packets but that's the main stuff. Just look at the hex and what you are doing. That + wiki makes things easy to figure out. Once you know your UID in one packet you can block it off in ANY other packet based on that character (easy removal of 4 unknown bytes). Same with target uid, target a mob and if the value you are reading is between 300-500k you know it's a mob uid. etc
pro4never is offline  
Old 10/17/2010, 05:26   #5
 
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
Quote:
Originally Posted by pro4never View Post
First of all I don't know java syntax but it looks like you're combining the entire values for the packet and printing them out...

#1 It's a byte array which then needs to be structured and read using REVERSED BYTE ORDER

Eg

uint with value of 1 is

1 0 0 0

IIRC java's default 'readers' for that type of stuff (binary reader for files did it) where it wouldn't reverse the order so you get funky values. You need java's equivalent of a bitconverter. You will also need to think of an efficient method for writing packets. Something like writeuint32(value, offset, destination); is what I use... one of impulse's methods (and others use it) but anything will work really.

Also keep in mind you will need to decrypt the incoming information using AuthEncryption (it's posted in every source ever and is incredibly simple) and Blowfish for the game server.

Check out the proxy sticky if you need more information. It's all been posted basically.
Endianness - Wikipedia, the free encyclopedia


To OP: add me on MSN, I'll PM you
_tao4229_ is offline  
Old 10/17/2010, 05:45   #6
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
My bad saint. I've never done anything in Java and when Noah was attempting to read values using it we were having some issues where the reader he was using was not reversing the bytes. I was positive that there were functions built in to java to complete this... I just know that when he was writing the code to read dmaps it was pulling funky values when he used the default binary reader wheras when he read a single byte it read correctly (the only obvious explanation I could think of at the time was endianness)
pro4never is offline  
Old 10/17/2010, 18:33   #7
 
tkblackbelt's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 266
Received Thanks: 85
Ok I rewrote the proxy in c# and got the encryption and decryption working for Auth. but when I get the password seed. and relay it to the client and get back the response I get the same packet as I sent not the response with the acc pass and etc.

Code:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace LightProxy
{
    class Program
    {
        static void Main(string[] args)
        {

            IPAddress ip;
            TcpListener ClientListner;
            TcpClient ClientSocket;
            Socket ProxyToServerSocket;
            AuthProtocolCryptographer cryptor;
            byte[] buffer = new byte[255];
            Program proxy = new Program();

            ProxyToServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            ip = IPAddress.Parse("192.168.1.100");
            ClientListner = new TcpListener(ip, 9959);

            ClientListner.Start();
            Console.WriteLine("Server Started");

            ClientSocket = ClientListner.AcceptTcpClient();
            Console.WriteLine("Server: Client Connected");

            try
            {
                ProxyToServerSocket.Connect("208.96.34.46", 9959);
                Console.WriteLine("Auth: Client Connected to Auth");
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not connect to Auth server");
            }
            cryptor = new AuthProtocolCryptographer();

            ProxyToServerSocket.Receive(buffer);
            
            cryptor.Decrypt(buffer);
            cryptor.Encrypt(buffer);
            proxy.DumpHex(buffer);

            ClientSocket.Client.Send(buffer);
            ProxyToServerSocket.Send(buffer);
            proxy.DumpHex(buffer);

            
        }
tkblackbelt is offline  
Old 10/19/2010, 08:07   #8
 
elite*gold: 0
Join Date: Jan 2007
Posts: 118
Received Thanks: 20
Quote:
Originally Posted by tkblackbelt View Post
Ok I rewrote the proxy in c# and got the encryption and decryption working for Auth. but when I get the password seed. and relay it to the client and get back the response I get the same packet as I sent not the response with the acc pass and etc.

Code:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace LightProxy
{
    class Program
    {
        static void Main(string[] args)
        {

            IPAddress ip;
            TcpListener ClientListner;
            TcpClient ClientSocket;
            Socket ProxyToServerSocket;
            AuthProtocolCryptographer cryptor;
            byte[] buffer = new byte[255];
            Program proxy = new Program();

            ProxyToServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            ip = IPAddress.Parse("192.168.1.100");
            ClientListner = new TcpListener(ip, 9959);

            ClientListner.Start();
            Console.WriteLine("Server Started");

            ClientSocket = ClientListner.AcceptTcpClient();
            Console.WriteLine("Server: Client Connected");

            try
            {
                ProxyToServerSocket.Connect("208.96.34.46", 9959);
                Console.WriteLine("Auth: Client Connected to Auth");
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not connect to Auth server");
            }
            cryptor = new AuthProtocolCryptographer();

            ProxyToServerSocket.Receive(buffer);
            
            cryptor.Decrypt(buffer);
            cryptor.Encrypt(buffer);
            proxy.DumpHex(buffer);

            ClientSocket.Client.Send(buffer);
            ProxyToServerSocket.Send(buffer);
            proxy.DumpHex(buffer);

            
        }
You're code is so confusing and it is not the right way to set up your proper proxy. You need to study further on how to create a client server application for the first place.

The process inside the proxy such as encryption and decryption will be done on the receive event of the packets coming from either conquer client or TQ authentication and game server.
xmen01235 is offline  
Old 10/19/2010, 16:02   #9
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
Your problem is you haven't actually setup any sort of receive functions.

I don't know about Java but in C# you have to either make a thread to block off looking for connections which then on successful connection spawns a new thread to listen for data (sync sockets... not a great option) or an event based socket system which on receive/on connect performs some sort of action (async sockets)

Also as stated before, crypt will be stored PER CLIENT. Auth encryption uses a counter meaning you MUST encrypt/decrypt each packet that goes through or else it will lose 'sync' and stop working
pro4never is offline  
Old 10/19/2010, 16:24   #10
 
elite*gold: 0
Join Date: Jan 2007
Posts: 656
Received Thanks: 541
Why are you messing with the password seed unless you are trying to create a standalone bot?
Just let the client do it for you, if it's a proxy you are after.
Trigorio is offline  
Old 10/19/2010, 17:13   #11
 
tkblackbelt's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 266
Received Thanks: 85
Thanks for helping me bu ya I think I'll study c# for a while before I go any further with this.
tkblackbelt is offline  
Old 10/19/2010, 17:41   #12
 
elite*gold: 0
Join Date: Jan 2007
Posts: 118
Received Thanks: 20
Quote:
Originally Posted by tkblackbelt View Post
Thanks for helping me bu ya I think I'll study c# for a while before I go any further with this.
Don't give up too early you can study my own socket wrapper for your reference

xmen01235 is offline  
Thanks
1 User
Old 10/19/2010, 18:39   #13
 
tkblackbelt's Avatar
 
elite*gold: 0
Join Date: Sep 2010
Posts: 266
Received Thanks: 85
Sweet I'll have a look at but I was programming in java for a about 4-5 months, and decided to try c# so I only have about a week of experience with it (although the syntax is very similar to java so I'm learning quit quickly) so I'm gonna finish reading my c# book and take a few C# networking tuts and then get back to my proxy, and I will complete it. Also would you recommend reading a book on cryptography to help understanding encrypting and decrypting packets?
tkblackbelt is offline  
Old 10/20/2010, 02:49   #14
 
elite*gold: 0
Join Date: Jan 2007
Posts: 118
Received Thanks: 20
Quote:
Originally Posted by tkblackbelt View Post
Sweet I'll have a look at but I was programming in java for a about 4-5 months, and decided to try c# so I only have about a week of experience with it (although the syntax is very similar to java so I'm learning quit quickly) so I'm gonna finish reading my c# book and take a few C# networking tuts and then get back to my proxy, and I will complete it. Also would you recommend reading a book on cryptography to help understanding encrypting and decrypting packets?
As for my socket class I am using vb dot net on it but it is easy for you to convert it into c# if you really want. And about the crypthography I also learn those stuff from epvp and codexplosion, I really not that very proficient on those fields but the you can study the 2 specific crypthography that conquer has been using. I have my own wrapper for both crypthograhpy also but I want you to learn it by yourself. The first one for authentication is not that hard and it is like an XOR method only but the second one for game server is a bit tricky and you need to study blowfish and DH key exchange. If you reach at this point you should study the best method of defeating this crypthography which is know as man in the middle attack.
xmen01235 is offline  
Old 10/20/2010, 04:29   #15
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376


Has some links to info on encryption. I generally just use public encryption methods for both as they 'work' perfectly fine in C#.

If you want to write your own though there is a bunch of info on the dhkey/man in the middle attack and also a nice bit of example code for blowfish on korv's wiki. All this is already linked in the proxy thread though.




Diffie?Hellman key exchange - Wikipedia, the free encyclopedia
Man-in-the-middle attack - Wikipedia, the free encyclopedia

Also points for you for actually being willing to put work into LEARNING. I'm shocked. 99 pct of the posts around here has been "omg how do I make proxy?!?" and then as soon as they run into an obstacle they give up and ask for a working one to use/leach/etc.
pro4never is offline  
Reply


Similar Threads Similar Threads
[Source Code] Zum Verständnis (Proxy DLL).
10/23/2011 - Kal Hacks, Bots, Cheats & Exploits - 16 Replies
Hallo, "liebe" Community. Irgendwann - ganz sicher - kommt ihr auf die Idee, eine "vereinfachte" Art zu benutzen. Damit will ich sagen, dass euch vielleicht irgendwann (zum Beispiel) die __asm-Codes auf den Sack gehen. Zumindest war's bei mir so. Ich weiß, dass es schwer ist, an ordentliches Material zu kommen. Und wenn man daran denkt, dass es ordentliches Material gibt, dann wüsste man gern', woher man das bekommt. Naja, ich hab' für euch einen Source Code - zum Verständnis. Ich...
Release: KalOnline PacketHack (Proxy-DLL) Source Code.
01/06/2011 - Kal Hacks, Bots, Cheats & Exploits - 29 Replies
Aloah, Community. Bevor ich jetzt einiges schreiben werde, ist folgendes notwendig. Ich habe die Funktion "SearchPattern()" von BakaBug benutzt. Ebenso das Code-Snippet (memcpy(...)) von BakaBug's Source Code. Deshalb gelten - wenn, dann - Credits an/für/zu BakaBug. Mir egal, was ihr damit macht. Momentan funktioniert diese Proxy-DLL. Zumindest mit dem, womit diese "ausgestattet" ist. Anmerkungen: - Nein, es ist kein Bot.
[Request]Some one who can code a Bot//Proxy[Will be payed]
05/26/2010 - CO2 Programming - 8 Replies
I have joined CoGenius. Please close this thread.
Source Code for CID Proxy!
04/02/2009 - Conquer Online 2 - 7 Replies
I won't say where I got this, but here is the source.
proxy source code
08/09/2007 - Conquer Online 2 - 4 Replies
Im trying to find a source code for proxy which i can edit to make a nado bot. can anyone give me a link? i already searched here but got nothing. help is much appreciated. <hr>Append on Aug 8 2007, 14:21<hr> bump!



All times are GMT +2. The time now is 09:45.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

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