• Welcome to Valhalla Legends Archive.
 

Compute war3x map crc32 values

Started by tinman, September 12, 2007, 04:14 AM

Previous topic - Next topic

tinman

Anyone know how?
i tried throwing every bytes of the map file into the crc32 function and end up with different crc32 value when compared with the packets log.  ???
i suppose i should start reading from a specified offset?

UserLoser

Quote from: tinman on September 12, 2007, 04:14 AM
Anyone know how?
i tried throwing every bytes of the map file into the crc32 function and end up with different crc32 value when compared with the packets log.  ???
i suppose i should start reading from a specified offset?

Try all the data after the map header block

tinman

is the header = first 512 byte?

i cant seems to get the correct crc32 checksum :/

Don Cullen

#3
Quote from: tinman on September 13, 2007, 07:15 AM
is the header = first 512 byte?

i cant seems to get the correct crc32 checksum :/

While I'm out of my depth here, I have an idea you could try, use it or ignore it as the babbling of someone who doesn't know what he's talking about. Your choice. :)

Couldn't you basically save the correct crc32 checksum to a variable, then basically brute force the map? Basically, write a program that starts with the first byte reading until the last byte, and calculates the crc32 checksum, compares it to the correct one, if it's not the same, it moves on to the second byte, then the third, until it has reached the last byte. Chances are, if UserLoser is right, that you just need to read everything after the header, the program will eventually reach the end of the header, and it'll score a match, and it can then display a message telling you exactly where the end of the header is.
Regards,
Don
-------

Don't wonder why people suddenly are hostile when you treat them the way they shouldn't be- it's called 'Mutual Respect'.

tinman

Quote from: Don Cullen on September 13, 2007, 01:42 PM
Quote from: tinman on September 13, 2007, 07:15 AM
is the header = first 512 byte?

i cant seems to get the correct crc32 checksum :/

While I'm out of my depth here, I have an idea you could try, use it or ignore it as the babbling of someone who doesn't know what he's talking about. Your choice. :)

Couldn't you basically save the correct crc32 checksum to a variable, then basically brute force the map? Basically, write a program that starts with the first byte reading until the last byte, and calculates the crc32 checksum, compares it to the correct one, if it's not the same, it moves on to the second byte, then the third, until it has reached the last byte. Chances are, if UserLoser is right, that you just need to read everything after the header, the program will eventually reach the end of the header, and it'll score a match, and it can then display a message telling you exactly where the end of the header is.

I did written a script to do the job...  it is now at offset 2074. still no luck :<

UserLoser

Post your CRC32 function, maybe you're doing something wrong there?

tinman

i'm using the php crc32 since my script is written in php.


<?PHP
set_time_limit(0);
//return the filesize in big endian format
    function getMapSize($mappath)
    {
    $filesize = filesize($mappath);
    $part1 = ($filesize     ) & 0xFF;
    $part2 = ($filesize >> 8) & 0xFF;
    return chr($part1).chr($part2);
    }
       
    $mappath = 'treetag.w3x';
    $BE_filesize = getMapSize($mappath);
    echo 'Map filezie:' . filesize($mappath) . "\r\n";
   
    $map_crc32 = "\xf9\x0d\x49\xe5";
    $map_crc32 = ( ord($map_crc32[0]) ) + ( ord($map_crc32[1]) << 8) + ( ord($map_crc32[2]) << 16) + ( ord($map_crc32[3]) << 24);
 
    $map = file_get_contents($mappath);
    $map_len = strlen($map);
    $content = '';
    $map_crc32= sprintf("%u", $map_crc32);



for($i = 0; $i < $map_len; $i++)
{
    for($x=$i; $x < $map_len; $x++)
    {
    $content .= $map[$x];
    }
   
    $checksum = sprintf("%u", crc32($content));

echo "Current offset: " . $i . "\n";
echo "Suppose to be: ".$map_crc32."\n";
    echo "Computed value: ".$checksum."\n";
   
    if($map_crc32 == $checksum)
    {
    echo "1.Matching found at offset $i\n";
    exit;
    }
   
    echo "\n\n";
    $content = '';
    $checksum = '';
}

Camel

There are a large number of standard variants on the CRC family. Are you sure the one Blizzard uses is one of the standards, and the one that PHP provides?

Kp

Remember that Blizzard has a long history of taking a standard algorithm and getting it slightly wrong.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

tinman

the crc32 function generate the correct results for other packets that logged by me... so i assume they are both using the same crc32 function as php. maybe i should try different variants / find out whats wrong with the crc32 function in war3.