Last active
August 29, 2015 13:56
-
-
Save ptantiku/9288037 to your computer and use it in GitHub Desktop.
Scan Android's apk files for SECRET_CODE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################### | |
### For finding all secret codes in android ### | |
############################################################################### | |
# author: @ptantiku | |
# | |
# refer: http://forum.xda-developers.com/showthread.php?t=540483 | |
# | |
# ***************************************************************************** | |
### prerequisites: ### | |
# - Android (rooted) | |
# - Android Development Tools (adb) | |
# - wget -O bin2xml.pl http://android-random.googlecode.com/files/axml2xml.pl | |
# - sudo apt-get install perl libunicode-string-perl unzip | |
# | |
# ***************************************************************************** | |
### prepare apk files (run on PC) ### | |
# adb devices | |
# adb shell | |
# su | |
# mkdir /sdcard/apks | |
# find /system/app -name '*.apk' -exec cp {} /sdcard/apks \; | |
# find /data/app -name '*.apk' -exec cp {} /sdcard/apks \; | |
# exit | |
# mkdir /tmp/apks | |
# cd /tmp/apks | |
# adb pull /sdcard/apks . | |
# | |
# ***************************************************************************** | |
#empty output | |
> output.txt | |
# for every file in current directory (presumebly /tmp/apks) | |
for f in `find . -name '*.apk'` | |
do | |
echo "Trying on $f ..." | |
# unzip classes.dex inside, and grep with word 'SECRET' | |
check=$(unzip -p $f | strings | grep -i 'SECRET') | |
if [ $? -eq 0 ] | |
then | |
# extract AndroidManifest.xml, make it readable, | |
# then transform matching code into *#*#(code)#*#* format | |
echo $f >> output.txt; | |
unzip -p $f AndroidManifest.xml | perl bin2xml.pl | grep 'host=' | sed -rn 's/.*"([0-9]+)".*/*#*#\1#*#*/gp' >> output.txt | |
fi | |
done | |
# print out | |
grep -B1 '#' output.txt |
List of known secret codes:
http://www.reddit.com/r/Android/comments/1sl0ep/list_of_android_secret_codes_tips_and_tricks/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output from CyanogenMod 11: