clash royale 黑盒分析与手游客户端保护方案

127
Clash Royaleἓፋړ܉ [email protected]

Upload: cfc4n-chen

Post on 21-Jan-2017

208 views

Category:

Internet


4 download

TRANSCRIPT

Page 1: Clash royale 黑盒分析与手游客户端保护方案

Clash Royale

[email protected]

Page 2: Clash royale 黑盒分析与手游客户端保护方案

• ios

• WIFI+ PC MAC PRO

• genymotion

Page 3: Clash royale 黑盒分析与手游客户端保护方案

• wifi

• WIFI SSID

• mac pro wireshark

Page 4: Clash royale 黑盒分析与手游客户端保护方案

IP

Page 5: Clash royale 黑盒分析与手游客户端保护方案
Page 6: Clash royale 黑盒分析与手游客户端保护方案

• A

• NS

• CNAME

Page 7: Clash royale 黑盒分析与手游客户端保护方案

whois• Domain Name: clashroyaleapp.com

• Registry Domain ID: 1970575925_DOMAIN_COM-VRSN

• Registrar WHOIS Server: whois.comlaude.com

• Registrar URL: http://www.comlaude.com

• Updated Date: 2016-02-15T11:01:48Z

• Creation Date: 2015-10-21T16:11:09Z

• Registrar Registration Expiration Date: 2016-10-21T00:00:00Z

• Registrar: NOM-IQ Ltd dba Com Laude

• Registrar IANA ID: 470

• Domain Status: clientDeleteProhibited https://www.icann.org/epp#clientDeleteProhibited

• Domain Status: clientTransferProhibited https://www.icann.org/epp#clientTransferProhibited

• Domain Status: clientUpdateProhibited https://www.icann.org/epp#clientUpdateProhibited

• Registry Registrant ID:

• Registrant Name: Domain Manager

Page 8: Clash royale 黑盒分析与手游客户端保护方案

whois

• comlaude

• SuperCell

Page 9: Clash royale 黑盒分析与手游客户端保护方案

Name Server• NS-1313.AWSDNS-36.ORG

• NS-1582.AWSDNS-05.CO.UK

• NS-460.AWSDNS-57.COM

• NS-762.AWSDNS-31.NET

Page 10: Clash royale 黑盒分析与手游客户端保护方案

A• Bangkok, Thailand 54.231.49.82

• Auckland, New Zealand 54.231.82.129

• Toronto, Canada 54.231.49.249

• Paris, France 54.231.48.42

• Frankfurt, Germany 54.231.50.49

• Arizona, United States 54.231.1.188

• Washington DC, United States 54.231.48.106

• Sydney, Australia 54.231.0.172

• Beijing, China 54.231.14.140

• Tokyo, Japan 54.231.12.164

• Monterrey, Mexico 54.231.18.244

• Johannesburg, South Africa 54.231.9.188

• Moscow, Russia 54.231.19.20

• Manchester, United Kingdom 54.231.17.52

Page 11: Clash royale 黑盒分析与手游客户端保护方案

Page 12: Clash royale 黑盒分析与手游客户端保护方案

• A gamec.clashroyaleapp.com

• CNAME CNAME clashroyalegame.kunlun-cdn.com CNAME cr.kunlun-cdn.com

Page 13: Clash royale 黑盒分析与手游客户端保护方案

CNAME

Page 14: Clash royale 黑盒分析与手游客户端保护方案

DNS

Page 15: Clash royale 黑盒分析与手游客户端保护方案

• 106.75.133.* 20 ucloud.cn /

• 106.75.134.* 10 ucloud.cn /

• 106.75.135.* 7 ucloud.cn /

• 106.75.140.* 3 ucloud.cn /

2016-03-17

Page 16: Clash royale 黑盒分析与手游客户端保护方案

Name Server

cfc4n@cnxct:~$ dig gamec.clashroyaleapp.com

;; AUTHORITY SECTION:

kunlun-cdn.com. 22379 IN NS ns3.dnsv5.com.

kunlun-cdn.com. 22379 IN NS ns4.dnsv5.com.

Page 17: Clash royale 黑盒分析与手游客户端保护方案

Page 18: Clash royale 黑盒分析与手游客户端保护方案

• gamec.clashroyaleapp.com 3 16 15 DNS 400W

• game.clashroyaleapp.com 3 16 15 DNS 17W

• game.clashroyaleapp.com.ad***.to***

• game.clashroyaleapp.com.bel***

• game.clashroyaleapp.com.dh***

• game.clashroyaleapp.com.ho***

• game.clashroyaleapp.com.lo***

• game.clashroyaleapp.com.ral***

• game.clashroyaleapp.com.wor***

Page 19: Clash royale 黑盒分析与手游客户端保护方案
Page 20: Clash royale 黑盒分析与手游客户端保护方案

• CNAME

• A

• 4 Name Server ,A

• A DNS

Page 21: Clash royale 黑盒分析与手游客户端保护方案

• Ucloud

• 40 400W

• DNS http dns

Page 22: Clash royale 黑盒分析与手游客户端保护方案
Page 23: Clash royale 黑盒分析与手游客户端保护方案

• 9339

Page 24: Clash royale 黑盒分析与手游客户端保护方案
Page 25: Clash royale 黑盒分析与手游客户端保护方案
Page 26: Clash royale 黑盒分析与手游客户端保护方案

• 27 7c 00 00 10 00 00 79

• 27 7b 00 00 19 00 00 72

• 27 7b 00 00 19 00 00 ca

• 37 16 00 00 1a 00 00 3c

• 27 7c 00 00 10 00 00 31

• 27 7b 00 00 19 00 00 56

Page 27: Clash royale 黑盒分析与手游客户端保护方案

• IP\TCP

Page 28: Clash royale 黑盒分析与手游客户端保护方案

pcapng

Page 29: Clash royale 黑盒分析与手游客户端保护方案

• wirshark

• 23

• [39 124 0 0 16 0 0 135 29 244 121 46 116 184 61 65 103 17 224 73 143 189 48]

• [39 124 0 0 16 0 0 25 80 113 190 45 125 228 66 148 62 222 192 195 74 184 150]

• [39 124 0 0 16 0 0 138 215 9 252 5 252 4 96 135 136 71 30 168 52 19 201]

Page 30: Clash royale 黑盒分析与手游客户端保护方案

Page 31: Clash royale 黑盒分析与手游客户端保护方案

-

27 7c 00 00 10 00 00 79 39 e2 ce a2 19 55 6f 2c

15 54 f3 72 c3 ad 96

5 0x10 7-N

Page 32: Clash royale 黑盒分析与手游客户端保护方案

• 8<<1 , 0XFF, 255

• 255

Page 33: Clash royale 黑盒分析与手游客户端保护方案
Page 34: Clash royale 黑盒分析与手游客户端保护方案

• 7 402

• 4 5 0x0192

• 4-5 ( )

• Big Endian

Page 35: Clash royale 黑盒分析与手游客户端保护方案

• 0-3

• 4-5

• 6-7 0x00

Page 36: Clash royale 黑盒分析与手游客户端保护方案

• 0-2 command

• 3-5

• 6-7 0x00

Page 37: Clash royale 黑盒分析与手游客户端保护方案

• client->server

• SuperCell ?

• coc-proxy

• libg.so

Page 38: Clash royale 黑盒分析与手游客户端保护方案
Page 39: Clash royale 黑盒分析与手游客户端保护方案

• COC Hey Day Boom Beach Clash Royale

Page 40: Clash royale 黑盒分析与手游客户端保护方案

• command

• ( )

Page 41: Clash royale 黑盒分析与手游客户端保护方案

• csv

• sc

Page 42: Clash royale 黑盒分析与手游客户端保护方案

• android apk

• ios ipa

• zip

• csv

Page 43: Clash royale 黑盒分析与手游客户端保护方案

csv

Page 44: Clash royale 黑盒分析与手游客户端保护方案

/

• 1.jpg 1.png 1.gif

Page 45: Clash royale 黑盒分析与手游客户端保护方案

• (magic Number) ?

Page 46: Clash royale 黑盒分析与手游客户端保护方案

Magic Number

Page 47: Clash royale 黑盒分析与手游客户端保护方案

Magic Number

http Magic Number

Page 48: Clash royale 黑盒分析与手游客户端保护方案
Page 49: Clash royale 黑盒分析与手游客户端保护方案
Page 50: Clash royale 黑盒分析与手游客户端保护方案

(magic number)

Page 51: Clash royale 黑盒分析与手游客户端保护方案

Page 52: Clash royale 黑盒分析与手游客户端保护方案

Page 53: Clash royale 黑盒分析与手游客户端保护方案

csv

5d 00 00 04 file heaher\magic number\file signature 5d 00 00 file heaher\magic number\file signature

Page 54: Clash royale 黑盒分析与手游客户端保护方案

lzma

Page 55: Clash royale 黑盒分析与手游客户端保护方案
Page 56: Clash royale 黑盒分析与手游客户端保护方案

lzma• LZMA Lempel-Ziv-Markov chain-Algorithm Deflate LZ77

Igor Pavlov 2001 7-Zip 2001 LZ77

bzip2 4GB

• bin lzma

• http://sudo-kill-all.blogspot.tw/2015/06/tutorial-unpacking-cable-modem-firmware.html

• http://zenhax.com/viewtopic.php?t=27

• https://github.com/cscott/lzma-purejs/blob/master/FORMAT.md

• ftp://ftp.uni-bayreuth.de/pub/packages/tools/lzma/tukaani.org/lzma/header-format-12.txt

Page 57: Clash royale 黑盒分析与手游客户端保护方案

LZMA RFC

ftp://ftp.uni-bayreuth.de/pub/packages/tools/lzma/tukaani.org/lzma/header-format-12.txt

• the number of literal context bits (lc, [0, 8]);

• the number of literal position bits (lp, [0, 4]); and

• the number of position bits (pb, [0, 4]).

Page 58: Clash royale 黑盒分析与手游客户端保护方案

csv• credits.csv: 5D 00 00 04 00 4F 02 00 00

00 11 13 88 26 D3 4D 46 2E C5 BA A5 53 6B 56 08 84 CF 8B 5B 2E D8 7C

• 5D 00 00 04 00 magic Number

• 4F 02 00 00 00 11 13 88 11 13 88

• 11 13 88

Page 59: Clash royale 黑盒分析与手游客户端保护方案

csv

11 13 88

4F 02 00 00 00

9B B0 00 00 00

BE 03 00 00 00

86 84 00 00 00

Page 60: Clash royale 黑盒分析与手游客户端保护方案

csv

• 591 2971 958 33926

• 1K,3KB,1KB,33K

Page 61: Clash royale 黑盒分析与手游客户端保护方案

csv• 5 length

• lzma 8 5

• 3 0x00

• ...

• “4F 02 00 00 00” 00 literal position bits

• 4 ?

• ...

• .... lzma

Page 62: Clash royale 黑盒分析与手游客户端保护方案

csv

Page 63: Clash royale 黑盒分析与手游客户端保护方案

• “ ”

• LOL OB http://www.cnxct.com/how-to-watch-lol-tencent-ob-on-mac-osx/

Page 64: Clash royale 黑盒分析与手游客户端保护方案

SC

Page 65: Clash royale 黑盒分析与手游客户端保护方案

SC

Page 66: Clash royale 黑盒分析与手游客户端保护方案

SC• Magic Number:53 43 00 00 00 01 00 00 00 10

• SuperCell ?

• 0x53\0x43

• ASCII S C

Page 67: Clash royale 黑盒分析与手游客户端保护方案

• android

• android java

• SO

Page 68: Clash royale 黑盒分析与手游客户端保护方案

• Linux C fopen

• fopen

Page 69: Clash royale 黑盒分析与手游客户端保护方案

fopen

Page 70: Clash royale 黑盒分析与手游客户端保护方案

• fopen

• fopen

Page 71: Clash royale 黑盒分析与手游客户端保护方案
Page 72: Clash royale 黑盒分析与手游客户端保护方案

sc• clash royale android 1.2.3 ( ), IDA

• sub_1FDCC0

• sub_1E1C50

• v174 !=83 SC magic number

• S ASCII 0x53

Page 73: Clash royale 黑盒分析与手游客户端保护方案

• N

Page 74: Clash royale 黑盒分析与手游客户端保护方案

SC HEXLZMA

Page 75: Clash royale 黑盒分析与手游客户端保护方案

LZMA•

• SuperCell

• Clash Royale COC

• SC COC

Page 76: Clash royale 黑盒分析与手游客户端保护方案

• IDA _tex.sc

• _tex.sc COC lzma

Page 77: Clash royale 黑盒分析与手游客户端保护方案

_tex.sc

Little endian 02 A8 05

02A800 + 0E

Page 78: Clash royale 黑盒分析与手游客户端保护方案

SC

• SC PNG SC

• PNG

Page 79: Clash royale 黑盒分析与手游客户端保护方案

SC

Page 80: Clash royale 黑盒分析与手游客户端保护方案

• ( )

• (zuo) (de) (geng) (hao)

Page 81: Clash royale 黑盒分析与手游客户端保护方案

• SC 57M

• 326M

• 17%

Page 82: Clash royale 黑盒分析与手游客户端保护方案

• ( )

• so exe

Page 83: Clash royale 黑盒分析与手游客户端保护方案

• lua

Page 84: Clash royale 黑盒分析与手游客户端保护方案
Page 85: Clash royale 黑盒分析与手游客户端保护方案

• luac magic number 58 58 54 45

Page 86: Clash royale 黑盒分析与手游客户端保护方案

fopen\fread ...

Page 87: Clash royale 黑盒分析与手游客户端保护方案

lua

Page 88: Clash royale 黑盒分析与手游客户端保护方案

sign magic number

Page 89: Clash royale 黑盒分析与手游客户端保护方案

LUA

Page 90: Clash royale 黑盒分析与手游客户端保护方案

• magic number F9 43 5A

• initWithImageData

• initWithImageData

• sub_XXXXX so+so

Page 91: Clash royale 黑盒分析与手游客户端保护方案
Page 92: Clash royale 黑盒分析与手游客户端保护方案

android• IDA pro (>6.6 android )

• ARM CPU

• IDA pro android_server ARM X86

• android su

Page 93: Clash royale 黑盒分析与手游客户端保护方案

android•

• android_server

• adb forward tcp:xxx

• adb shell su android_server

• attach

Page 94: Clash royale 黑盒分析与手游客户端保护方案

attach android

Page 95: Clash royale 黑盒分析与手游客户端保护方案
Page 96: Clash royale 黑盒分析与手游客户端保护方案

so

Page 97: Clash royale 黑盒分析与手游客户端保护方案
Page 98: Clash royale 黑盒分析与手游客户端保护方案
Page 99: Clash royale 黑盒分析与手游客户端保护方案

DUMP• magic number

• png magic number

• R1 8 89 50 4E 47

• png

Page 100: Clash royale 黑盒分析与手游客户端保护方案

PNG

Page 101: Clash royale 黑盒分析与手游客户端保护方案

PNG

Page 102: Clash royale 黑盒分析与手游客户端保护方案

dump

Page 103: Clash royale 黑盒分析与手游客户端保护方案
Page 104: Clash royale 黑盒分析与手游客户端保护方案

• stack

• ...

Page 105: Clash royale 黑盒分析与手游客户端保护方案

lua

Page 106: Clash royale 黑盒分析与手游客户端保护方案

lua

• N magic number

Page 107: Clash royale 黑盒分析与手游客户端保护方案

lua

• KEY

• XXTEA

Page 108: Clash royale 黑盒分析与手游客户端保护方案

xxtea_decrypt

DUMP

Page 109: Clash royale 黑盒分析与手游客户端保护方案

lua•

• lua

Page 110: Clash royale 黑盒分析与手游客户端保护方案

Page 111: Clash royale 黑盒分析与手游客户端保护方案
Page 112: Clash royale 黑盒分析与手游客户端保护方案

• CPU

Page 113: Clash royale 黑盒分析与手游客户端保护方案

Page 114: Clash royale 黑盒分析与手游客户端保护方案

cheat engine …

• Call

Call LOL …

Page 115: Clash royale 黑盒分析与手游客户端保护方案

Cheat Engine

Page 116: Clash royale 黑盒分析与手游客户端保护方案
Page 117: Clash royale 黑盒分析与手游客户端保护方案

Page 118: Clash royale 黑盒分析与手游客户端保护方案

• so so

• android ...

Page 119: Clash royale 黑盒分析与手游客户端保护方案

Call

• soso attach

• ...

Page 120: Clash royale 黑盒分析与手游客户端保护方案

KEY

• KEY

Page 121: Clash royale 黑盒分析与手游客户端保护方案

status tracePid

Page 122: Clash royale 黑盒分析与手游客户端保护方案

• maps SO

• so 96

Page 123: Clash royale 黑盒分析与手游客户端保护方案

• : hash

• : apktoolpng

• : ELF …

• : ...

Page 124: Clash royale 黑盒分析与手游客户端保护方案

• Clash Royale

Page 125: Clash royale 黑盒分析与手游客户端保护方案

• :http://www.bangcle.com/ COC

• :https://www.ijiami.cn/

• APKProtect :http://www.apkprotect.com/

• Shield4J :http://shield4j.com/

• DexGuard :http://www.saikoa.com/dexguard

Page 126: Clash royale 黑盒分析与手游客户端保护方案
Page 127: Clash royale 黑盒分析与手游客户端保护方案

• COC proxy https://github.com/clugh/coc-proxy

• LOL Launcher http://www.cnxct.com/league-of-legends-launcher-of-osx/

• https://en.wikipedia.org/wiki/Magic_number_(programming)

• http://open.163.com/movie/2012/10/B/K/M99VIFJA6_M9A018BBK.html

• https://www.pnfsoftware.com/blog/dexguards-assets-encryption/

• APK http://bbs.pediy.com/showthread.php?t=183116

• ELF :http://bbs.pediy.com/showthread.php?t=192874