Clash Royale .sc files decrypt

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
CamC999
Posts: 19
Joined: Tue Nov 22, 2016 9:25 pm

Re: Clash Royale .sc files decrypt

Post by CamC999 »

The tutorial video for the .sc files decryption is up! https://youtu.be/oqnG9nuDV6I



P.S. : The .csv files decryption video will be posted soon! Subscribe to stay updated.
Johnny
Posts: 16
Joined: Fri Oct 28, 2016 9:54 am

Re: Clash Royale .sc files decrypt

Post by Johnny »

CamC999 wrote:The tutorial video for the .sc files decryption is up! https://youtu.be/oqnG9nuDV6I
P.S. : The .csv files decryption video will be posted soon! Subscribe to stay updated.


Unfortunately the video got took down by "Supercell Oy", could you send the vid as an mp4 plz? Thx. (You could also re-upload the video and make it a private vid with only the ppl with the link that can have access to it)
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

CamC999 wrote:
barbossa42 wrote:It is VERY unlikely that the client (CR app) would accept modified resource files, since it validates their hash against the server.
Now, if there were some alternative server around, like the Ultrapowa Clash Server, it wouldn't be hard to reverse the process: change the textures, update the texture map if necessary, save a stream of pixels in the correct format, compress with LZMA and remove a part of the header, so the file would behave just like CR's .sc files.
Also, I'm not the creator of dumpsc, just fixed a bug ;-)


So I found that the .sc files have a fingerprint and hash on them, not allowing you to edit them, however, the _tex.sc files don't. I was able to replace the chr_princess_tex.sc with chr_electro_wiz_tex.sc and it worked using filza on jailbreak. The problem is that the normal .sc files can't be changed, so it ends up trying to perform an animation meant for the princess texture, on the electro wizard, making the textures offset and out of place.

I am trying to find a way to use LZMA and the dumpsc.py script to reencrypt edited .png files that will save them as the correct encrypted .sc files. Do you know enough about the script to reverse the process? :?


So did you find a script that reverse the process ?
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

barbossa42 wrote:
CamC999 wrote:So I found that the .sc files have a fingerprint and hash on them, not allowing you to edit them, however, the _tex.sc files don't. I was able to replace the chr_princess_tex.sc with chr_electro_wiz_tex.sc and it worked using filza on jailbreak. The problem is that the normal .sc files can't be changed, so it ends up trying to perform an animation meant for the princess texture, on the electro wizard, making the textures offset and out of place.

I am trying to find a way to use LZMA and the dumpsc.py script to reencrypt edited .png files that will save them as the correct encrypted .sc files. Do you know enough about the script to reverse the process? :?


As I said before, the reverse process is relatively simple. Unfortunately I'm a bit busy at work to code it, but here is an outline:

0- Change your PNG file as wished; to keep it simple, keep the image dimensions the same.

1- Load the image using PIL/pillow, convert it to an 1D array of pixels, encoded as 4 bytes per pixel (RGBA)
2- Write the header:
2.1- byte 0 is 0x01
2.2- bytes 1-4 should be the number of pixels * the number of bytes per pixel (4), little endian notation
2.3- byte 5 should be 0x00
2.4- bytes 6-7 are the image width, little endian
2.5- bytes 8-9 are the image height, little endian

3- Write header + image data to a file, compress using LZMA
4- Remove 4 0x00 bytes from position 9 of the compressed file
5- Save as .sc

Some sprite map files have the image pixel format in them, this could probably cause some errors; you would need to note the pixel format of the source image and re-encode the pixels in the original format, but this is outside my knowledge, the instructions above are for RGBA8888. Check the convert_pixel function and reverse the binary operations there.


So did you find a script that convert png files to correct sc files ?
YohanIsHere
Posts: 1
Joined: Tue Jan 10, 2017 1:08 am

Re: Clash Royale .sc files decrypt

Post by YohanIsHere »

CamC999 wrote:Okay so i did everything barbossa42 said and i get this error:

C:\Users\cam\Desktop\sc>for %v in (*_tex.sc) do python dumpsc.py %v

C:\Users\cam\Desktop\sc>python dumpsc.py arena_training_tex.sc
Traceback (most recent call last):
File "dumpsc.py", line 6, in <module>
from PIL import Image
ImportError: No module named 'PIL'

It also does this for every SC file in the folder ending in _tex.sc

UPDATE: I was able to fix the issue by installing "pillow" for python (The link can be found here: https://pypi.python.org/pypi/Pillow/3.4.2#downloads)

ALSO: I was able to find all of the images by fixing the problem above! thank you everyone!

P.S. I can share the audio and images with any of you on google drive if you want :lol:

Here are some sample files!

ui_spells_tex_.png

chr_electro_wizard_tex.png

ui_spells_tex.png

YES Can you pleassee share the files with me. my email is yohan.guyomard@gmail.com
CamC999
Posts: 19
Joined: Tue Nov 22, 2016 9:25 pm

Re: Clash Royale .sc files decrypt

Post by CamC999 »

Johnny wrote:
CamC999 wrote:The tutorial video for the .sc files decryption is up! https://youtu.be/oqnG9nuDV6I
P.S. : The .csv files decryption video will be posted soon! Subscribe to stay updated.


Unfortunately the video got took down by "Supercell Oy", could you send the vid as an mp4 plz? Thx. (You could also re-upload the video and make it a private vid with only the ppl with the link that can have access to it)


Yes, fortunately I do have it on my drive and this is the link: https://drive.google.com/open?id=0Bzh5n ... m1pdTJ2RlU

I guess it would be better to just also do this for the upcoming .csv decryption tutorial :D
CamC999
Posts: 19
Joined: Tue Nov 22, 2016 9:25 pm

Re: Clash Royale .sc files decrypt

Post by CamC999 »

YohanIsHere wrote:
CamC999 wrote:Okay so i did everything barbossa42 said and i get this error:

C:\Users\cam\Desktop\sc>for %v in (*_tex.sc) do python dumpsc.py %v

C:\Users\cam\Desktop\sc>python dumpsc.py arena_training_tex.sc
Traceback (most recent call last):
File "dumpsc.py", line 6, in <module>
from PIL import Image
ImportError: No module named 'PIL'

It also does this for every SC file in the folder ending in _tex.sc

UPDATE: I was able to fix the issue by installing "pillow" for python (The link can be found here: https://pypi.python.org/pypi/Pillow/3.4.2#downloads)

ALSO: I was able to find all of the images by fixing the problem above! thank you everyone!

P.S. I can share the audio and images with any of you on google drive if you want :lol:

Here are some sample files!

ui_spells_tex_.png

chr_electro_wizard_tex.png

ui_spells_tex.png

YES Can you pleassee share the files with me. my email is yohan.guyomard@gmail.com


Yes I have just shared the .png files with you as of now :D
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

CamC999 wrote:
YohanIsHere wrote:
CamC999 wrote:Okay so i did everything barbossa42 said and i get this error:

C:\Users\cam\Desktop\sc>for %v in (*_tex.sc) do python dumpsc.py %v

C:\Users\cam\Desktop\sc>python dumpsc.py arena_training_tex.sc
Traceback (most recent call last):
File "dumpsc.py", line 6, in <module>
from PIL import Image
ImportError: No module named 'PIL'

It also does this for every SC file in the folder ending in _tex.sc

UPDATE: I was able to fix the issue by installing "pillow" for python (The link can be found here: https://pypi.python.org/pypi/Pillow/3.4.2#downloads)

ALSO: I was able to find all of the images by fixing the problem above! thank you everyone!

P.S. I can share the audio and images with any of you on google drive if you want :lol:

Here are some sample files!

ui_spells_tex_.png

chr_electro_wizard_tex.png

ui_spells_tex.png

YES Can you pleassee share the files with me. my email is yohan.guyomard@gmail.com


Yes I have just shared the .png files with you as of now :D

Hi, did u find a script that reverse the process ?
CamC999
Posts: 19
Joined: Tue Nov 22, 2016 9:25 pm

Re: Clash Royale .sc files decrypt

Post by CamC999 »

imblyzzard wrote:
CamC999 wrote:
YohanIsHere wrote:YES Can you pleassee share the files with me. my email is yohan.guyomard@gmail.com


Yes I have just shared the .png files with you as of now :D

Hi, did u find a script that reverse the process ?


Umm... unfortunatley I have not found a script to reverse the process. I have been working on it for a very long time, but if anyone can do it, i would say Barbossa42 could, but he doesn't appear to go on this forum anymore :(
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

CamC999 wrote:
imblyzzard wrote:
CamC999 wrote:
Yes I have just shared the .png files with you as of now :D

Hi, did u find a script that reverse the process ?


Umm... unfortunatley I have not found a script to reverse the process. I have been working on it for a very long time, but if anyone can do it, i would say Barbossa42 could, but he doesn't appear to go on this forum anymore :(


Oh ok. I thank u for the work you realize (srry for my bad english). I'm still looking for reverse the process but its hard. There is a forum on ultrapowa.com/forum where a guy post a script to convert _tex.sc to png on décember 2. He says that he works on that to. Same with knobse (on the same forum).
But if someone trying and do it, that could be awesome !
Thanks for you reply
Bye
barbossa42
Posts: 11
Joined: Thu Oct 20, 2016 11:18 am

Re: Clash Royale .sc files decrypt

Post by barbossa42 »

Hi guys.
I'm quite busy at work for some time now, so working on this script is being really hard. Also, my phone is not rooted right now (and I'll have to keep it like that for some time), so I can't really test if _tex.sc replacement will work.
I'll try to come up with something on the next week or so, but don't count on it.
And yes, I'll still follow this topic =)
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

barbossa42 wrote:Hi guys.
I'm quite busy at work for some time now, so working on this script is being really hard. Also, my phone is not rooted right now (and I'll have to keep it like that for some time), so I can't really test if _tex.sc replacement will work.
I'll try to come up with something on the next week or so, but don't count on it.
And yes, I'll still follow this topic =)


Ok great man good luck ;)
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

imblyzzard wrote:
barbossa42 wrote:Hi guys.
I'm quite busy at work for some time now, so working on this script is being really hard. Also, my phone is not rooted right now (and I'll have to keep it like that for some time), so I can't really test if _tex.sc replacement will work.
I'll try to come up with something on the next week or so, but don't count on it.
And yes, I'll still follow this topic =)


Ok great man good luck ;) on my side i will try to create a new fingerprint.json or something like that. If i succeed, we wont need to convert png to sc and that could be convenient. Sorry for my bad english one more time :lol: bye
CamC999
Posts: 19
Joined: Tue Nov 22, 2016 9:25 pm

Re: Clash Royale .sc files decrypt

Post by CamC999 »

imblyzzard wrote:
imblyzzard wrote:
barbossa42 wrote:Hi guys.
I'm quite busy at work for some time now, so working on this script is being really hard. Also, my phone is not rooted right now (and I'll have to keep it like that for some time), so I can't really test if _tex.sc replacement will work.
I'll try to come up with something on the next week or so, but don't count on it.
And yes, I'll still follow this topic =)


Ok great man good luck ;) on my side i will try to create a new fingerprint.json or something like that. If i succeed, we wont need to convert png to sc and that could be convenient. Sorry for my bad english one more time :lol: bye


I already know that fingerprint.json already has a fingerprint on it, preventing you from being able to change the .sc in any way. HOWEVER, the files that are _tex.sc can be altered. I have tested this by deleting the chr_princess_tex.sc file and duplicating the chr_goblin_blowdart and renaming back to "chr_princess_tex.sc"

This makes it so that the princess has the texture of the dart goblin, but since the normal .sc files control the hitboxes and animations, the troop's texture is offset, and this can't be changed because it is controlled by the fingerprint.json
Moon Arts
Posts: 10
Joined: Sun Jan 15, 2017 7:32 pm

Re: Clash Royale .sc files decrypt

Post by Moon Arts »

Hi everyone, first i'm sorry for my bad english, i'm french and i'm only 17. Well, i know how transform any .sc to .png with CamC999's Tutorial, he said he will do a tutorial about .csv modification. I'm waiting for this tutorial because i know how to edit them. I decrypt them, change values and recrypt them, the only problem that's when i build the new apk with modified values, i can't install it, i think Supercell have some security, do you know how can i bypass those security ? Thanks a lot :)
Last edited by Moon Arts on Sun Jan 15, 2017 10:35 pm, edited 1 time in total.
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

Moon Arts wrote:Hi everyone, first i'm sorry for my bad english, i'm french and i'm only 17. Well, i know how transform any .sc to .png with CamC999's Tutorial, he said he will do a tutorial about .scv modification. I'm waiting for this tutorial because i know how to edit them. I decrypt them, change values and recrypt them, the only problem that's when i build the new apk with modified values, i can't install it, i think Supercell have some security, do you know how can i bypass those security ? Thanks a lot :)


Yo ! Je suis français aussi enfin mdr. Bon alors moi JAI 14 ans. On travaille tous plus ou moins sur un script qui transforme les png en sc mais je bloque à une ligne de code (ça c t pour les autres). Dans ton cas, je ne pense pas que supercell ai une sécurité qui empêche l'apk de s'installer. C'est même impossible. Ce qui serait possible, c'est que tu serais capable de l'installer, de la lancer et ça crash. Ça ok. Mais non. J'utilise DarkSouls Éditor 3.0 pour le decrypt/encrypt des csv. Je suis sous iOS jailbreak et moi comme je suis JB, je n'ai pass besoin de réinstaller l'application, JAI juste besoin de remplacer le csv que j'ai modifié avec iFile. *SPAM* de Root ton Android device, modifie le csv (oublie pas de le reencypter) et remplace le avec un logiciel Root du genre iFile. Si tu as la flemme de Root ton tel/tablette, je pense savoir d'où vient ton problème. Quand tu recompile ton apk, je pense qu'elle n'est pas signée. C'est pour ça qu'elle ne veut pas s'installer. Il y a plein d'application qui permette de signer une apk (AdvancedApk Tool by BDFreak). Tien moi au courant
Bye
Moon Arts
Posts: 10
Joined: Sun Jan 15, 2017 7:32 pm

Re: Clash Royale .sc files decrypt

Post by Moon Arts »

imblyzzard wrote: Yo ! Je suis français aussi enfin mdr. Bon alors moi JAI 14 ans. On travaille tous plus ou moins sur un script qui transforme les png en sc mais je bloque à une ligne de code (ça c t pour les autres). Dans ton cas, je ne pense pas que supercell ai une sécurité qui empêche l'apk de s'installer. C'est même impossible. Ce qui serait possible, c'est que tu serais capable de l'installer, de la lancer et ça crash. Ça ok. Mais non. J'utilise DarkSouls Éditor 3.0 pour le decrypt/encrypt des csv. Je suis sous iOS jailbreak et moi comme je suis JB, je n'ai pass besoin de réinstaller l'application, JAI juste besoin de remplacer le csv que j'ai modifié avec iFile. *SPAM* de Root ton Android device, modifie le csv (oublie pas de le reencypter) et remplace le avec un logiciel Root du genre iFile. Si tu as la flemme de Root ton tel/tablette, je pense savoir d'où vient ton problème. Quand tu recompile ton apk, je pense qu'elle n'est pas signée. C'est pour ça qu'elle ne veut pas s'installer. Il y a plein d'application qui permette de signer une apk (AdvancedApk Tool by BDFreak). Tien moi au courant
Bye


C'est exactement ça, alors il faut savoir que j'ai un téléphone assez rare un "Xiaomi Redmi Note 2 Prime" un téléphone chinois, je l'avais root avant mais suite à certain problèmes de version de ma rom, j'ai dû enlever le root. J'utilise aussi DarkSouls Editor 3.0 pour decrypt/encrypt mes .csv. Merci pour toutes tes informations qui vont m'être très utile par la suite. Je vais *SPAM* de signer mon .apk cette semaine je te retiens au courant. Bye
royalemod
Posts: 2
Joined: Mon Jan 16, 2017 3:54 pm

Re: Clash Royale .sc files decrypt

Post by royalemod »

It is easy to reverse dumpsc.py. Proof: http://imgur.com/a/57YqJ
But i think it shoud not be public available. Who can't reverse the script - dont need it. For example it can cause that a lot of clickbaiters on youtube as Azhure will make more trash videos with "ideas" and fake updates.
imblyzzard
Posts: 28
Joined: Mon Jan 09, 2017 8:50 pm

Re: Clash Royale .sc files decrypt

Post by imblyzzard »

royalemod wrote:It is easy to reverse dumpsc.py. Proof: http://imgur.com/a/57YqJ
But i think it shoud not be public available. Who can't reverse the script - dont need it. For example it can cause that a lot of clickbaiters on youtube as Azhure will make more trash video with "ideas" and fake updates.


Maybe but we don't know that your picture is fake or not. If you success, you can send me the reversed dumpsc.py. I Will test it.

Bye
Sorry for my bad english
royalemod
Posts: 2
Joined: Mon Jan 16, 2017 3:54 pm

Re: Clash Royale .sc files decrypt

Post by royalemod »

imblyzzard wrote:Maybe but we don't know that your picture is fake or not. If you success, you can send me the reversed dumpsc.py. I Will test it.

I can only send the modded texture. Not the script itself, reasons in my prev. post