Skip to main content

Force change file size in byte and CRC checksum by any value

I play LOL game. Sometime we have game patch done 99% then stopped. The log file display Error message like [bla bla here] So I have to re-patch or restart my PC.
This time has no luck, so I decided to fix myself, hoping can play couple of funny game.
LOL game first verify size of old game data file in byte. In my case is some character image in game_dir/.../assets/images/champions/.
This folder store all champions images from action to tile...
In my case the file Tryndamme_Tile_2.jpg size is not match, expected is 150503 (byte).

In my mind, Garena or Riot game have to verify everything in game data to avoid cheating from local. etc. And they will use filesize and checksum and some other methods to done this.

So first I have to add missing image (Tryndamme_Tile_2.jpg), then force size of this image to match LOL Game expected in update.
Copy file is easy, that use command prompt. Shift + Right click to folder contain image u want to copy to LOL game data. I have to use command prompt because of permission in folder game data. I do not know other way to copy, so just use "familiar" cmd.
[imge here]

After some googling, I find way to edit file to exactly size in byte. I use and hex Editor (HxD) in Windows. Because LOL only play on Windows or MAC OS.  If in linux IDE, I has every tool to use.
Fortunately, I only have to edit file with few hundred KB jpg image.
[HxD] hex editor.
In this editor, when you type something to this, it auto in replace mode, so filesize do not change. So I copy something then paste. From 170KB I delete content int hex Editor to 147KB ~ 150503 byte. After some modify, finally I got exactly byte size need.

Copy to LOL and re update patch.
[quit LOL update use taskmanager or similar (PC Hunter) ...)

[image]

It say CRC not match, crc: is abcdefgh expected crc:e9e99e32 vvv
So I have to force my file to CRC I want.

After few googling, there is no tool for me in Windows. Some tool like CRC faker can't be downloaded or found somewhere.
So I endup with this post
https://www.nayuki.io/page/forcing-a-files-crc-to-any-value

Unfortunately, it do not have any runable program (exe or install). Only source code available: java, python and c.

I decide using python script because it faster to build env in Windows to work with. Java has large download jdk and jre and I do not familiar with javac.
C is good option but I do not have experience with gcc on Windows. Install IDE like code block, DevCpp or Visual Studio is time costly.

So go Python !
Install only in couple of minute. Forgot tick add to ENV variable, no problem re-run installer and re-check. And voila.

Git-bash I have from previous install.
I have to install editor Sublime Text 3 to view python source.

[image ...]
After python env and source downloaded.
I set name to crc_faker.py
then run:
python crc_faker.py file_name offset new_CRC
First I use offset = 1
then I fake crc with offset = 0;

OK
OK, Done ...

Voila ! Now I copy faked CRC jpg image to LOL and hope LOL game will work.

...



Noooooooooooo!

CRC auto changed or the way LOL compute CRC is different.

CRC can be verify using HxD feature in menu.

It has some params: polynomial, init, ...
I don't know.

I only curious on polynomial, after 20' googling, I end up with function index nth. So it's worth nothing.

Only offset is the params I think that affect different CRC compute.

In some first attempt to Force LOL accept Tryndamme_Tile_2.jpg, I saw that LOL see extractly CRC checksum like in HxD.
After some trial-error LOL turn to calculate different CRC.
So I think there are something LOL added or the way it calc CRC different from my HxD.

I try some way to reserve CRC offset but no luck.
After about 3 hours of trial n error, I gave up. My hope of play some LOL game is gone.

So I decide to download new LOL game from start (>5GB on a dial-up net :( ). It may take more than 2 hours to download.

But I still have something to harvest.
First, I've digging in some guide to fix LOL patch from Garena both US and Asia. But end-up with nothing work or the guide is too old.
Second, the fastest way is to copy a game from Net Cafe using USB or similar. Or copy only damage game data from nearest computer.
My nearest LOL game just 2 meter below (:) ) but I don't use that "hard" way.

2nd: int32 and crc32 has some different.
int 32 has a signed bit so max positive value of it is 2^32 (about 2 bil). But crc 32 when convert to INT is max 2 x 2^32 so some of my offset bit I calculate from 2 CRC different by HxD and LOL update not work because it bigger than Int 32.
ie: d2da0236 or f20902ff
and HxD do not accept this too big offset.

I use try to use different offset to verify (calc) CRC in HxD and see different output.

Tool to calc different offset between 2 integer (2 hex string is more precious). No tool found.
I end up with source code again. This time only Csharp :(.
No Visual Studio, only online CSharp available:

private void getOffSet(byte one, byte two)
{
  byte baseByte = 0x80;

  int defaultOffset = 0x0418;

  int mul = (one - baseByte) % 8;

  int result = mul * 0x2000 + defaultOffset;
  result += two * 0x0020;

  Console.WriteLine(result.ToString("X"));
}

The source here http://stackoverflow.com/questions/21989547/calculating-offset-from-two-hex-strings
and http://stackoverflow.com/questions/141262/can-someone-explain-hex-offsets-to-me

csharp online like here:http://www.tutorialspoint.com/compile_csharp_online.php

After some attempt to calc offset but no luck because of tired and I do not familiar with byte programming operator.

So I will try this later. But may be new LOL game will replace old one so how can I re-generate this situation ?

Another doc I will try to know, I have to master (know)  my tool.
https://www.cosc.canterbury.ac.nz/greg.ewing/essays/CRC-Reverse-Engineering.html
http://www.csm.ornl.gov/~dunigan/crc.html

Ha ha it's just few Km of short documents.

[Day 2]
After reading/studying 2 reference above, I found that why LOL game generate different CRC with HxD, It must be it's parameters: Poly, ReflectIn, ReflectOut, XOR in XOR out. Not just poly or offset I thought.


Mình thi thoảng chơi Leage of Legend, 1 game như kiểu Dota đang thịnh hành hiện nay. Game online là cách rẻ tiền để "live the moment", bạn hãy nhớ lại những pha combat ức chế kay cmn kú hay lúc hành team kia.
Garena vn như shit, các bản vá hay gặp lỗi và windows thì tỉ thứ rác như virus, maleware ... làm cho nó ì ạch. Nhưng vì game vẫn phải vô win (m chạy dual boot ubuntu).
Hum nay update patch tiếp tục lăn ra chết khi chạy được 199%. Restart các kiểu con đà điểu ko ăn thua quyết định fix bằng tay. Thử chơi một trò time eater mới.
....



Comments

Post a Comment

Popular posts from this blog

AWS Elasticache Memcached connection

https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/accessing-elasticache.html#access-from-outside-aws http://hourlyapps.blogspot.com/2010/06/examples-of-memcached-commands.html Access memcached https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/GettingStarted.AuthorizeAccess.html Zip include hidden file https://stackoverflow.com/questions/12493206/zip-including-hidden-files phpmemcachedadmin ~ phpMyAdmin or phpPgAdmin ... telnet mycachecluster.eaogs8.0001.usw2.cache.amazonaws.com 11211 stats items stats cachedump 27 100 https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/VPCs.EC.html https://lzone.de/cheat-sheet/memcached VPC ID Security Group ID (sg-...) Cluster: The identifier for the cluster memcached1 Creation Time: The time (UTC) when the cluster was created January 9, 2019 at 11:47:16 AM UTC+7 Configuration Endpoint: The configuration endpoint of the cluster memcached1.ahgofe.cfg.usw1.cache.amazonaws.com:11211 St...

Notes Windows 10 Virtualbox config, PHP Storm Japanese, custom PHP, Apache build, Postgresql

 cmd => Ctrl + Shift + Enter mklink "C:\Users\HauNT\Videos\host3" "C:\Windows\System32\drivers\etc\hosts" https://www.quora.com/How-to-create-a-router-in-php https://serverfault.com/questions/225155/virtualbox-how-to-set-up-networking-so-both-host-and-guest-can-access-internet 1 NAT + 1 host only config https://unix.stackexchange.com/questions/115464/how-to-properly-set-up-2-network-interfaces-in-centos-running-in-virtualbox DEVICE=eth0 TYPE=Ethernet #BOOTPROTO=dhcp BOOTPROTO=none #IPADDR=10.9.11.246 #PREFIX=24 #GATEWAY=10.9.11.1 #IPV4_FAILURE_FATAL=yes #HWADDR=08:00:27:CC:AC:AC ONBOOT=yes NAME="System eth0" [root@localhost www]# cat /etc/sysconfig/network-scripts/ifcfg-eth1 # Advanced Micro Devices, Inc. [AMD] 79c970 [PCnet32 LANCE] DEVICE=eth1 IPADDR=192.168.56.28 <= no eff => auto like DHCP #GATEWAY=192.168.56.1 #BOOTPROTO=dhcp BOOTPROTO=static <= no eff ONBOOT=yes HWADDR=08:00:27:b4:20:10 [root@localhost www]# ...

Rocket.Chat DB schema

_raix_push_notifications avatars.chunks avatars.files instances meteor_accounts_loginServiceConfiguration meteor_oauth_pendingCredentials meteor_oauth_pendingRequestTokens migrations rocketchat__trash rocketchat_cron_history rocketchat_custom_emoji rocketchat_custom_sounds rocketchat_import rocketchat_integration_history rocketchat_integrations rocketchat_livechat_custom_field rocketchat_livechat_department rocketchat_livechat_department_agents rocketchat_livechat_external_message rocketchat_livechat_inquiry rocketchat_livechat_office_hour rocketchat_livechat_page_visited rocketchat_livechat_trigger rocketchat_message rocketchat_oauth_apps rocketchat_oembed_cache rocketchat_permissions rocketchat_raw_imports rocketchat_reports rocketchat_roles rocketchat_room rocketchat_settings rocketchat_smarsh_history rocketchat_statistics rocketchat_subscription rocketchat_uploads system.indexes users usersSessions https://rocket.chat/docs/developer-guides/sc...