Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to replace a string (zipped) code from apk dalvik
    primarykey
    data
    text
    <p>I would like to replace a single string from the hex/dalvik apk code. I realize this would entail finding how the string gets encoded when it is converted from an Android class project into a signed apk file.</p> <p>Is this possible? Well, I know in code, anythings possible.. but does anyone here know how to do it? I have learned that it's possible to delete and add to .apk files on a windows platform with a simple zip archive (such as replacing icons for the SystemUI.apk), without breaking the apk.. but how would one do it programmatically? Specifically in python?</p> <p>Does anyone have any ideas on how to do this?</p> <p>I have tried:</p> <pre><code>import zipfile zf=zipfile.ZipFile('APK.apk') # my zip file for filename in ['classes.dex']: # zipped file content file data=zf.read(filename) data=data.replace('mystring','newstring') #replace string within the content file file=open('classes.dex','wb') file.write(data) # write NEW content file to local disk file.close() zin=zipfile.ZipFile('APK.apk','r') # create zip in and zip out zout=zipfile.ZipFile('APK.apk','w') # iterate through zipped contents and for item in zin.infolist(): # copy all EXCEPT 'classes.dex' content file buffer=zin.read(item.filename) if (item.filename!='classes.dex'): zout.writestr(item,buffer) zout.close() zin.close() zf=zipfile.ZipFile('APK.apk',mode='a') # finally, add new content file from my local disk zf.write('classes.dex',arcname='classes.dex') zf.close() </code></pre> <p>This takes the original APK.apk file, and rewrites a string within one of the zipped content files, then repacking it back to APK.apk. Problem is: ORIGINAL APK.apk = 170 kb NEW APK.apk = 399 kb and NOT INSTALLABLE, the apk was "broken", and the Android system won't install the apk.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload