New monster.dat from Co2 client.

11/02/2005 01:15 unknownone#1
Ok, just a short guide on decrypting the new monster.dat distributed with the Conquer2.0 upgrade. I figure some of you might need to decrypt it to change monster sizes like we've done in the past.
This is only the decryption, so it'll need reversing to be able to make edits, any volunteers?

I'm not very good at explaining this kinda thing, but heres goes.

---

We have 3 counters.
CounterA, CounterB, CounterC

CounterA starts at zero, and it a pointer to the next byte you access from Monster.Dat
CounterB = CounterA Modulus 128. Counter B points to the next byte in the decryption key. (below)
CounterC = CounterA Modulus 8, is used for bitwise shift, explained below.

Decryption Key
Code:
AD 6B 4F FB DD B8 0E 09 13 33 8F F5 43 09 15 88
5D 80 A3 45 2D 42 08 56 80 F8 19 C5 88 1B 3E EF
81 07 30 36 95 52 00 F7 FD 5B 5C BC 6A 26 0E B2
A3 67 C5 5D 6F DC 18 8A B5 E0 C8 85 E2 3E 45 8D
8B 43 74 85 54 17 B0 EC 10 4D 0F 0F 29 B8 E6 7D
42 80 8F BC 1C 76 69 3A B6 A5 21 86 B9 29 30 C0
12 45 A5 4F E1 AF 25 D1 92 2E 30 58 49 67 A5 D3
84 F4 89 CA FC B7 04 4F CC 6E AC 31 D4 87 07 72
Monster.Dat (beginning)
Code:
F6 E5 9A B0 1B 34 9E BB 72 D5 5E 1F 93 48 C1 3C
27 4A A6 66 6B E5 44 D0 8A 4C A4 BE 5E 11 67 D6
E2 CD 89 95 46 74 0C EF F0 4F 69 B7 ED AF 54 81
C6 1D 1D F4 3C BA 55 0C BF 78 5D 36 B4 B3 0A 15
86 57 7D FE 73 DA E0 5D 64 9F B2 7C FA DE AA E7
4F 94 86 C7 3B BB 38 09 D0 6F AC 25 6A 80 A0 69
66 87 1C 6C F7 E1 3C 57 98 AA 8D CB AF 0D 7E 69
EA 3C 7D B9 0A 7A 5D C9 C6 EC 21 92 F1 2B DB 62...
Ok, so each increment of Counter A, you increase Counters B and C.

-Get byte from location CounterA from Monster.dat (ByteA)
-Get byte from location CounterB from the decryption key (ByteB).
-XOR ByteA, ByteB
-Let ByteC = ByteA
-Bitwise Shift Left ByteA by (8 - CounterC)
-Bitwise Shift Right ByteC by CounterC
-Result = ByteA + ByteC

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")
The decrypted file is a structured test file, much like the old monster.ini file, except it contains quite a few more variables.

Code:
[MonsterName]
SizeAdd=%d
ZoomPercent=%d
MaxLife=%d
Level=%d
BornAction=%d
BornEffect=%s
BornSound=%s
ActResCtrl=%d
ASB=%d
ADB=%d"
BodyType=%d
TypeID=%d
AntiType=%d
I'm getting a few invalid characters in my decrypted file, but I think thats just an incorrect byte in the decryption key I need to re-check, Maybe tomorrow.
11/02/2005 04:08 unknownone#2
Bump, re-posted
11/02/2005 04:24 unknownone#3
Reversed file...
11/02/2005 12:32 mind...#4
I think this is worth a karma, nice finding out how it works...
11/02/2005 13:17 Hojo#5
Damn, beat me :P

My and unknown were at it last night...

Im not good at reversing things like this :eek:

Good job

+1 karma

#Pinned, Moved
11/02/2005 13:54 Peach#6
no new monster.dat editor?
11/02/2005 16:08 Hojo#7
#Moved back :P
11/02/2005 19:05 thedevil666#8
this guy has been such a great help to this community that he deserves to be a mod


+karma
11/07/2005 19:53 sniper__freak#9
hmm wonder if this will be the same decrytion method for itemtype.dat i need only the command tokens renamed :D
11/07/2005 22:20 unknownone#10
itemtype.dat is not encrypted.
11/15/2005 14:12 pipi#11
oh no !!!
i dun know what is all this ? =x
i m so noob!!
hw i make a metdove big in CO2
thx!! ^^V
11/15/2005 16:46 flowerpot#12
Just use MrTeenie's co2 monster.dat:
[Only registered and activated users can see links. Click Here To Register...]
11/22/2005 04:42 pwnage#13
Made a PHP version for fun and stuff, for those of you who wanted something similar to C/C++ syntax.
Code:
<?php
function decryptChar($char,$num) {
	$decrypt = array(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);
	$CounterA = $num;
	$CounterB = $CounterA % 128;
	$CounterC = $CounterA % 8;
	
	$ByteA = ord($char);
	$ByteB = $decrypt[$CounterB];
	$ByteA = $ByteA ^ $ByteB;
	$ByteC = $ByteA;
	$ByteA = 255 & ($ByteA << (8 - $CounterC));
	$ByteC = 255 & ($ByteC >> $CounterC);
	return chr($ByteA + $ByteC);
}
function decrypt($file = '') {
 echo 'File Length: '.strlen($file)."<br />";
	$result = '';
	for ($i = 0; $i < strlen($file); $i++) {
 $result .= decryptChar($file[$i],$i);
	}
	echo 'File end: '.$i."<br /><br />";
	return $result;
}

$filename = './Monster.dat';
$handle = fopen($filename, "rb");
$contents = fread($handle, filesize($filename));
fclose($handle);

echo '<html><body>';
echo str_replace("\n",'<br />', decrypt($contents));
echo '</body></html>';
?>
12/09/2005 07:17 Nitrometano#14
is it able to decrypt/encrypt back with new data?
12/09/2005 07:18 Nitrometano#15
great job unknowone and pwage