[C# Source/App] DatCryptor

04/16/2008 07:25 high6#31
Quote:
Originally Posted by shitboi View Post
Took me quite a while to put chocoman's source into use.

Ummmm, how to use the key for lv.dat? Does level.dat have the same de/encrytion routine as itemtype.dat

If possible teach me the process of decrypting itemtype.dat. Eg, finding keys and de/encrytion process
chocoman's source?

Just replace the byte arrays. Yes

[Only registered and activated users can see links. Click Here To Register...]
04/18/2008 14:38 warriorchamp#32
Quote:
Originally Posted by high6 View Post
There might be a problem with your .net framework.

Also are you 32 bit or 64 bit?
Im at 32 bit. I dont know why isn't working:( This is the first application which doesn't work on my computer... :| :(
04/18/2008 17:11 shitboi#33
Quote:
Originally Posted by high6 View Post
chocoman's source?

Just replace the byte arrays. Yes

[Only registered and activated users can see links. Click Here To Register...]
In coder62's itemtype DeEn thread, first page, Chocoman4k released his version of the de/en routine in C++. That was the one i made use of.

Code:
example: 

CounterA = 7
CounterB = CounterA Mod 128 //=0x7
CounterC = CounterA Mod 8 //=0x7
ByteA = 0xBB
ByteB = 0x09
xor ByteA, ByteB // 0xBB xor 0x0E = 0xB2
ByteC = ByteA  // =0xB2
shl ByteA, (8 - CounterC) // ByteA = 0x64
shr ByteC, CounterC //ByteC = 0x1
result = ByteA + ByteC // 0x64 + 0x1 = 0x65 (101 = "e")
i don't quite get what does 0x7 mean. I fact, what is the exact meaning of "0x" does it convert from hex to dec or what?
04/18/2008 18:55 shitboi#34
Quote:
Originally Posted by warriorchamp View Post
Im at 32 bit. I dont know why isn't working:( This is the first application which doesn't work on my computer... :| :(
Well, you can use the tool i made.

Extract the pure_itemtypeEnDe.exe into your ..Conquer2.0/ini folder and run.
The menu is easy to understand, just follow instructions.
04/27/2008 11:33 Sissi#35
Hi guys, i tryed to include the encrypt and decrypt functions into my own project, which should check automatically, if the itemtype.dat was updated by conquer and then decrypt, replace some strings in it and write back encrypted into itemtype.dat.

Here is my code:

/*
* Erstellt mit SharpDevelop.
* Datum: 27.04.2008
* Zeit: 10:57
*
* Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
*/

using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace CO4US
{
/// <summary>
/// Description of Form1.
/// </summary>
public partial class frmSpecial : Form
{
public frmSpecial()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();

//
// TODO: Add constructor code after the InitializeComponent() call.
//
}

void CmdBackClick(object sender, EventArgs e)
{
this.Hide();
}

void CmdItemTypeClick(object sender, EventArgs e)
{
byte[] bytes;
bytes = HoleDaten("ItemType");
Decrypt(ref bytes);
}

byte[] HoleDaten(string Datei)
{
if (Datei == "ItemType" || Datei == "Monster")
{
Datei = "ini" + Path.DirectorySeparatorChar + Datei + ".dat";
}
if (Datei == "MapItemIcon")
{
Datei +=".ani";
}
string Pfad = System.IO.Directory.GetCurrentDirectory();
Pfad = Directory.GetParent(Pfad).ToString();
Pfad = @"C:\Programme\Conquer 2.0";
string DateiPfad = Pfad + Path.DirectorySeparatorChar + Datei;
MessageBox.Show(DateiPfad);
byte[] bytes = File.ReadAllBytes(DateiPfad);
return bytes;
}

static byte[] key = {
0xAD ,0x6B ,0x4F ,0xFB ,0xDD ,0xB8 ,0x0E ,0x09 ,0x13 ,0x33 ,0x8F ,0xF5 ,0x43 ,0x09 ,0x15 ,0x88 ,0x5D ,0x80 ,0xA3 ,0x45 ,0x2D ,0x42 ,0x08 ,0x56 ,0x80 ,0xF8 ,0x19 ,0xC5 ,0x88 ,0x1B ,0x3E ,0xEF
,0x81 ,0x07 ,0x30 ,0x36 ,0x95 ,0x52 ,0x00 ,0xF7 ,0xFD ,0x5B ,0x5C ,0xBC ,0x6A ,0x26 ,0x0E ,0xB2 ,0xA3 ,0x67 ,0xC5 ,0x5D ,0x6F ,0xDC ,0x18 ,0x8A ,0xB5 ,0xE0 ,0xC8 ,0x85 ,0xE2 ,0x3E ,0x45 ,0x8D
,0x8B ,0x43 ,0x74 ,0x85 ,0x54 ,0x17 ,0xB0 ,0xEC ,0x10 ,0x4D ,0x0F ,0x0F ,0x29 ,0xB8 ,0xE6 ,0x7D ,0x42 ,0x80 ,0x8F ,0xBC ,0x1C ,0x76 ,0x69 ,0x3A ,0xB6 ,0xA5 ,0x21 ,0x86 ,0xB9 ,0x29 ,0x30 ,0xC0
,0x12 ,0x45 ,0xA5 ,0x4F ,0xE1 ,0xAF ,0x25 ,0xD1 ,0x92 ,0x2E ,0x30 ,0x58 ,0x49 ,0x67 ,0xA5 ,0xD3 ,0x84 ,0xF4 ,0x89 ,0xCA ,0xFC ,0xB7 ,0x04 ,0x4F ,0xCC ,0x6E ,0xAC ,0x31 ,0xD4 ,0x87 ,0x07 ,0x72};

static void Decrypt(ref byte[] bytes)
{
if (bytes.Length < 0)
return;
int i = 1;
byte t1 = 0;
int t2;
while (i < bytes.Length)
{
MessageBox.Show(bytes[i].ToString());
t1 = (byte)(bytes[i] ^ key[(byte)i % 0x80]);
t2 = i % 0x8;
bytes[i] = (byte)((t1 << (0x8 - t2)) + (t1 >> t2));
i++;
}
}

static void Encrypt(ref byte[] bytes)
{
if (bytes.Length < 0)
return;
int i = 1;
byte t1 = 0;
int t2;
while (i < bytes.Length)
{
t2 = i % 0x8;
t1 = (byte)((bytes[i] >> (0x8 - t2)) + (bytes[i] << t2));
bytes[i] = (byte)(t1 ^ key[(byte)i % 0x80]);
i++;
}
}
}
}

Everytime i try to run it, it says "overflow" and i found out it stops at the function decrypt at bytes[i] = (byte)((t1 << (0x8 - t2)) + (t1 >> t2));
I worked the original programm through and the variables at the first time are have the same worth like they are in my program, but in my program is an overflow. I hope you can help me.

Mfg Sissi.
04/28/2008 03:42 high6#36
Quote:
Originally Posted by Sissi View Post
Hi guys, i tryed to include the encrypt and decrypt functions into my own project, which should check automatically, if the itemtype.dat was updated by conquer and then decrypt, replace some strings in it and write back encrypted into itemtype.dat.

Here is my code:

/*
* Erstellt mit SharpDevelop.
* Datum: 27.04.2008
* Zeit: 10:57
*
* Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
*/

using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;

namespace CO4US
{
/// <summary>
/// Description of Form1.
/// </summary>
public partial class frmSpecial : Form
{
public frmSpecial()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();

//
// TODO: Add constructor code after the InitializeComponent() call.
//
}

void CmdBackClick(object sender, EventArgs e)
{
this.Hide();
}

void CmdItemTypeClick(object sender, EventArgs e)
{
byte[] bytes;
bytes = HoleDaten("ItemType");
Decrypt(ref bytes);
}

byte[] HoleDaten(string Datei)
{
if (Datei == "ItemType" || Datei == "Monster")
{
Datei = "ini" + Path.DirectorySeparatorChar + Datei + ".dat";
}
if (Datei == "MapItemIcon")
{
Datei +=".ani";
}
string Pfad = System.IO.Directory.GetCurrentDirectory();
Pfad = Directory.GetParent(Pfad).ToString();
Pfad = @"C:ProgrammeConquer 2.0";
string DateiPfad = Pfad + Path.DirectorySeparatorChar + Datei;
MessageBox.Show(DateiPfad);
byte[] bytes = File.ReadAllBytes(DateiPfad);
return bytes;
}

static byte[] key = {
0xAD ,0x6B ,0x4F ,0xFB ,0xDD ,0xB8 ,0x0E ,0x09 ,0x13 ,0x33 ,0x8F ,0xF5 ,0x43 ,0x09 ,0x15 ,0x88 ,0x5D ,0x80 ,0xA3 ,0x45 ,0x2D ,0x42 ,0x08 ,0x56 ,0x80 ,0xF8 ,0x19 ,0xC5 ,0x88 ,0x1B ,0x3E ,0xEF
,0x81 ,0x07 ,0x30 ,0x36 ,0x95 ,0x52 ,0x00 ,0xF7 ,0xFD ,0x5B ,0x5C ,0xBC ,0x6A ,0x26 ,0x0E ,0xB2 ,0xA3 ,0x67 ,0xC5 ,0x5D ,0x6F ,0xDC ,0x18 ,0x8A ,0xB5 ,0xE0 ,0xC8 ,0x85 ,0xE2 ,0x3E ,0x45 ,0x8D
,0x8B ,0x43 ,0x74 ,0x85 ,0x54 ,0x17 ,0xB0 ,0xEC ,0x10 ,0x4D ,0x0F ,0x0F ,0x29 ,0xB8 ,0xE6 ,0x7D ,0x42 ,0x80 ,0x8F ,0xBC ,0x1C ,0x76 ,0x69 ,0x3A ,0xB6 ,0xA5 ,0x21 ,0x86 ,0xB9 ,0x29 ,0x30 ,0xC0
,0x12 ,0x45 ,0xA5 ,0x4F ,0xE1 ,0xAF ,0x25 ,0xD1 ,0x92 ,0x2E ,0x30 ,0x58 ,0x49 ,0x67 ,0xA5 ,0xD3 ,0x84 ,0xF4 ,0x89 ,0xCA ,0xFC ,0xB7 ,0x04 ,0x4F ,0xCC ,0x6E ,0xAC ,0x31 ,0xD4 ,0x87 ,0x07 ,0x72};

static void Decrypt(ref byte[] bytes)
{
if (bytes.Length < 0)
return;
int i = 1;
byte t1 = 0;
int t2;
while (i < bytes.Length)
{
MessageBox.Show(bytes[i].ToString());
t1 = (byte)(bytes[i] ^ key[(byte)i % 0x80]);
t2 = i % 0x8;
bytes[i] = (byte)((t1 << (0x8 - t2)) + (t1 >> t2));
i++;
}
}

static void Encrypt(ref byte[] bytes)
{
if (bytes.Length < 0)
return;
int i = 1;
byte t1 = 0;
int t2;
while (i < bytes.Length)
{
t2 = i % 0x8;
t1 = (byte)((bytes[i] >> (0x8 - t2)) + (bytes[i] << t2));
bytes[i] = (byte)(t1 ^ key[(byte)i % 0x80]);
i++;
}
}
}
}

Everytime i try to run it, it says "overflow" and i found out it stops at the function decrypt at bytes[i] = (byte)((t1 << (0x8 - t2)) + (t1 >> t2));
I worked the original programm through and the variables at the first time are have the same worth like they are in my program, but in my program is an overflow. I hope you can help me.

Mfg Sissi.
What is "i"'s value on overflow? And how big is the array?
04/28/2008 04:19 Hiyoal#37
How do you find the initial key in the first place?? What are the steps to go through. Could you please enlighten me on this Topic High...This one time.

Hiyoal :o
04/29/2008 08:37 Sissi#38
i is the counter from 0 to end of the array and the array is the whole file, like in your code. Strange is in your prog, when i compile, it works, but not at mine. But it seems that my software (sharpdevelop) is the problem - its freeware and if others do the same with my code it works.
Seems i need to borrow me that software fom them, thx anywhere
07/08/2008 21:08 Dgen#39
Why doesn't this program work for me? It shows and error when i want to start it.



EDiT: I fixed it :D.
07/24/2008 23:51 Guerilla#40
Thank you very much. :)
08/04/2008 14:29 torbido#41
good ty
08/05/2008 16:51 Hassan28#42
nice ty
12/02/2008 02:58 elragal_30#43
alot thanks i was search for it while ago
thanks for @nTL3fTy for guide me
and can i use this code for all dat files?? or just co ??
12/02/2008 04:38 nTL3fTy#44
Quote:
Originally Posted by elragal_30 View Post
alot thanks i was search for it while ago
thanks for @nTL3fTy for guide me
and can i use this code for all dat files?? or just co ??
Just encrypted CO2 ones, because there are some CO2 .dat files that are not encrypted (such as MagicType (as of v5017)).
01/23/2009 16:56 Deriaz#45
Thanks alot for this, it both helped me getting monsters smaller and learned me how to encrypt/decrypt easily, thanks a lot! :)