0

So I have a file in res/values/ on my desktop, in it is strings.xml, this strings.xml contains the following:

<?xml version="1.0" encoding="utf-8"?>
<resources>

  <string name="hello">Hello World, SHAHashActivity!</string>
  <string name="app_name">SHA-Hash</string>
  <string name="sha">12345</string>
  <string name="app_path">67890</string>

</resources>

I have a script that contains that then takes some user input in regards to the name of the apk im trying to modify, then it unzips the apk, hashes classes.dex and attempts to insert the hash value to replace 12345 in strings.xml. In all, once modified, it attempts to use aapt to update the strings.xml file in the apk, but to no avail. Here is a part of the script.

export hash=`/usr/bin/openssl sha1 apk/classes.dex | sed "s|SHA1(apk/classes.dex)= ||g"`
sed -i '' -e"s/12345/$hash/g" res/values/strings.xml
./aapt a -v SHA-Hash.apk res/values/strings.xml

Using sed to locally update the strings file works, it modifies it, but using aapt to update it in the apk does not work.

Any ideas on which command to use aapt properly to replace the existing /res/values/strings.xml with the one on my computer? I can't find much documentation on aapt so any help would be appreciated.

Thanks!

sbrichards
  • 2,169
  • 2
  • 19
  • 32

1 Answers1

0

What about overwriting res/values/strings.xml using plain old jar:

jar vuf SHA-Hash.apk res/values/strings.xml

Justin Muller
  • 1,283
  • 13
  • 21