Clash Royale .sc files decrypt

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
iCraftHD
Posts: 3
Joined: Wed Apr 27, 2016 9:14 am

Clash Royale .sc files decrypt

Post by iCraftHD »

Hi, i'm new in this site and my english is very bad eheh...
I've a question: can you decrypt .sc files from clash royale game?
Example: chr_giant.sc
Download: https://mega.nz/#!b4VFgASb
Thanks a lot!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

Have you already checked this thread?
viewtopic.php?t=2186

There is a script but the compressed files are extracted "as-is" without decompression (unknown algorithm).
iCraftHD
Posts: 3
Joined: Wed Apr 27, 2016 9:14 am

Re: Clash Royale .sc files decrypt

Post by iCraftHD »

aluigi wrote:Have you already checked this thread?
viewtopic.php?t=2186

There is a script but the compressed files are extracted "as-is" without decompression (unknown algorithm).

Hi Aluigi, i read this thread, but i don't understand how to use the script. I'm really ignorant in this
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

It's a script for quickbms, you can find the tool here:
http://quickbms.aluigi.org

launch quickbms.exe, select the script, select the sc archive and then the output folder where extracting the files.
iCraftHD
Posts: 3
Joined: Wed Apr 27, 2016 9:14 am

Re: Clash Royale .sc files decrypt

Post by iCraftHD »

I did it! Thanks. Now i have to find a way to open the file
minhkhoant
Posts: 5
Joined: Wed May 04, 2016 11:34 pm

Re: Clash Royale .sc files decrypt

Post by minhkhoant »

How to decrypt clash of clans _tex.sc?it not as clash royale _tex
.sc!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

Have you tried the script in that other thread?
If it doesn't work then upload that file.
minhkhoant
Posts: 5
Joined: Wed May 04, 2016 11:34 pm

Re: Clash Royale .sc files decrypt

Post by minhkhoant »

how to decrypt _tex.sc file clash of clans?
http://www.mediafire.com/download/m3j2e ... ngs_tex.sc
Help me!!!! thank!!!!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

There is no solution for the SCLZ files.
I think they are compressed but I guess I already tried to scan them (which is not easy since they don't contain textual strings to guess what compression is correct).
midler
Posts: 1
Joined: Mon May 09, 2016 9:35 am

Re: Clash Royale .sc files decrypt

Post by midler »

Hello, folks!
I want to "import" village to ultrapowa from original Clash Of Clans game. I have discovered that when I enter someone's base, android creates 4 files in data - chache:
name size
background_player.info 1kb
background_player.sc 1kb
background_player_tex.info 1kb
background_player_tex.sc 10 582 kb

background_player_tex.sc is 10 mb. I think it's texture files and I don't need it. background_player.sc seems to be objects location of village (I think) that I need. Maybe I am wrong and village information is in .info file.

Here are my files -
https://mega.nz/#!5YYnEARJ!BropWWdmQi4A ... ovWE6XnJVU

Any information will be helpful
Thanks.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

Script 0.2 :D
barbossa42
Posts: 11
Joined: Thu Oct 20, 2016 11:18 am

Re: Clash Royale .sc files decrypt

Post by barbossa42 »

Hi there!
I'm a sucker for pattern searching (and for Clash Royale too), so I got instantly hooked on decoding these files.

First: as for the images, this script can extract them all: https://github.com/123456abcdef/cr-sc-dump/

Second: even with the new script version, some sc files can't be extracted, namely the attached list. They exit with the error below:

Code: Select all

- open script clash_royale.bms
- set output folder 1.5.0\error\sc

  offset   filesize   filename
--------------------------------------
  00000023 36034      building_mega_bomb

Error: the compressed LZMA input is wrong or incomplete (0)
Info:  algorithm   445
       offset      00000023
       input size  0x000017c5 6085
       output size 0x00008cc2 36034
       result      0xffffff9c -100

Error: the uncompressed data (-100) is bigger than the allocated buffer (36034)

Last script line before the error or that produced the error:
  28  clog NAME OFFSET SIZE XSIZE


Third: now this is what you guys were waiting for. With the .sc files that quickBMS could extract, I googled for their headers and found nothing useful. So I dug Notepad++ and an hex editor plugin and started researching the binaries for patterns and such. I focused on ui_spells.sc (the card's pictures on your card collection), because it's a neat grid and patterns would emerge quickly. Among the text strings inside I found "atlasgenerator_texture_rgba5656", which could be a clue, but Google doesn't know much about it. This is what I found so far (addresses are in hex):
  1. numbers are INT16 Little Endian: first byte is the least significative part, second byte is the most significative. So a pair e6 03 is 998, not 58883.
  2. 00-01 - total number of effective sprites mapped in the file
  3. 02-10 - ??
  4. 11-12 - number of IDs/strings (these are mentioned in the CSV files)
  5. 13-xx - a list of IDs for each string, 2 bytes each
  6. a list of strings. Each is preceded by a byte with the string's legth.
  7. 17 00 00 00 00 1A 00 00 00 00 (constant?)
  8. block(s) of 10 bytes, starting with 01 05, one for each image mapped in this file. The image extracting script appends an "_" on the filename for each image on the same _tex.sc file. The last 4 bytes are the image's width and height
  9. blocks starting with byte 12, one for each sprite: these map the sprites on the image, and vary in size. These have 5 '00' bytes between blocks.
    1. 12
    2. 2 bytes: length of the block
    3. 00 00
    4. 2 bytes: sprite ID (not the same as string ID, but they're associated later)
    5. (lots of bytes to decode)
    6. for static, rectangular images: final 16 bytes are the coordinates (xy) of the 4 corners, normalized between 0000 and FFFF. Just multiply by (image_dimension/65535)
  10. blocks starting with byte 08, not sure how many, not sure what they are, same size rule as 12-blocks. These have 5 '00' bytes between blocks.
  11. blocks starting with byte 09, not sure how many, not sure what they are, same size rule as 12-blocks. These have 5 '00' bytes between blocks.
  12. blocks starting with byte 0C, one for each string, same size rule as 12-blocks. Bytes 5-6 are the same IDs from address 13 onwards, bytes 22-23 are the IDs on the sprite blocks. These have 5 '00' bytes between blocks.

Again, this is based on a study of ui_spells.sc, which are static and mostly rectangular images (legendary cards are hexagonal and their 12-blocks are structured differently). In time I'll try to get some sense off of the animated ones. Any constructive feedback is appreciated.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

Can you upload building_mega_bomb.sc?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

The following are the LZHAM parameters adopted by the SCLZ archives, in case someone is interested:

Code: Select all

m_dict_size_log2 18
m_decompress_flags 0
m_table_update_rate 8
m_table_max_update_interval 0
m_table_update_interval_slow_rate 0
barbossa42
Posts: 11
Joined: Thu Oct 20, 2016 11:18 am

Re: Clash Royale .sc files decrypt

Post by barbossa42 »

There, all .sc files that couldn't be extracted.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

Script 0.2.1 :D
barbossa42
Posts: 11
Joined: Thu Oct 20, 2016 11:18 am

Re: Clash Royale .sc files decrypt

Post by barbossa42 »

Thanks a lot!
Going back to research now... I wonder if I can make some cool animated GIFs out of those sprites :lol:
milanmaldini
Posts: 1
Joined: Tue Oct 25, 2016 2:05 pm

Re: Clash Royale .sc files decrypt

Post by milanmaldini »

aluigi wrote:Script 0.2.1 :D


hi aluigi
I have tried your script and get one file.

How I can use this tool to get *.png files?

Thank you.
Johnny
Posts: 16
Joined: Fri Oct 28, 2016 9:54 am

Re: Clash Royale .sc files decrypt

Post by Johnny »

barbossa42 wrote:Hi there!
I'm a sucker for pattern searching (and for Clash Royale too), so I got instantly hooked on decoding these files.

First: as for the images, this script can extract them all: https://github.com/123456abcdef/cr-sc-dump/


Hey barbossa42, I was wondering if you could explain to me this step of the github link:

2. Install pyliblzma with:
python -m pip install pyliblzma

3. Install Pillow with:
python -m pip install Pillow

I don't understand how you can install pylibzma just by using this code. Bc when i type it on python it says: SyntaxError invalid syntax

Thx so much !(I'm sorry if this is obvious, im just a noob. I just want some good clash royale high rez pics)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Clash Royale .sc files decrypt

Post by aluigi »

@milanmaldini
Unfortunately I worked only on the script, I can't help with the content of the extracted data

@Johnny
The syntax of the commands reported on that link is correct but pyliblzma is an obsolete package of 6 years ago that can't be installed on Windows by default ("close_fds is not supported on Windows ").
Just my 2 cents in case you get no answer from the other user.