clugh / coc-patcher

A small utility to patch and sign the Clash of Clans APK
15 stars 9 forks source link

python 2.7 and issues filling out config.json #1

Closed mrqaidi closed 8 years ago

mrqaidi commented 8 years ago

i am getting this error whats wrong ? config.json is exist dont know why its says not exist

C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>python patcher.py 2.212.9
  File "patcher.py", line 43
    print('ERROR: config.json does not exist.', file=sys.stderr)
                                                    ^
SyntaxError: invalid syntax
mrqaidi commented 8 years ago

another error

AttributeError: type object 'str' has no attribute 'fromhex'


C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>python patcher.py 2.212.9
Getting config ...
Checking environment ...
Traceback (most recent call last):
  File "patcher.py", line 73, in <module>
    bytes.fromhex(config['key'])
AttributeError: type object 'str' has no attribute 'fromhex'
clugh commented 8 years ago

The patcher requires Python 3.5. What is the output of the following?:

python -V
mrqaidi commented 8 years ago

thats right my system was on v2.7 now its updated and i cant see that error but i am getting this

C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>C:\Python35\python.exe patcher.py 2.212.9
Getting config ...
Checking environment ...
client.keystore does not exist. Would you like to create it? (y/n): y
Traceback (most recent call last):
  File "patcher.py", line 126, in <module>
    result = subprocess.run([config['paths']['keytool'], '-genkey', '-keystore', KEYSTORE_PATH, '-storepass', config['keystore']['storepass'], '-alias', config['keystore']['key']['alias'], '-keypass', config['keystore']['key']['keypass'], '-dname', dname, '-keyalg', 'RSA', '-keysize', '2048', '-validity', '10000'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "C:\Python35\lib\subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Python35\lib\subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "C:\Python35\lib\subprocess.py", line 1220, in _execute_child
    startupinfo)
OSError: [WinError 87] The parameter is incorrect

can you share your config.json please

mrqaidi commented 8 years ago

aha i have to put all paths . first thing i did i put my keytool path : C:\Java\jdk1.8.0_73\bin

but i got this

Getting config ...
ERROR: Failed to decode config.json.
mrqaidi commented 8 years ago

i put this

    "apktool": "C:\/Windows\/",
    "md5sum": "",
    "dd": "",
    "keytool": "C:\/Java\/jdk1.8.0_73\bin\/",
    "jarsigner": "C:\/Java\/jdk1.8.0_73\bin\/",
    "zipalign": ""

what i am doing wrong ? please help

clugh commented 8 years ago

You have to put the full path to the executable, for example:

"apktool": "C:\\apktool\\apktool.bat"

Also, you must put the path to all tools.

Edit: Fixed escapes.

mrqaidi commented 8 years ago

i did put path to all tools but not work this error again

C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>python patcher.py 2.212.9
Getting config ...
ERROR: Failed to decode config.json.
clugh commented 8 years ago

Your JSON is likely invalid. Either post it here or run it through a validator.

mrqaidi commented 8 years ago

here is config file#

{
  "debug": true,
  "package": "com.supercell.clashofclans",
  "key": "72f1a4a4c48e44da0c42310f800e96624e6dc6a641a9d41c3b5039d8dfadc27e",
  "url": "gamea.clashofclans.com",
  "keystore": {
    "storepass": "123456",
    "key": {
      "alias": "coc",
      "keypass": "123456",
      "dname": {
        "cn": "Qaidi",
        "ou": "Qaii",
        "o": "qaidi",
        "l": "iraq",
        "s": "kurdistan",
        "c": "iraq"
      }
    }
  },
  "paths": {
    "apktool": "C:\/apktool.bat",
    "md5sum": "C:\/md5sum.bat",
    "dd": "C:\/Users\/Ayman\/Desktop\/CoCSharp.Server\/coc-patcher\/dd-0.3\/dd.exe",
    "keytool": "C:\/Java\/jdk1.8.0_73\/bin\/keytool.exe",
    "jarsigner": "C:\Java\/jdk1.8.0_73\/bin\/jarsigner.exe",
    "zipalign": "C:\/android-sdk-win\/build-tools\/23.0.1\/zipalign.exe"
  }
}
mrqaidi commented 8 years ago

you right json not vaild on line "jarsigner": "C:\Java\/jdk1.8.0_73\/bin\/jarsigner.exe",

clugh commented 8 years ago

Two things. First, I didn't catch it the first time, but you're using regex escapes instead of Windows path escapes. For example, the apktool line should be:

"apktool": "C:\\apktool.bat",

And second, which I see you've just discovered, is the missing escape on jarsigner.

mrqaidi commented 8 years ago

everything passed now but i got new error

ERROR: Version is missing from wiki ('2.212.9 not in keys.').

clugh commented 8 years ago

There is no version 2.212.9, you're looking for 8.212.9.

Edit: Whoops, hit close and comment by accident. But this is a support issue, rather than a bug, anyway, so I'll leave it closed. Feel free to continue commenting here.

mrqaidi commented 8 years ago

ohhh i am wrong :) now another error . sorry bro i am new to apk decoding

Decoding APK ...
ERROR: Failed to decode com.supercell.clashofclans-8.212.9.apk (W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x0101045c
W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x0101045c
Exception in thread "main" brut.androlib.err.UndefinedResObject: resource spec: 0x01010479
        at brut.androlib.res.data.ResPackage.getResSpec(ResPackage.java:59)
        at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:66)
        at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:62)
        at brut.androlib.res.data.value.ResReferenceValue.getReferent(ResReferenceValue.java:57)
        at brut.androlib.res.data.value.ResReferenceValue.encodeAsResXml(ResReferenceValue.java:47)
        at brut.androlib.res.data.value.ResScalarValue.encodeAsResXmlValue(ResScalarValue.java:58)
        at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:72)
        at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:510)
        at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:264)
        at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:128)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:106)
        at brut.apktool.Main.cmdDecode(Main.java:163)
        at brut.apktool.Main.main(Main.java:81)
Picked up _JAVA_OPTIONS:  -Xmx512M).
clugh commented 8 years ago

What version of apktool are you using? What happens if you run:

C:\apktool.bat d com.supercell.clashofclans-8.212.9.apk

Edit: Fixed typo.

mrqaidi commented 8 years ago

this i got from command you sent


Picked up _JAVA_OPTIONS:  -Xmx512M
Apktool v2.1.0 - a tool for reengineering Android apk files
with smali v2.1.1 and baksmali v2.1.1
Copyright 2014 Ryszard Wi?niewski <brut.alll@gmail.com>
Updated by Connor Tumbleson <connor.tumbleson@gmail.com>
clugh commented 8 years ago

Is that the entire output?

mrqaidi commented 8 years ago

here is entire output


C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>C:\/Windows\/apktool.bat  com.d supercell.clashofclans-8.212.9.apk
Picked up _JAVA_OPTIONS:  -Xmx512M
Apktool v2.1.0 - a tool for reengineering Android apk files
with smali v2.1.1 and baksmali v2.1.1
Copyright 2014 Ryszard Wi?niewski <brut.alll@gmail.com>
Updated by Connor Tumbleson <connor.tumbleson@gmail.com>

usage: apktool
 -advance,--advanced   prints advance information.
 -version,--version    prints the version then exits
usage: apktool if|install-framework [options] <framework.apk>
 -p,--frame-path <dir>   Stores framework files into <dir>.
 -t,--tag <tag>          Tag frameworks using <tag>.
usage: apktool d[ecode] [options] <file_apk>
 -f,--force              Force delete destination directory.
 -o,--output <dir>       The name of folder that gets written. Default is apk.out
 -p,--frame-path <dir>   Uses framework files located in <dir>.
 -r,--no-res             Do not decode resources.
 -s,--no-src             Do not decode sources.
 -t,--frame-tag <tag>    Uses framework files tagged by <tag>.
usage: apktool b[uild] [options] <app_path>
 -f,--force-all          Skip changes detection and build all files.
 -o,--output <dir>       The name of apk that gets written. Default is dist/name.apk
 -p,--frame-path <dir>   Uses framework files located in <dir>.

For additional info, see: http://ibotpeaches.github.io/Apktool/
For smali/baksmali info, see: https://github.com/JesusFreke/smali
clugh commented 8 years ago

See the typo in the command, it should be:

C:\apktool.bat d com.supercell.clashofclans-8.212.9.apk
mrqaidi commented 8 years ago

i got this

C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>C:\/Windows\/apktool.bat d com.supercell.clashofclans-8.212.9.apk
Picked up _JAVA_OPTIONS:  -Xmx512M
Destination directory (C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher\com.supercell.clashofclans-8.212.9) already exists. Use -f switch if you want to overwrite it.
mrqaidi commented 8 years ago

i deleted folder and tried again i got this

C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>C:\/Windows\/apktool.bat d com.supercell.clashofclans-8.212.9.apk
Picked up _JAVA_OPTIONS:  -Xmx512M
I: Using Apktool 2.1.0 on com.supercell.clashofclans-8.212.9.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Ayman\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x0101045c
W: Could not decode attr value, using undecoded value instead: ns=android, name=background, value=0x0101045c
I: Decoding values */* XMLs...
Exception in thread "main" brut.androlib.err.UndefinedResObject: resource spec: 0x01010462
        at brut.androlib.res.data.ResPackage.getResSpec(ResPackage.java:59)
        at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:66)
        at brut.androlib.res.data.ResTable.getResSpec(ResTable.java:62)
        at brut.androlib.res.data.value.ResReferenceValue.getReferent(ResReferenceValue.java:57)
        at brut.androlib.res.data.value.ResStyleValue.serializeToResValuesXml(ResStyleValue.java:54)
        at brut.androlib.res.AndrolibResources.generateValuesFile(AndrolibResources.java:510)
        at brut.androlib.res.AndrolibResources.decode(AndrolibResources.java:264)
        at brut.androlib.Androlib.decodeResourcesFull(Androlib.java:128)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:106)
        at brut.apktool.Main.cmdDecode(Main.java:163)
        at brut.apktool.Main.main(Main.java:81)

C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>
mrqaidi commented 8 years ago

issue fixed with this answer from here

https://github.com/iBotPeaches/Apktool/issues/988

This warning you have W: Could not decode attr value, using undecoded value instead: ns=, name=, value=0xffffffff means your framework files are out of date.

Delete the file at $HOME/apktool/framework/1.apk and try again. Give this is a read: http://ibotpeaches.github.io/Apktool/documentation/#framework-files
clugh commented 8 years ago

Glad you got it fixed, and thanks for sharing the link.

mrqaidi commented 8 years ago

thanks but i got another problem

C:\Users\Ayman\Desktop\CoCSharp.Server\coc-patcher>python patcher.py 8.212.9
Getting config ...
Checking environment ...
Getting version info ...
{
  "key": "469b704e7f6009ba8fc72e9b5c864c8e9285a755c5190f03f5c74852f6d9f419",
  "arm": {
    "md5": "769e2e9e1258b75d15cb7e04b2e49de3",
    "key-offset": "4280344",
    "url-offset": "3534513"
  },
  "x86": {
    "md5": "29ca23e48a5e419e83f2a7988c842d3e",
    "key-offset": "6189080",
    "url-offset": "4768816"
  }
}
Decoding APK ...
Checking AndroidManifest.xml ...
Checking package ID ...
Patching package ID ...
Verifying package ID ...
Checking libg.so ...
Traceback (most recent call last):
  File "patcher.py", line 297, in <module>
    result = subprocess.run([config['paths']['md5sum'], LIBG_ARM], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
  File "C:\python35\lib\subprocess.py", line 696, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\python35\lib\subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "C:\python35\lib\subprocess.py", line 1220, in _execute_child
    startupinfo)

i think this time with md5sum please help

clugh commented 8 years ago

Can you post the entire output? The exception seems to be missing from the bottom.

mrqaidi commented 8 years ago

you right something wrong with path i have wrong one i gave new ones for md5sum and dd seem its working i see new steps and building app :)

mrqaidi commented 8 years ago

Decoding APK ... Checking AndroidManifest.xml ... Checking package ID ... Patching package ID ... Verifying package ID ... Checking libg.so ... Checking keys ... Checking URLs ... Patching keys ... Patching URLs ... Verifying keys ... Verifying URLs ... Backing up original APK ... Building APK ... Signing APK ... Aligning APK ... Done.

wow i cant believe that . thanks for your help i will install builded app and test on bluestacks to test coc proxy and let you know result

mrqaidi commented 8 years ago

there is one problem with this . i cant load my village or load my account on this app