-
Notifications
You must be signed in to change notification settings - Fork 39
/
inject.sh
executable file
·40 lines (30 loc) · 1.25 KB
/
inject.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
apktool=$(which apktool)
version=$($apktool --version)
original_apk=$1
function detect_version()
{
if [ "$version" \> "1.5.2" ]
then
echo "-o" # new output folder syntax for version 2.0.0-RC2
else
echo ""
fi
}
output_parameter=$(detect_version)
# prepare the directory structure
rm -rf patch
mkdir -p patch
# disassemble original apk and injected apk
$apktool d bin/injector.apk $output_parameter patch/injector
$apktool d $original_apk $output_parameter patch/orig
# injecting introspection classes
cp -r patch/injector/smali/* patch/orig/smali/
# insert the service
sed -i -e 's/<\/application>/<service android:name="com.sysdream.fino.InspectionService" android:enabled="true" android:exported="true"><intent-filter><action android:name="com.sysdream.fino.inspection"\/><\/intent-filter><\/service><\/application>/' patch/orig/AndroidManifest.xml
# fix sdk versions
sed -i -e 's/<uses-sdk[^>]+>/<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="15" \/>/' patch/orig/AndroidManifest.xml
# build the unsigned apk
apktool b patch/orig $output_parameter tmp.apk
# sign the final apk
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore ~/.android/debug.keystore -storepass android -signedjar $2 tmp.apk androiddebugkey