Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 01:34

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

Advertisement



5017 Game Cryptography

Discussion on 5017 Game Cryptography within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
Super Aids's Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
5017 Game Cryptography

I seem to have an issue with my cryptography and I simply can't spot it. Been double checking and tried different implementations from different sources, but it just doesn't do it right.
Code:
module game.crypto.gamecrypto;

import network.packet;
private class CryptoData : DataPacket {
	this() {
		super();
	}
}


private class CryptoCounter {
	ushort m_counter = 0;
	@property {
		ubyte key1() {
			return cast(ubyte)(m_counter & 0xFF);
		}
		
		ubyte key2() {
			return cast(ubyte)(m_counter >> 8);
		}
	}
	
	void increment() {
		m_counter++;
	}
	
	void reset() {
		m_counter = 0;
	}
}
class GameCrypto {
private:
	enum keySize = 256;
	CryptoCounter m_encryptCounter, m_decryptCounter;
    ubyte[] crypt1;
	ubyte[] crypt2;
	ubyte[] crypt3;
	ubyte[] crypt4;
    bool m_alternate;
public:
	this() {
		m_alternate = false;
		
		m_encryptCounter = new CryptoCounter;
        m_decryptCounter = new CryptoCounter;

		crypt1 = new ubyte[256];
        crypt2 = new ubyte[256];
        ubyte i_key1 = 157;
        ubyte i_key2 = 98;
        foreach (i; 0 .. 256)
        {
            crypt1[i] = i_key1;
            crypt2[i] = i_key2;
            i_key1 = cast(ubyte)((0xF + cast(ubyte)(i_key1 * 0xFA)) * i_key1 + 0x13);
            i_key2 = cast(ubyte)((0x79 - cast(ubyte)(i_key2 * 0x5C)) * i_key2 + 0x6D);
        }
	}
	
	ubyte[] encrypt(ubyte[] inBuffer) {
		synchronized {
			ubyte[] buffer = inBuffer.dup;
			foreach (i; 0 .. buffer.length) {
				buffer[i] ^= 0xAB;
				buffer[i] = cast(ubyte)(buffer[i] >> 4 | buffer[i] << 4);
				buffer[i] ^= cast(ubyte)(crypt1[m_encryptCounter.key1] ^ crypt2[m_encryptCounter.key2]);
				m_encryptCounter.increment();
			}
			return buffer;
		}
	}
	
	ubyte[] decrypt(ubyte[] inBuffer) {
		synchronized {
			ubyte[] buffer = inBuffer.dup;
			if (!m_alternate) {
				foreach (i; 0 .. buffer.length) {
					buffer[i] ^= 0xAB;
					buffer[i] = cast(ubyte)(buffer[i] >> 4 | buffer[i] << 4);
					buffer[i] ^= cast(ubyte)(crypt2[m_decryptCounter.key2] ^ crypt1[m_decryptCounter.key1]);
					m_decryptCounter.increment();
				}
			}
			else {
				foreach (i; 0 .. buffer.length) {
					buffer[i] ^= 0xAB;
					buffer[i] = cast(ubyte)(buffer[i] >> 4 | buffer[i] << 4);
					buffer[i] ^= cast(ubyte)(crypt4[m_decryptCounter.key2] ^ crypt3[m_decryptCounter.key1]);
					m_decryptCounter.increment();
				}
			}
			return buffer;
		}
	}
	
	void setKeys(uint accountId, uint token)
    {
        synchronized {
			uint tmpkey1 = cast(uint)((((token) + accountId) ^ 0x4321) ^ (token));
			uint tmpkey2 = cast(uint)(tmpkey1 * tmpkey1);
			crypt3 = new ubyte[0x100];
			crypt4 = new ubyte[0x100];
		
			auto temp = new CryptoData;
			temp.write!uint(tmpkey1);
			ubyte[] tmp1 = temp.pBuffer;
		
			temp = new CryptoData;
			temp.write!uint(tmpkey2);
			ubyte[] tmp2 = temp.pBuffer;
		
			foreach (i; 0 .. 256)
			{
				crypt3[i] = cast(ubyte)(crypt1[i] ^ tmp1[i % 4]);
				crypt4[i] = cast(ubyte)(crypt2[i] ^ tmp2[i % 4]);
			}
			m_alternate = true;
		}
    }
}
#Edit
I don't know what the hell I did, but it works now.
Super Aids is offline  
Thanks
1 User
Reply

« weapons | Host »

Similar Threads Similar Threads
Cryptography and Custom Updater/Game
08/30/2014 - Shaiya PServer Guides & Releases - 18 Replies
Part 1 - Cryptography: you should ask, I do a Shaiya and people copy it effortlessly, and still catch my ip in game.exe? Yup! That's why I decided to make this post to show you how to encrypt your game.exe and his Updater.exe to avoid this, so your IP and your files Shaiya will be Safe. OK, Let's GO! 1 - First you will need this program below; Themida.V2.1.8.0 2 - Open program and let's go; first click on Protection Options and disable the options of compression *Application, Resources...
Game Cryptography ??
09/22/2012 - CO2 Programming - 0 Replies
Hello :) coders my project (Proxy bot) i need help to Update The encryption auth crypto is working but the problem in game crypto i tried 2 proxy's encryption and it stuck when logging in game server help ? currently proxy is works 100% but doesnt give the right packets thanks. edit : im not sure maybe the auth encryption are also does not decrypt correctly
[Release]5017 Password Cryptography
06/22/2011 - CO2 PServer Guides & Releases - 10 Replies
-5017+ Will work with Lower Versions but not all Will work with Higher versions but not all Create a new .cs file if you wish and paste this class:



All times are GMT +1. The time now is 01:35.


Powered by vBulletin®
Copyright ©2000 - 2026, 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 ©2026 elitepvpers All Rights Reserved.