├── BBoxTester ├── utils │ ├── __init__.py │ ├── zip_utils.py │ ├── apk_utils.py │ ├── state_machine.py │ ├── auxiliary_utils.py │ └── android_manifest.py ├── bbox_core │ ├── __init__.py │ ├── general_exceptions.py │ ├── bboxreporter.py │ ├── bboxexecutor.py │ └── bbox_config.py ├── interfaces │ ├── __init__.py │ ├── dx_interface.py │ ├── zipalign_interface.py │ ├── commander.py │ ├── dex2jar_interface.py │ ├── apktool_interface.py │ └── emma_interface.py ├── auxiliary │ ├── dex2jar │ │ ├── setclasspath.bat │ │ ├── lib │ │ │ ├── dx.jar │ │ │ ├── dex-ir-1.12.jar │ │ │ ├── jasmin-p2.5.jar │ │ │ ├── asm-all-3.3.1.jar │ │ │ ├── dex-reader-1.15.jar │ │ │ ├── jar-rename-1.6.jar │ │ │ ├── commons-lite-1.15.jar │ │ │ ├── dex-tools-0.0.9.15.jar │ │ │ ├── dex-translator-0.0.9.15.jar │ │ │ ├── commons-io-NOTICE.txt │ │ │ ├── asm-LICENSE.txt │ │ │ ├── license-jasmin.txt │ │ │ ├── dx-NOTICE │ │ │ └── commons-io-LICENSE.txt │ │ ├── dex-dump.bat │ │ ├── NOTICE.txt │ │ ├── dex-dump.sh │ │ ├── dex2jar.bat │ │ ├── d2j-dex-dump.bat │ │ ├── d2j-jar2dex.bat │ │ ├── d2j-apk-sign.bat │ │ ├── d2j-asm-verify.bat │ │ ├── d2j-dex2jar.bat │ │ ├── d2j-jar-remap.bat │ │ ├── d2j-dex-asmifier.bat │ │ ├── d2j-init-deobf.bat │ │ ├── d2j-jar-access.bat │ │ ├── d2j-jar2jasmin.bat │ │ ├── d2j-jasmin2jar.bat │ │ ├── d2j-decrpyt-string.bat │ │ ├── dex2jar.sh │ │ ├── d2j-dex-dump.sh │ │ ├── d2j-apk-sign.sh │ │ ├── d2j-dex2jar.sh │ │ ├── d2j-jar-remap.sh │ │ ├── d2j-jar2dex.sh │ │ ├── d2j-asm-verify.sh │ │ ├── d2j-init-deobf.sh │ │ ├── d2j-jar-access.sh │ │ ├── d2j-jar2jasmin.sh │ │ ├── d2j-jasmin2jar.sh │ │ ├── d2j-dex-asmifier.sh │ │ ├── d2j-decrpyt-string.sh │ │ └── LICENSE.txt │ ├── dx │ │ ├── readme.txt │ │ └── dx.jar │ ├── aapt │ │ └── aapt │ ├── emma │ │ ├── emma.jar │ │ ├── emma_device.jar │ │ └── resources │ │ │ ├── emma_ant.properties │ │ │ ├── com │ │ │ └── vladium │ │ │ │ └── emma │ │ │ │ ├── data │ │ │ │ └── merge_usage.res │ │ │ │ ├── report │ │ │ │ └── report_usage.res │ │ │ │ ├── rt │ │ │ │ └── RTExitHook.closure │ │ │ │ ├── instr │ │ │ │ └── instr_usage.res │ │ │ │ ├── exceptions.properties │ │ │ │ └── run_usage.res │ │ │ └── emma_default.properties │ ├── zipalign │ │ └── zipalign │ ├── apktool │ │ └── apktool.jar │ └── instrument_classes │ │ ├── com │ │ └── zhauniarovich │ │ │ └── bbtester │ │ │ ├── EmmaInstrumentation.class │ │ │ └── EmmaInstrumentation$1.class │ │ └── build_helper_classes.sh ├── logconfig.py ├── config │ └── logconfig.json ├── bboxtester.py ├── monkey_run_one_apk.py ├── main_activity_strategy.py ├── main_intents_strategy.py └── running_strategies.py ├── .gitignore ├── BBoxTester_Instr_Sources ├── .settings │ └── org.eclipse.jdt.core.prefs ├── .classpath ├── .project └── src │ └── com │ └── zhauniarovich │ └── bbtester │ └── EmmaInstrumentation.java ├── CITATION.cff ├── README.md └── LICENSE /BBoxTester/utils/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /BBoxTester/bbox_core/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /BBoxTester/interfaces/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .directory 2 | *.pyc 3 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/setclasspath.bat: -------------------------------------------------------------------------------- 1 | SET CLASSPATH=%1;%CLASSPATH% 2 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dx/readme.txt: -------------------------------------------------------------------------------- 1 | dx.jar is copied from android sdk build-tools version 19.1.0 -------------------------------------------------------------------------------- /BBoxTester/auxiliary/aapt/aapt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/aapt/aapt -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dx/dx.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dx/dx.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/emma.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/emma/emma.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/dx.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/dx.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/zipalign/zipalign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/zipalign/zipalign -------------------------------------------------------------------------------- /BBoxTester/auxiliary/apktool/apktool.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/apktool/apktool.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/emma_device.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/emma/emma_device.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/dex-ir-1.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/dex-ir-1.12.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/jasmin-p2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/jasmin-p2.5.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/asm-all-3.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/asm-all-3.3.1.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/dex-reader-1.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/dex-reader-1.15.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/jar-rename-1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/jar-rename-1.6.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/commons-lite-1.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/commons-lite-1.15.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/dex-tools-0.0.9.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/dex-tools-0.0.9.15.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/dex-translator-0.0.9.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/dex2jar/lib/dex-translator-0.0.9.15.jar -------------------------------------------------------------------------------- /BBoxTester/auxiliary/instrument_classes/com/zhauniarovich/bbtester/EmmaInstrumentation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/instrument_classes/com/zhauniarovich/bbtester/EmmaInstrumentation.class -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/dex-dump.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set CLASSPATH= 3 | 4 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" %%i 5 | 6 | java -Xms512m -Xmx1024m -cp "%CLASSPATH%" com.googlecode.dex2jar.util.Dump %* 7 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/instrument_classes/build_helper_classes.sh: -------------------------------------------------------------------------------- 1 | javac -cp /home/yury/software/android-sdk/platforms/android-18/android.jar -d . -g ../../../BBoxTester_Instr_Sources/src/com/zhauniarovich/bbtester/EmmaInstrumentation.java 2 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/instrument_classes/com/zhauniarovich/bbtester/EmmaInstrumentation$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zyrikby/BBoxTester/HEAD/BBoxTester/auxiliary/instrument_classes/com/zhauniarovich/bbtester/EmmaInstrumentation$1.class -------------------------------------------------------------------------------- /BBoxTester_Instr_Sources/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/NOTICE.txt: -------------------------------------------------------------------------------- 1 | dex2jar - Tools to work with android .dex and java .class files 2 | Copyright (c) 2009-2012 Panxiaobo 3 | 4 | contributors 5 | - Panxiaobo 6 | - yyjdelete 7 | 8 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/commons-io-NOTICE.txt: -------------------------------------------------------------------------------- 1 | Apache Commons IO 2 | Copyright 2002-2010 The Apache Software Foundation 3 | 4 | This product includes software developed by 5 | The Apache Software Foundation (http://www.apache.org/). 6 | 7 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/emma_ant.properties: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------- 2 | 3 | emma: com.vladium.emma.emmaTask 4 | emmajava: com.vladium.emma.emmajavaTask 5 | 6 | # ------------------------------------------------------------- 7 | # end of file 8 | -------------------------------------------------------------------------------- /BBoxTester/bbox_core/general_exceptions.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Sep 30, 2014 3 | 4 | @author: yury 5 | ''' 6 | 7 | class MsgException(Exception): 8 | ''' 9 | Generic exception with an optional string msg. 10 | ''' 11 | def __init__(self, msg=""): 12 | self.msg = msg 13 | -------------------------------------------------------------------------------- /BBoxTester_Instr_Sources/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/dex-dump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # copy from $Tomcat/bin/startup.sh 4 | # resolve links - $0 may be a softlink 5 | PRG="$0" 6 | while [ -h "$PRG" ] ; do 7 | ls=`ls -ld "$PRG"` 8 | link=`expr "$ls" : '.*-> \(.*\)$'` 9 | if expr "$link" : '/.*' > /dev/null; then 10 | PRG="$link" 11 | else 12 | PRG=`dirname "$PRG"`/"$link" 13 | fi 14 | done 15 | PRGDIR=`dirname "$PRG"` 16 | # 17 | 18 | _classpath="." 19 | for k in "$PRGDIR"/lib/*.jar 20 | do 21 | _classpath="${_classpath}:${k}" 22 | done 23 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.util.Dump" $1 $2 $3 $4 $5 $6 24 | -------------------------------------------------------------------------------- /BBoxTester/utils/zip_utils.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Oct 13, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import os 7 | from zipfile import ZipFile, ZIP_DEFLATED 8 | 9 | 10 | def zipdir(basedir, archivename): 11 | assert os.path.isdir(basedir) 12 | with ZipFile(archivename, "a", ZIP_DEFLATED) as z: 13 | for root, _, files in os.walk(basedir): 14 | #NOTE: ignore empty directories 15 | #print root 16 | for fn in files: 17 | absfn = os.path.join(root, fn) 18 | zfn = absfn[len(basedir)+len(os.sep):] #XXX: relative path 19 | z.write(absfn, zfn) -------------------------------------------------------------------------------- /BBoxTester/logconfig.py: -------------------------------------------------------------------------------- 1 | import os 2 | import json 3 | import logging.config 4 | import inspect 5 | 6 | def setup_logging( 7 | default_path='./config/logconfig.json', 8 | default_level=logging.INFO, 9 | env_key='LOG_CFG' 10 | ): 11 | """Setup logging configuration 12 | 13 | """ 14 | path = default_path 15 | value = os.getenv(env_key, None) 16 | if value: 17 | path = value 18 | if os.path.exists(path): 19 | with open(path, 'rt') as f: 20 | config = json.load(f) 21 | logging.config.dictConfig(config) 22 | else: 23 | logging.basicConfig(level=default_level) 24 | 25 | def logFuncName(): 26 | logger.debug("Function called: [%s] from [%s]" % (inspect.currentframe().f_back.f_code.co_name, inspect.currentframe().f_back.f_back.f_code.co_name)) 27 | 28 | setup_logging() 29 | logger=logging.getLogger("console") -------------------------------------------------------------------------------- /BBoxTester_Instr_Sources/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | BBTester 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/dex2jar.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.v3.Main" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-dex-dump.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.util.Dump" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar2dex.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.Jar2Dex" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-apk-sign.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.ApkSign" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-asm-verify.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.AsmVerify" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-dex2jar.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.Dex2jarCmd" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar-remap.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.JarRemap" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-dex-asmifier.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.util.ASMifierFileV" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-init-deobf.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.DeObfInitCmd" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar-access.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.JarAccessCmd" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar2jasmin.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.Jar2Jasmin" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jasmin2jar.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.Jasmin2Jar" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-decrpyt-string.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM 4 | REM dex2jar - Tools to work with android .dex and java .class files 5 | REM Copyright (c) 2009-2012 Panxiaobo 6 | REM 7 | REM Licensed under the Apache License, Version 2.0 (the "License"); 8 | REM you may not use this file except in compliance with the License. 9 | REM You may obtain a copy of the License at 10 | REM 11 | REM http://www.apache.org/licenses/LICENSE-2.0 12 | REM 13 | REM Unless required by applicable law or agreed to in writing, software 14 | REM distributed under the License is distributed on an "AS IS" BASIS, 15 | REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | REM See the License for the specific language governing permissions and 17 | REM limitations under the License. 18 | REM 19 | 20 | set CLASSPATH= 21 | FOR %%i IN ("%~dp0lib\*.jar") DO CALL "%~dp0setclasspath.bat" "%%i" 22 | 23 | java -Xms512m -Xmx1024m -cp %CLASSPATH% "com.googlecode.dex2jar.tools.DecryptStringCmd" %* 24 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/dex2jar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.v3.Main" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-dex-dump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.util.Dump" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-apk-sign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.ApkSign" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-dex2jar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.Dex2jarCmd" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar-remap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.JarRemap" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar2dex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.Jar2Dex" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-asm-verify.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.AsmVerify" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-init-deobf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.DeObfInitCmd" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar-access.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.JarAccessCmd" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jar2jasmin.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.Jar2Jasmin" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-jasmin2jar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.Jasmin2Jar" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-dex-asmifier.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.util.ASMifierFileV" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/d2j-decrpyt-string.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # dex2jar - Tools to work with android .dex and java .class files 5 | # Copyright (c) 2009-2012 Panxiaobo 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | # copy from $Tomcat/bin/startup.sh 21 | # resolve links - $0 may be a softlink 22 | PRG="$0" 23 | while [ -h "$PRG" ] ; do 24 | ls=`ls -ld "$PRG"` 25 | link=`expr "$ls" : '.*-> \(.*\)$'` 26 | if expr "$link" : '/.*' > /dev/null; then 27 | PRG="$link" 28 | else 29 | PRG=`dirname "$PRG"`/"$link" 30 | fi 31 | done 32 | PRGDIR=`dirname "$PRG"` 33 | # 34 | 35 | _classpath="." 36 | for k in "$PRGDIR"/lib/*.jar 37 | do 38 | _classpath="${_classpath}:${k}" 39 | done 40 | java -Xms512m -Xmx1024m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.DecryptStringCmd" "$@" 41 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/com/vladium/emma/data/merge_usage.res: -------------------------------------------------------------------------------- 1 | 2 | 'in', 'input': 3 | required, mergeable, values: 1, 4 | '', 5 | "list of meta/coverage data files"; 6 | 7 | 'out', 'outfile': 8 | optional, values: 1, 9 | '', 10 | "merged data output file (defaults to 'coverage.es')"; 11 | 12 | 'p', 'props', 'properties': 13 | optional, values: 1, 14 | '', 15 | "properties override file"; 16 | 17 | 'D': 18 | optional, mergeable, detailedonly, pattern, values: 1, 19 | '', 20 | "generic property override"; 21 | 22 | 'exit': 23 | optional, detailedonly, values: 0, 24 | "use System.exit() on termination"; 25 | 26 | 'verbose': 27 | optional, detailedonly, values: 0, 28 | excludes {'silent', 'quiet', 'debug'}, 29 | "verbose output operation"; 30 | 31 | 'quiet': 32 | optional, detailedonly, values: 0, 33 | excludes {'silent', 'verbose', 'debug'}, 34 | "quiet operation (ignore all but warnings and severe errors)"; 35 | 36 | 'silent': 37 | optional, detailedonly, values: 0, 38 | excludes {'quiet', 'verbose', 'debug'}, 39 | "extra-quiet operation (ignore all but severe errors)"; 40 | 41 | 'debug', 'loglevel': 42 | optional, detailedonly, values: ?, 43 | '[]', 44 | excludes {'verbose', 'quiet', 'silent'}, 45 | "debug tracing level"; 46 | 47 | 'debugcls': 48 | optional, detailedonly, values: 1, 49 | '', 50 | "class mask for debug tracing"; 51 | 52 | 53 | -------------------------------------------------------------------------------- /CITATION.cff: -------------------------------------------------------------------------------- 1 | title: BBoxTester 2 | abstract: Tool to measure code coverage of Android applications when their source code is not available. 3 | authors: 4 | - family-names: Zhauniarovich 5 | given-names: Yury 6 | orcid: "https://orcid.org/0000-0001-9116-0728" 7 | cff-version: 1.2.0 8 | date-released: "2015-06-11" 9 | identifiers: 10 | - type: url 11 | value: "https://github.com/zyrikby/BBoxTester/tree/fa7684f8094c6523e1b69d8ac15796562e8a940c" 12 | description: Latest version 13 | keywords: 14 | - research 15 | - Android 16 | - "black-box" 17 | - "code coverage" 18 | license: Apache-2.0 19 | message: If you use this software, please cite it using these metadata. 20 | repository-code: "https://github.com/zyrikby/BBoxTester" 21 | preferred-citation: 22 | title: "Towards Black Box Testing of Android Apps" 23 | type: conference-paper 24 | authors: 25 | - family-names: "Zhauniarovich" 26 | given-names: "Yury" 27 | - family-names: "Philippov" 28 | given-names: "Anton" 29 | - family-names: "Gadyatskaya" 30 | given-names: "Olga" 31 | - family-names: "Crispo" 32 | given-names: "Bruno" 33 | - family-names: "Massacci" 34 | given-names: "Fabio" 35 | collection-title: "10th International Conference on Availability, Reliability and Security" 36 | collection-type: "proceedings" 37 | conference: 38 | name: "ARES" 39 | doi: "10.1109/ARES.2015.70" 40 | start: 501 # First page number 41 | end: 510 # Last page number 42 | year: 2015 43 | -------------------------------------------------------------------------------- /BBoxTester/utils/apk_utils.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Oct 13, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import os 7 | 8 | 9 | def checkInputApkFile(inputPath): 10 | if not inputPath: 11 | return (False, "File is not provided!") 12 | if not os.path.isfile(inputPath): 13 | return (False, "Provided path is not pointing on a file!") 14 | 15 | fileType = is_android(inputPath) 16 | if fileType != "APK": 17 | return (False, "Provided file is not an apk file!") 18 | 19 | return (True, None) 20 | 21 | 22 | def is_android(filename) : 23 | """Return the type of the file 24 | 25 | @param filename : the filename 26 | @rtype : "APK", "DEX", "ELF", None 27 | """ 28 | if not filename: 29 | return None 30 | 31 | with open(filename, "r") as fd: 32 | f_bytes = fd.read(7) 33 | 34 | val = is_android_raw(f_bytes) 35 | return val 36 | 37 | 38 | def is_android_raw(raw): 39 | val = None 40 | f_bytes = raw[:7] 41 | 42 | if f_bytes[0:2] == "PK": 43 | val = "APK" 44 | elif f_bytes[0:3] == "dex": 45 | val = "DEX" 46 | elif f_bytes[0:3] == "dey": 47 | val = "DEY" 48 | elif f_bytes[0:7] == "\x7fELF\x01\x01\x01": 49 | val = "ELF" 50 | elif f_bytes[0:4] == "\x03\x00\x08\x00": 51 | val = "AXML" 52 | elif f_bytes[0:4] == "\x02\x00\x0C\x00": 53 | val = "ARSC" 54 | 55 | return val 56 | 57 | def is_valid_android_raw(raw) : 58 | return raw.find("classes.dex") != -1 -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/com/vladium/emma/report/report_usage.res: -------------------------------------------------------------------------------- 1 | 2 | 'in', 'input': 3 | required, mergeable, values: 1, 4 | '', 5 | "list of meta/coverage data files"; 6 | 7 | 'r', 'report': 8 | required, mergeable, values: 1, 9 | '', 10 | "coverage report type list"; 11 | 12 | 'sp', 'sourcepath': 13 | optional, mergeable, values: 1, 14 | '', 15 | "Java source path for generating reports"; 16 | 17 | 'p', 'props', 'properties': 18 | optional, values: 1, 19 | '', 20 | "properties override file"; 21 | 22 | 'D': 23 | optional, mergeable, detailedonly, pattern, values: 1, 24 | '', 25 | "generic property override"; 26 | 27 | 'exit': 28 | optional, detailedonly, values: 0, 29 | "use System.exit() on termination"; 30 | 31 | 'verbose': 32 | optional, detailedonly, values: 0, 33 | excludes {'silent', 'quiet', 'debug'}, 34 | "verbose output operation"; 35 | 36 | 'quiet': 37 | optional, detailedonly, values: 0, 38 | excludes {'silent', 'verbose', 'debug'}, 39 | "quiet operation (ignore all but warnings and severe errors)"; 40 | 41 | 'silent': 42 | optional, detailedonly, values: 0, 43 | excludes {'quiet', 'verbose', 'debug'}, 44 | "extra-quiet operation (ignore all but severe errors)"; 45 | 46 | 'debug', 'loglevel': 47 | optional, detailedonly, values: ?, 48 | '[]', 49 | excludes {'verbose', 'quiet', 'silent'}, 50 | "debug tracing level"; 51 | 52 | 'debugcls': 53 | optional, detailedonly, values: 1, 54 | '', 55 | "class mask for debug tracing"; 56 | 57 | 58 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/com/vladium/emma/rt/RTExitHook.closure: -------------------------------------------------------------------------------- 1 | #this file is auto-generated, do not edit 2 | #Fri Feb 08 12:18:59 PST 2008 3 | closure=com.vladium.util.ResourceLoader,com.vladium.emma.rt.RTCoverageDataPersister,com.vladium.util.IntSet,com.vladium.logging.Logger,com.vladium.util.IntSet$Entry,com.vladium.emma.data.DataFactory$UCFileOutputStream,com.vladium.emma.rt.RTExitHook,com.vladium.util.ClassLoaderResolver$CallerResolver,com.vladium.emma.data.CoverageData,com.vladium.util.ClassLoadContext,com.vladium.emma.data.ClassDescriptor,com.vladium.util.Property$SystemPropertyLookup,com.vladium.util.IConstants,com.vladium.emma.data.IMetaData,com.vladium.emma.data.CoverageOptions,com.vladium.util.ClassLoaderResolver,com.vladium.emma.data.ICoverageData$DataHolder,com.vladium.emma.data.ISessionData,com.vladium.emma.data.DataFactory$UCFileInputStream,com.vladium.emma.data.IMetadataConstants,com.vladium.emma.data.MethodDescriptor,com.vladium.util.Property$SystemRedirectsLookup,com.vladium.emma.data.MetaData,com.vladium.logging.Logger$1,com.vladium.util.IClassLoadStrategy,com.vladium.emma.data.DataFactory$RandomAccessFileInputStream,com.vladium.emma.data.IMergeable,com.vladium.util.IntObjectMap,com.vladium.util.Property,com.vladium.logging.Logger$ThreadLocalStack,com.vladium.emma.data.DataFactory,com.vladium.emma.data.ICoverageData,com.vladium.emma.data.DataFactory$RandomAccessFileOutputStream,com.vladium.util.IntObjectMap$Entry,com.vladium.util.XProperties,com.vladium.util.ClassLoaderResolver$DefaultClassLoadStrategy,com.vladium.logging.ILogLevels,com.vladium.util.ClassLoaderResolver$1,com.vladium.util.Property$FilePropertyLookup 4 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/asm-LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | ASM: a very small and fast Java bytecode manipulation framework 3 | Copyright (c) 2000-2005 INRIA, France Telecom 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions 8 | are met: 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 3. Neither the name of the copyright holders nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 | THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/license-jasmin.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996-2004, Jon Meyer 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are permitted provided 6 | * that the following conditions are met: 7 | * 8 | * Redistributions of source code must retain the above copyright notice, this list of conditions 9 | * and the following disclaimer. 10 | * 11 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions 12 | * and the following disclaimer in the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * Neither the name of the Jon Meyer nor the names of its contributors may be used to 16 | * endorse or promote products derived from this software without specific prior written permission. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 24 | * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * Jasmin was written by Jon Meyer, www.cybergrain.com 28 | * The Jasmin website is jasmin.sourceforge.net. 29 | */ 30 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/com/vladium/emma/instr/instr_usage.res: -------------------------------------------------------------------------------- 1 | 2 | 'ip', 'cp', 'instrpath': 3 | required, mergeable, values: 1, 4 | '', 5 | "instrumentation path"; 6 | 7 | 'd', 'dir', 'outdir': 8 | optional, values: 1, 9 | '', 10 | "instrumentation output directory (required for non-overwrite output modes)"; 11 | 12 | 'out', 'outfile': 13 | optional, values: 1, 14 | '', 15 | "metadata output file (defaults to 'coverage.em')"; 16 | 17 | 'merge': 18 | optional, values: 1, 19 | '(y[es]|n[o])', 20 | "merge metadata into output file, if it exists"; 21 | 22 | 'm', 'outmode': 23 | optional, values: 1, 24 | '(copy|overwrite|fullcopy)', 25 | "output mode (defaults to 'copy')"; 26 | 27 | 'ix', 'filter': 28 | optional, mergeable, values: 1, 29 | '', 30 | "coverage inclusion/exclusion patterns {?,*}"; 31 | 32 | 'p', 'props', 'properties': 33 | optional, values: 1, 34 | '', 35 | "properties override file"; 36 | 37 | 'D': 38 | optional, mergeable, detailedonly, pattern, values: 1, 39 | '', 40 | "generic property override"; 41 | 42 | 'exit': 43 | optional, detailedonly, values: 0, 44 | "use System.exit() on termination"; 45 | 46 | 'verbose': 47 | optional, detailedonly, values: 0, 48 | excludes {'silent', 'quiet', 'debug'}, 49 | "verbose output operation"; 50 | 51 | 'quiet': 52 | optional, detailedonly, values: 0, 53 | excludes {'silent', 'verbose', 'debug'}, 54 | "quiet operation (ignore all but warnings and severe errors)"; 55 | 56 | 'silent': 57 | optional, detailedonly, values: 0, 58 | excludes {'quiet', 'verbose', 'debug'}, 59 | "extra-quiet operation (ignore all but severe errors)"; 60 | 61 | 'debug', 'loglevel': 62 | optional, detailedonly, values: ?, 63 | '[]', 64 | excludes {'verbose', 'quiet', 'silent'}, 65 | "debug tracing level"; 66 | 67 | 'debugcls': 68 | optional, detailedonly, values: 1, 69 | '', 70 | "class mask for debug tracing"; 71 | 72 | 73 | -------------------------------------------------------------------------------- /BBoxTester/config/logconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "disable_existing_loggers": false, 4 | "formatters": { 5 | "simple": { 6 | "format": "%(asctime)s - %(filename)s - %(levelname)s - %(message)s" 7 | } 8 | }, 9 | 10 | "handlers": { 11 | "console": { 12 | "class": "logging.StreamHandler", 13 | "level": "DEBUG", 14 | "formatter": "simple", 15 | "stream": "ext://sys.stdout" 16 | }, 17 | 18 | "info_file_handler": { 19 | "class": "logging.handlers.RotatingFileHandler", 20 | "level": "INFO", 21 | "formatter": "simple", 22 | "filename": "log/info.log", 23 | "maxBytes": "10485760", 24 | "backupCount": "20", 25 | "encoding": "utf8" 26 | }, 27 | 28 | "error_file_handler": { 29 | "class": "logging.handlers.RotatingFileHandler", 30 | "level": "ERROR", 31 | "formatter": "simple", 32 | "filename": "log/errors.log", 33 | "maxBytes": "10485760", 34 | "backupCount": "20", 35 | "encoding": "utf8" 36 | }, 37 | 38 | "log_file_handler": { 39 | "class": "logging.handlers.RotatingFileHandler", 40 | "level": "DEBUG", 41 | "formatter": "simple", 42 | "filename": "log/log.log", 43 | "maxBytes": "10485760", 44 | "backupCount": "20", 45 | "encoding": "utf8" 46 | } 47 | }, 48 | 49 | "loggers": { 50 | "console": { 51 | "level": "DEBUG", 52 | "handlers": ["console"], 53 | "propagate": false 54 | }, 55 | "default": { 56 | "level": "INFO", 57 | "handlers": ["console", "log_file_handler"], 58 | "propagate": false 59 | } 60 | }, 61 | 62 | "root": { 63 | "level": "INFO", 64 | "handlers": ["console", "info_file_handler", "error_file_handler"] 65 | } 66 | } -------------------------------------------------------------------------------- /BBoxTester/interfaces/dx_interface.py: -------------------------------------------------------------------------------- 1 | import os 2 | import commander 3 | 4 | 5 | class DxInterface: 6 | def __init__(self, javaPath = "java", javaOpts = "-Xms512m -Xmx1024m", pathDx = "./auxiliary/dx/", jarDx="dx.jar"): 7 | self.javaPath = javaPath 8 | self.javaOpts = javaOpts 9 | self.pathDx = pathDx 10 | self.jarDx = jarDx 11 | 12 | 13 | def _previewDexCmd(self, action, options): 14 | path = os.path.join(self.pathDx, self.jarDx) 15 | cmd = "%s %s %s" % (path, action, options) 16 | return cmd 17 | 18 | 19 | def _interpResultsDexCmd(self, returnCode, outputStr): 20 | retCode = "Return code is: %s" % returnCode 21 | #NOTE: later we can select different routines to process different errors 22 | if returnCode: 23 | output = "%s\n%s" % (retCode, outputStr) 24 | return (False, output) 25 | return (True, None) 26 | 27 | 28 | def dex(self, inFiles, output, noLocals=False): 29 | """ 30 | There are a number of other options of dx tool. However, here we do not 31 | use them, because we do not need them 32 | """ 33 | options = "" 34 | if noLocals: 35 | options += " --no-locals" 36 | 37 | # TODO: dx does not create folder. Thus, if you specify the folder that do not exist 38 | # dx tool will not create it and you will receive and error. This can be corrected by 39 | # adding additional code for folder creation 40 | options += " --output='" + output + "'" 41 | 42 | options += " " 43 | for inFile in inFiles: 44 | options += "'" + inFile + "' " 45 | 46 | dexCmd = self._previewDexCmd("--dex", options) 47 | (result_code, outputStr) = self._runDxCommand(dexCmd) 48 | 49 | return self._interpResultsDexCmd(result_code, outputStr) 50 | 51 | 52 | def _runDxCommand(self, commandString): 53 | cmd = "'%s' %s -jar %s" % (self.javaPath, self.javaOpts, commandString) 54 | return commander.runOnce(cmd) 55 | 56 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/com/vladium/emma/exceptions.properties: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # this is loaded as a resource bundle by com.vladium.emma.* exceptions 3 | # ----------------------------------------------------------------------------- 4 | 5 | UNEXPECTED_FAILURE: \ 6 | unexpected failure {0}, please submit a bug report to: ''{1}'' 7 | 8 | INVALID_PARAMETER_VALUE: \ 9 | value ''{1}'' is not valid for parameter ''{0}'' 10 | 11 | REQUIRED_PARAMETER_MISSING: \ 12 | required parameter [{0}] is not specified 13 | 14 | INVALID_COLUMN_NAME: \ 15 | invalid report column name [{0}] 16 | 17 | SECURITY_RESTRICTION: \ 18 | current security settings are too restrictive for {0} to operate 19 | 20 | MAIN_CLASS_BAD_DELEGATION: \ 21 | the application class [{1}] that you are trying to launch was not loaded \ 22 | by {0} instrumenting classloader, possibly because is was not listed in \ 23 | the '-cp' option: {0} will not be able to collect any coverage data. The \ 24 | actual classloader was: {2} 25 | 26 | MAIN_CLASS_NOT_FOUND: \ 27 | application class [{0}] could not be loaded 28 | 29 | MAIN_CLASS_LOAD_FAILURE: \ 30 | application class [{0}] could not be loaded and initialized, most likely due \ 31 | to static initializer failure: {1} 32 | 33 | MAIN_METHOD_NOT_FOUND: \ 34 | application class [{0}] does not have a runnable public main() method 35 | 36 | MAIN_METHOD_FAILURE: \ 37 | {0}.main() method failure: {1} 38 | 39 | REPORT_GEN_FAILURE: \ 40 | failed to generate report 41 | 42 | REPORT_IO_FAILURE: \ 43 | exception occurred while writing report file(s): 44 | 45 | CLASS_STAMP_MISMATCH: \ 46 | runtime version of class [{0}] in the coverage data is not consistent \ 47 | with the version of this class in the metadata, possibly because stale \ 48 | metadata is being used for report generation. 49 | 50 | OUT_MKDIR_FAILURE: \ 51 | output directory [{0}] could not be created 52 | 53 | INSTR_IO_FAILURE: \ 54 | exception occurred while writing instrumented file(s): 55 | 56 | OUT_IO_FAILURE: \ 57 | exception occurred while writing output file [{0}]: 58 | 59 | ARGS_IO_FAILURE: \ 60 | exception while processing settings: 61 | 62 | # ----------------------------------------------------------------------------- 63 | # end of file 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Towards Black Box Testing of Android Apps 2 | 3 | ## Description 4 | BBoxTester is a framework able to generate code coverage reports and produce 5 | uniform coverage metrics in testing of the Android applications when the source 6 | code of them is not available. 7 | 8 | This work has been done at the University of Trento. 9 | 10 | 11 | 12 | 13 | ## Publication 14 | The results of our research will be presented at the 2nd International Workshop 15 | on Software Assurance (SAW '15) to be held in conjunction with the 16 | 10th International Conference on Availability, Reliability and Security 17 | 18 | Currently, 19 | please use the following bibtex reference to cite our paper: 20 | 21 | ``` 22 | @inproceedings{BBoxTester_Zhauniarovich2015, 23 | author={Zhauniarovich, Yury and Philippov, Anton and Gadyatskaya, Olga and Crispo, Bruno and Massacci, Fabio}, 24 | title={Towards Black Box Testing of Android Apps}, 25 | booktitle={2015 Tenth International Conference on Availability, Reliability and Security (ARES)}, 26 | year={2015}, 27 | month={August}, 28 | pages={501-510} 29 | } 30 | 31 | ``` 32 | 33 | 34 | ## Repository Description 35 | BBoxTester folder contains main resources of the application, while 36 | BBoxTester_Instr_Sources directory stores only code for the auxiliary classes 37 | which are required for application operation. 38 | 39 | In BBoxTester folder: 40 | 41 | 1. Scripts main_activity_strategy.py, main_intents_strategy.py and 42 | monkey_run_one_apk.py contain examples we used for experiments. 43 | 2. bboxtester.py shows different options how the tool can be used. 44 | 3. running_strategies.py describes the strategies currently implemented for 45 | the application testing. 46 | 4. bboxcoverage.py contains the main class. 47 | 48 | 49 | 50 | ## Dependencies 51 | 1. [Apktool](https://github.com/iBotPeaches/Apktool) released under Apache-2.0 52 | License. 53 | 2. [dex2jar](https://github.com/pxb1988/dex2jar) released under Apache-2.0 54 | License. 55 | 3. [Emma](http://emma.sourceforge.net/) released under Common Public Lisence. 56 | 4. aapt, dx and zipalign are parts of Android Open Source Project and released under 57 | Apache-2.0 Lisence. 58 | 59 | 60 | 61 | ## License 62 | The tool is distributed under Apache-2.0 license. The citation of the paper is 63 | highly appreciated. 64 | -------------------------------------------------------------------------------- /BBoxTester/interfaces/zipalign_interface.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Oct 1, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import os 7 | from interfaces import commander 8 | 9 | 10 | 11 | class ZipalignInterface: 12 | def __init__(self, dirZipalign="./auxiliary/zipalign", exeZipalign="zipalign"): 13 | self.dirZipalign = dirZipalign 14 | self.exeZipalign = exeZipalign 15 | self.pathToZipalign = os.path.join(self.dirZipalign, self.exeZipalign) 16 | 17 | 18 | 19 | def align(self, inFile, outFile, alignment=4, verbose=True, overwrite=True): 20 | options = "" 21 | if verbose: 22 | options += " -v" 23 | if overwrite: 24 | options += " -f" 25 | 26 | options += " %d '%s' '%s'" % (alignment, inFile, outFile) 27 | cmd = self._previewZipalignCmd(options) 28 | (returnCode, output) = self._runZipalignCommand(cmd) 29 | (successfulRun, cmdOutput) = self._interpretAlignCmdResults(returnCode, output) 30 | return (successfulRun, cmdOutput) 31 | 32 | #TODO: Need to refactor commander.runOnce command and then it is possible 33 | # to add this command because we need to interpret results obtained 34 | # from the stdout 35 | # def isAligned(self, inFile, alignment=4, verbose=True): 36 | # options = "-c" 37 | # if verbose: 38 | # options += " -v" 39 | # 40 | # options += " %d '%s'" % (alignment, inFile) 41 | # cmd = self._previewZipalignCmd(options) 42 | # (returnCode, output) = self._runZipalignCommand(cmd) 43 | # (successfulRun, cmdOutput) = self._interpretCheckAlignmentCmdResults(returnCode, output) 44 | # return (successfulRun, cmdOutput) 45 | 46 | def _previewZipalignCmd(self, options): 47 | zipalignCommand = "'%s' %s" % (self.pathToZipalign, options) 48 | return zipalignCommand 49 | 50 | def _runZipalignCommand(self, cmd): 51 | return commander.runOnce(cmd) 52 | 53 | def _interpretAlignCmdResults(self, returnCode, output): 54 | output = "Return code is: [%s].\nCommand output: %s" % (returnCode, output) 55 | #TODO: later we can select different routines to process different errors 56 | if returnCode: 57 | return (False, output) 58 | return (True, output) 59 | 60 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/com/vladium/emma/run_usage.res: -------------------------------------------------------------------------------- 1 | 2 | 'cp', 'classpath': 3 | optional, mergeable, values: 1, 4 | '', 5 | excludes { 'jar' }, 6 | "load/coverage classpath"; 7 | 8 | 'jar': 9 | optional, values: 0, 10 | excludes { 'cp' }, 11 | "run an executable jar file"; 12 | 13 | 'f', 'fullmetadata': 14 | optional, values: 0, 15 | "consider the entire classpath for coverage {including classes that are never loaded}"; 16 | 17 | 'ix', 'filter': 18 | optional, mergeable, values: 1, 19 | '', 20 | "coverage inclusion/exclusion patterns {?,*}"; 21 | 22 | 'r', 'report': 23 | optional, mergeable, values: 1, 24 | '', 25 | "coverage report type list"; 26 | 27 | 'sp', 'sourcepath': 28 | optional, mergeable, values: 1, 29 | '', 30 | "Java source path for generating reports"; 31 | 32 | 'raw', 'sessiondata': 33 | optional, values: 0, 34 | "dump raw session data file"; 35 | 36 | 'out', 'outfile': 37 | optional, values: 1, 38 | '', 39 | requires { 'raw' }, 40 | "raw session data output file (defaults to 'coverage.es')"; 41 | 42 | 'merge': 43 | optional, values: 1, 44 | '', 45 | requires { 'raw' }, 46 | "merge session data into output file, if it exists"; 47 | 48 | 'p', 'props', 'properties': 49 | optional, values: 1, 50 | '', 51 | "properties override file"; 52 | 53 | 'D': 54 | optional, mergeable, detailedonly, pattern, values: 1, 55 | '', 56 | "generic property override"; 57 | 58 | 'exit': 59 | optional, detailedonly, values: 0, 60 | "use System.exit() on termination"; 61 | 62 | 'verbose': 63 | optional, detailedonly, values: 0, 64 | excludes {'silent', 'quiet', 'debug'}, 65 | "verbose output operation"; 66 | 67 | 'quiet': 68 | optional, detailedonly, values: 0, 69 | excludes {'silent', 'verbose', 'debug'}, 70 | "quiet operation (ignore all but warnings and severe errors)"; 71 | 72 | 'silent': 73 | optional, detailedonly, values: 0, 74 | excludes {'quiet', 'verbose', 'debug'}, 75 | "extra-quiet operation (ignore all but severe errors)"; 76 | 77 | 'debug', 'loglevel': 78 | optional, detailedonly, values: ?, 79 | '[]', 80 | excludes {'verbose', 'quiet', 'silent'}, 81 | "debug tracing level"; 82 | 83 | 'debugcls': 84 | optional, detailedonly, values: 1, 85 | '', 86 | "class mask for debug tracing"; 87 | 88 | 89 | -------------------------------------------------------------------------------- /BBoxTester/bbox_core/bboxreporter.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Oct 1, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | 7 | import os 8 | 9 | from interfaces.emma_interface import EmmaInterface, EMMA_REPORT 10 | 11 | 12 | class BBoxReporter: 13 | def __init__(self, config): 14 | self.metaFiles = [] 15 | self.reportFiles = [] 16 | self.config = config 17 | 18 | def addMetaFile(self, pathToMetaFile): 19 | if not os.path.isfile(pathToMetaFile): 20 | raise NotFileException("The path [%s] is not a file!" 21 | % pathToMetaFile) 22 | self.metaFiles.append(pathToMetaFile) 23 | 24 | def addReportFile(self, pathToReportFile): 25 | if not os.path.isfile(pathToReportFile): 26 | raise NotFileException("The path [%s] is not a file!" 27 | % pathToReportFile) 28 | self.reportFiles.append(pathToReportFile) 29 | 30 | def cleanMetaFiles(self): 31 | self.metaFiles = [] 32 | 33 | def cleanReportFiles(self): 34 | self.reportFiles = [] 35 | 36 | def generateEmmaReport(self, where, reportName, emmaReportType=EMMA_REPORT.HTML): 37 | emma = EmmaInterface(javaPath = self.config.getEmmaJavaPath(), 38 | javaOpts = self.config.getEmmaJavaOpts(), 39 | pathEmma = self.config.getEmmaDir(), 40 | jarEmma = self.config.getEmmaJar(), 41 | jarEmmaDevice = self.config.getEmmaDeviceJar()) 42 | 43 | if not (self.metaFiles and self.reportFiles): 44 | raise ReportGenerationError("A metafile or a report file is absent.\ 45 | Cannot generate report without one of these files!") 46 | 47 | inputs = [] 48 | inputs.extend(self.metaFiles) 49 | inputs.extend(self.reportFiles) 50 | 51 | #TODO: check the output 52 | emma.reportToDirWithName(inputs=inputs, toDir=where, mainFileName=reportName, report=emmaReportType) 53 | 54 | 55 | class MsgException(Exception): 56 | ''' 57 | Generic exception with an optional string msg. 58 | ''' 59 | def __init__(self, msg=""): 60 | self.msg = msg 61 | 62 | class NotFileException(MsgException): 63 | ''' 64 | The provided path does not point to the file. 65 | ''' 66 | 67 | class ReportGenerationError(object): 68 | ''' 69 | The coverage report cannot be generated. 70 | ''' 71 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/emma/resources/emma_default.properties: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------- 2 | # *************** DO NOT EDIT THIS FILE *********************** 3 | # 4 | # for user-editable property overrides use one of these options: 5 | # 6 | # (1) option-specific command line overrides, e.g. 7 | # -Dreport.txt.out.file=coverage.txt 8 | # 9 | # (2) '-p ' command line option, 10 | # 11 | # (3) 'emma.properties' resource placed somewhere in the classpath 12 | # (e.g., in \classes directory -- note that it does 13 | # not exist by default), 14 | # 15 | # (4) '-Demma.*' JVM options, e.g. 16 | # -Demma.report.txt.out.file=coverage.txt 17 | # 18 | # (5) 'emma.properties' JVM option pointing to a properties file 19 | # -Demma.properties=./myproperties.txt 20 | # ------------------------------------------------------------- 21 | 22 | # ------------------------------------------------------------- 23 | # logging properties: 24 | 25 | verbosity.level: info 26 | 27 | # classloading properties: 28 | 29 | #clsload.forced_delegation_filter: 30 | #clsload.through_delegation_filter: -* 31 | 32 | # ------------------------------------------------------------- 33 | 34 | # instrumentation properties: 35 | 36 | instr.exclude_synthetic_methods: true 37 | instr.exclude_bridge_methods: true 38 | instr.do_suid_compensation: true 39 | 40 | # ------------------------------------------------------------- 41 | 42 | # apprunner session data output properties: 43 | 44 | session.out.file: coverage.es 45 | session.out.merge: true 46 | 47 | # ------------------------------------------------------------- 48 | 49 | # runtime coverage data output properties: 50 | 51 | coverage.out.file: /sdcard/coverage.ec 52 | coverage.out.merge: true 53 | 54 | # ------------------------------------------------------------- 55 | 56 | # instr metadata output properties: 57 | 58 | metadata.out.file: coverage.em 59 | metadata.out.merge: true 60 | 61 | # ------------------------------------------------------------- 62 | 63 | # common report defaults: 64 | 65 | report.units: instr 66 | report.depth: method 67 | report.columns: name,class,method,block,line 68 | report.sort: +block,+name,+method,+class 69 | report.metrics: method:70,block:80,line:80,class:100 70 | 71 | # ------------------------------------------------------------- 72 | # txt report properties: 73 | 74 | report.txt.depth: all 75 | report.txt.columns: class,method,block,line,name 76 | report.txt.out.file: coverage.txt 77 | 78 | # ------------------------------------------------------------- 79 | # html report properties: 80 | 81 | #report.html.out.dir: coverage 82 | report.html.out.file: coverage/index.html 83 | report.html.out.encoding: ISO-8859-1 84 | 85 | # ------------------------------------------------------------- 86 | # xml report properties: 87 | 88 | report.xml.out.file: coverage.xml 89 | report.xml.out.encoding: UTF-8 90 | # ------------------------------------------------------------- 91 | # end of file 92 | -------------------------------------------------------------------------------- /BBoxTester/bboxtester.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Jul 2, 2014 3 | 4 | @author: yury 5 | ''' 6 | 7 | from bboxcoverage import BBoxCoverage 8 | from interfaces.adb_interface import * 9 | from interfaces.apktool_interface import * 10 | from interfaces.dex2jar_interface import * 11 | from interfaces.dx_interface import * 12 | from interfaces.emma_interface import * 13 | from utils.android_manifest import * 14 | 15 | 16 | 17 | def main(): 18 | bboxcoverage = BBoxCoverage() 19 | #bboxcoverage.instrumentApkForCoverage(pathToOrigApk="/home/yury/TMP/BBoxTester/Notepad.apk", resultsDir="/home/yury/TMP/BBoxTester/results/", tmpDir="/home/yury/TMP/BBoxTester/tmp", overwriteExisting=True, removeApkTmpDirAfterInstr=False, copyApkToRes=True) 20 | #bboxcoverage.installApkOnDevice() 21 | #bboxcoverage.startTesting() 22 | #time.sleep(30) 23 | #localReport = bboxcoverage.stopTesting() 24 | #bboxcoverage.generateReport([localReport], EMMA_REPORT.XML) 25 | 26 | #bboxcoverage.instrumentApkForCoverage(pathToOrigApk="/home/yury/PROJECTS/BBOXTESTING2/app/com.markuspage.android.atimetracker.apk", resultsDir="/home/yury/PROJECTS/BBOXTESTING2/app/results", tmpDir="/home/yury/TMP/BBoxTester/tmp", removeApkTmpDirAfterInstr=False, copyApkToRes=True) 27 | #bboxcoverage.installApkOnDevice() 28 | #bboxcoverage.startTesting() 29 | #time.sleep(30) 30 | #localReport = bboxcoverage.stopTesting() 31 | #bboxcoverage.generateReport([localReport], EMMA_REPORT.XML) 32 | 33 | # bboxcoverage.instrumentApkForCoverage(pathToOrigApk="/home/yury/PROJECTS/BBOXTESTING2/app/com.markuspage.android.atimetracker_17.apk", resultsDir="/home/yury/PROJECTS/BBOXTESTING2/app/results_packed", tmpDir="/home/yury/TMP/BBoxTester/tmp", removeApkTmpDirAfterInstr=False, copyApkToRes=True) 34 | # bboxcoverage.installApkOnDevice() 35 | # bboxcoverage.startTesting() 36 | # time.sleep(30) 37 | # localReport = bboxcoverage.stopTesting() 38 | 39 | bboxcoverage._signApk(bboxcoverage.bboxInstrumenter, "/home/yury/PROJECTS/BBOXTESTING2/app/com.markuspage.android.atimetracker_17_aligned.apk", "/home/yury/PROJECTS/BBOXTESTING2/app/com.markuspage.android.atimetracker_17_aligned_signed.apk") 40 | bboxcoverage.initAlreadyInstrApkEnv(pathToInstrApk="/home/yury/PROJECTS/BBOXTESTING2/app/com.markuspage.android.atimetracker_17_aligned_signed.apk", resultsDir="/home/yury/PROJECTS/BBOXTESTING2/app/results_packed/com.markuspage.android.atimetracker_17/") 41 | bboxcoverage.installApkOnDevice() 42 | bboxcoverage.startTesting() 43 | time.sleep(30) 44 | localReport = bboxcoverage.stopTesting() 45 | 46 | # bboxcoverage2 = BBoxCoverage() 47 | # bboxcoverage2.initAlreadyInstrApkEnv(pathToInstrApk="/home/yury/TMP/BBoxTester/Notepad_instr_final.apk", resultsDir="/home/yury/TMP/BBoxTester/results/Notepad") 48 | # bboxcoverage2.startTesting() 49 | # time.sleep(20) 50 | # lRep = bboxcoverage2.stopTesting() 51 | # bboxcoverage2.generateReport([lRep], EMMA_REPORT.XML) 52 | 53 | 54 | if __name__ == '__main__': 55 | main() -------------------------------------------------------------------------------- /BBoxTester/interfaces/commander.py: -------------------------------------------------------------------------------- 1 | import os 2 | import signal 3 | import subprocess 4 | import threading 5 | import time 6 | 7 | from bbox_core.general_exceptions import MsgException 8 | from logconfig import logger 9 | 10 | 11 | TIMEOUT_ERROR_VALUE = 1111 12 | 13 | def runOnce(cmd, timeout_time=None, return_output=True, stdin_input=None): 14 | """Spawns a subprocess to run the given shell command. 15 | 16 | Args: 17 | cmd: shell command to run 18 | timeout_time: time in seconds to wait for command to run before aborting. 19 | return_output: if True return output of command as string. Otherwise, 20 | direct output of command to stdout. 21 | stdin_input: data to feed to stdin 22 | Returns: 23 | output of command 24 | """ 25 | 26 | start_time = time.time() 27 | so = [] 28 | pid = [] 29 | return_code = [] # hack to store results from a nested function 30 | 31 | #TODO: Need to refactor this part. Subprocess need to return separate output 32 | # for standard output and standard error. 33 | def Run(): 34 | if return_output: 35 | output_dest = subprocess.PIPE 36 | else: 37 | # None means direct to stdout 38 | output_dest = None 39 | if stdin_input: 40 | stdin_dest = subprocess.PIPE 41 | else: 42 | stdin_dest = None 43 | 44 | pipe = subprocess.Popen( 45 | cmd, 46 | executable='/bin/bash', 47 | stdin=stdin_dest, 48 | stdout=output_dest, 49 | stderr=subprocess.STDOUT, 50 | shell=True) 51 | pid.append(pipe.pid) 52 | try: 53 | output = pipe.communicate(input=stdin_input)[0] 54 | if output is not None and len(output) > 0: 55 | so.append(output) 56 | except OSError, e: 57 | so.append("ERROR: OSError!") 58 | return_code.append(pipe.returncode) 59 | 60 | logger.debug("[COMMANDER] About to run cmd: %s" % cmd) 61 | 62 | t = threading.Thread(target=Run) 63 | t.start() 64 | 65 | break_loop = False 66 | while not break_loop: 67 | if not t.isAlive(): 68 | break_loop = True 69 | 70 | # Check the timeout 71 | if (not break_loop and timeout_time is not None 72 | and time.time() > start_time + timeout_time): 73 | try: 74 | os.kill(pid[0], signal.SIGKILL) 75 | except OSError: 76 | # process already dead. No action required. 77 | pass 78 | so.append("ERROR: Timeout!") 79 | return_code[0] = TIMEOUT_ERROR_VALUE 80 | if not break_loop: 81 | time.sleep(0.1) 82 | 83 | t.join() 84 | output = "".join(so) 85 | 86 | logger.debug("[COMMANDER] Finished! Return code: %d, Output: %s" % (return_code[0], output)) 87 | #TODO: Add throw timeout exception 88 | return (return_code[0], output) 89 | 90 | 91 | #Exceptions 92 | class TimeoutException(MsgException): 93 | ''' 94 | Timeout exception. 95 | ''' 96 | -------------------------------------------------------------------------------- /BBoxTester/utils/state_machine.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Oct 14, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | from bbox_core.bboxreporter import MsgException 7 | 8 | class StateMachine: 9 | ''' 10 | A simple state machine class. 11 | ''' 12 | def __init__(self, states = []): 13 | ''' 14 | Constructor. 15 | 16 | Args: 17 | :param states: list of possible states and allowed transitions 18 | ''' 19 | ''' 20 | Constructor 21 | ''' 22 | self._states = states 23 | self.currentState = None 24 | 25 | def start(self, startState): 26 | ''' 27 | Start the state machine from a predifined state 28 | 29 | Args: 30 | :param startState: state from which to start machine. 31 | ''' 32 | if not startState or (startState not in [x[0] for x in self._states]): 33 | raise ValueError("Not a valid start state") 34 | self.currentState = startState 35 | 36 | def stop(self): 37 | ''' 38 | Stops the state machine 39 | ''' 40 | self.currentState = None 41 | 42 | 43 | def isTransitionPossible(self, toState): 44 | if not self.currentState: 45 | raise TransitionNotPossible("StateMachine not Started - cannot process request!") 46 | 47 | if not toState: 48 | return False 49 | 50 | # get a list of transitions which are valid 51 | nextStates = [x[1] for x in self._states if x[0] == self.currentState] 52 | if not nextStates or (toState not in nextStates): 53 | return False 54 | return True 55 | 56 | # def isTransitionFromCurrentPossible(self, toState): 57 | # if not self.currentState: 58 | # raise TransitionNotPossible("StateMachine not Started - cannot process request!") 59 | # 60 | # if not toState: 61 | # raise ValueError("Not a valid start state") 62 | # 63 | # prevStates = [x[0] for x in self._states if x[1] == toState] 64 | # if not prevStates or (self.currentState not in prevStates): 65 | # return False 66 | # return True 67 | 68 | def transitToState(self, toState): 69 | if not self.currentState: 70 | raise TransitionNotPossible("StateMachine not Started - cannot process request!") 71 | 72 | if not toState: 73 | raise TransitionNotPossible("Cannot switch to undefined state!") 74 | 75 | # get a list of transitions which are valid 76 | nextStates = [x[1] for x in self._states if x[0] == self.currentState] 77 | if not nextStates or (toState not in nextStates): 78 | raise TransitionNotPossible("Transition from [%s] to [%s] is not allowed!" % (str(self.currentState), str(toState))) 79 | 80 | if (toState == self.currentState): 81 | return False 82 | 83 | self.currentState = toState 84 | return True 85 | 86 | def getCurrentState(self): 87 | return self.currentState 88 | 89 | 90 | 91 | class TransitionNotPossible(MsgException): 92 | ''' 93 | State transition is not possible! 94 | ''' 95 | -------------------------------------------------------------------------------- /BBoxTester/monkey_run_one_apk.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Dec 2, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | 7 | import os, sys, time 8 | from interfaces.adb_interface import AdbInterface 9 | from bboxcoverage import BBoxCoverage 10 | from running_strategies import MonkeyStrategy 11 | from utils import auxiliary_utils 12 | 13 | INSTRUMENTED_APK_PATH = "/home/yury/TMP/BBoxTester/errors_exploration/Dictionary-4/Dictionary-4_aligned.apk" 14 | EVENTS_COUNT = 10000 15 | SEED = 3 16 | THROTTLE = 50 17 | 18 | 19 | 20 | def getExecutionDevice(): 21 | ''' 22 | This method allows a user to select a device that is used to for further 23 | analysis. 24 | ''' 25 | dev_list = AdbInterface.getDeviceSerialsList() 26 | devNum = len(dev_list) 27 | 28 | if devNum <= 0: 29 | print "No device has been detected! Connect your device and restart the application!" 30 | return 31 | 32 | if devNum == 1: 33 | return dev_list[0] 34 | 35 | choice = None 36 | if devNum > 1: 37 | print "Select the device to use for analysis:\n" 38 | for i in xrange(0, devNum): 39 | print "%d. %s\n" % ((i + 1), dev_list[i]) 40 | 41 | while not choice: 42 | try: 43 | choice = int(raw_input()) 44 | if choice not in range(1, devNum+1): 45 | choice = None 46 | print 'Invalid choice! Choose right number!' 47 | 48 | except ValueError: 49 | print 'Invalid Number! Choose right number!' 50 | 51 | return dev_list[choice-1] 52 | 53 | def runMonkeyStrategy(adb, package_name, eventsCount, seed, throttle): 54 | automaticTriggeringStrategy = MonkeyStrategy(adbDevice=adb, packageName=package_name, eventsCount=eventsCount, seed=seed, verbosityLevel=2, throttle=throttle) 55 | automaticTriggeringStrategy.run() 56 | 57 | 58 | 59 | #main part 60 | adb = AdbInterface() 61 | device = getExecutionDevice() 62 | if not device: 63 | exit(1) 64 | 65 | adb.setTargetSerial(device) 66 | bboxcoverage = BBoxCoverage() 67 | 68 | apk_file = INSTRUMENTED_APK_PATH 69 | if apk_file: 70 | print "Starting monkeyrunner strategy experiment for apk: %s" % apk_file 71 | res_dir = os.path.split(os.path.abspath(apk_file))[0] 72 | # if not os.path.exists(res_dir): 73 | # auxiliary_utils.mkdir(res_dir, mode=0777, overwrite=True) 74 | print "Putting results in directory: %s" % res_dir 75 | try: 76 | bboxcoverage.initAlreadyInstrApkEnv(pathToInstrApk=apk_file, resultsDir=res_dir) 77 | bboxcoverage.installApkOnDevice() 78 | 79 | bboxcoverage.startTesting() 80 | package_name = bboxcoverage.getPackageName() 81 | runMonkeyStrategy(adb=adb, package_name=package_name, 82 | eventsCount=EVENTS_COUNT, seed=SEED, 83 | throttle=THROTTLE) 84 | 85 | params={} 86 | params["strategy"] = "monkey" 87 | params["package_name"] = package_name 88 | params["events_count"] = EVENTS_COUNT 89 | params["seed"] = SEED 90 | params["throttle"] = THROTTLE 91 | time.sleep(3) 92 | bboxcoverage.stopTesting("monkey_events_%d_seed_%d_throttle_%d" % (EVENTS_COUNT, SEED, THROTTLE), paramsToWrite=params) 93 | time.sleep(3) 94 | bboxcoverage.uninstallPackage() 95 | time.sleep(5) 96 | except Exception as e: 97 | print "EXCEPTION while execution: " + str(e) 98 | except: 99 | print "UNKNOWN EXCEPTION" -------------------------------------------------------------------------------- /BBoxTester/interfaces/dex2jar_interface.py: -------------------------------------------------------------------------------- 1 | import os 2 | import commander 3 | 4 | 5 | class Dex2JarInterface: 6 | def __init__(self, javaPath = "java", javaOpts = "-Xms512m -Xmx1024m", pathDex2JarLibs="./auxiliary/dex2jar/lib/", classDex2Jar="com.googlecode.dex2jar.tools.Dex2jarCmd", classApksign="com.googlecode.dex2jar.tools.ApkSign"): 7 | self.javaPath = javaPath 8 | self.javaOpts = javaOpts 9 | self.pathDex2JarLibs = pathDex2JarLibs 10 | self.classDex2Jar = classDex2Jar 11 | self.classApksign = classApksign 12 | self.classpath = self._createClassPath() 13 | 14 | def _createClassPath(self): 15 | classpathList = [os.path.join(self.pathDex2JarLibs,f) for f in os.listdir(self.pathDex2JarLibs) if '.jar' in f] 16 | return ":".join(classpathList) 17 | 18 | def _previewDex2JarCommand(self, className, parameters): 19 | cmd = "%s %s" % (className, parameters) 20 | return cmd 21 | 22 | def _runCommand(self, cmdString): 23 | cmd = "'%s' %s -classpath '%s' %s" % (self.javaPath, self.javaOpts, self.classpath, cmdString) 24 | return commander.runOnce(cmd) 25 | 26 | def _interpResultsDex2JarCmd(self, returnCode, outputStr): 27 | ''' 28 | This function interprets the returnCode and outputStr obtained from 29 | external process and returns if the run has been successful or not. 30 | Args: 31 | returnCode: 32 | outputStr: 33 | Returns: 34 | True, None: in case if the command has been executed correctly 35 | False, outputStr: otherwise 36 | ''' 37 | retCode = "Return code is: %s" % returnCode 38 | #NOTE: later we can select different routines to process different errors 39 | if "java.lang.RuntimeException" in outputStr or returnCode: 40 | output = "%s\n%s" % (retCode, outputStr) 41 | return (False, output) 42 | return (True, None) 43 | 44 | def dex2jar(self, source, output=None, force=True, debug_info=True): 45 | ''' 46 | Args: 47 | source: 48 | output: 49 | force: 50 | Returns: 51 | ''' 52 | options="" 53 | if output: 54 | options += " -o '%s'" % output 55 | if force: 56 | options += " -f" 57 | if debug_info: 58 | options += " -d" 59 | 60 | opts = "%s '%s'" % (options, source) 61 | cmd = self._previewDex2JarCommand(self.classDex2Jar, opts) 62 | 63 | (returnCode, outputStr) = self._runCommand(cmd) 64 | 65 | return self._interpResultsDex2JarCmd(returnCode, outputStr) 66 | 67 | 68 | def _interpResultsApkSignCmd(self, returnCode, outputStr): 69 | ''' 70 | This function interprets the returnCode and output obtained from 71 | external process and returns if the run has been successful or not. 72 | Args: 73 | returnCode: 74 | output: 75 | Returns: 76 | True, None: in case if the command has been executed correctly 77 | False, output: otherwise 78 | ''' 79 | retCode = "Return code is: %s" % returnCode 80 | #NOTE: later we can select different routines to process different errors 81 | if "java.lang.RuntimeException" in outputStr or returnCode: 82 | output = "%s\n%s" % (retCode, outputStr) 83 | return (False, output) 84 | return (True, None) 85 | 86 | 87 | def apkSign(self, source, output=None, force=True): 88 | options="" 89 | if output: 90 | options += " -o '%s'" % output 91 | if force: 92 | options += " -f" 93 | 94 | opts = "%s %s" % (options, source) 95 | cmd = self._previewDex2JarCommand(self.classApksign, opts) 96 | (returnCode, outputStr) = self._runCommand(cmd) 97 | 98 | return self._interpResultsApkSignCmd(returnCode, outputStr) 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /BBoxTester/interfaces/apktool_interface.py: -------------------------------------------------------------------------------- 1 | import os 2 | import commander 3 | 4 | 5 | class ApktoolInterface: 6 | def __init__(self, javaPath = "java", javaOpts = "-Xms512m -Xmx1024m", pathApktool = "./auxiliary/apktool", jarApktool="apktool.jar"): 7 | self.javaPath = javaPath 8 | self.javaOpts = javaOpts 9 | self.pathApktool = pathApktool 10 | self.jarApktool = jarApktool 11 | #TODO: later we can join path and jar and check if they exist or not 12 | # if not - generate an exception 13 | 14 | def _previewApktoolCommand(self, cmdStr, quiet): 15 | path = os.path.join(self.pathApktool, self.jarApktool) 16 | verbose = None 17 | if quiet: 18 | verbose = "--quiet" 19 | else: 20 | verbose = "--verbose" 21 | 22 | apktoolCmd = "%s %s %s" % (path, verbose, cmdStr) 23 | return apktoolCmd 24 | 25 | def _runApktoolCommand(self, commandString): 26 | cmd = "'%s' %s -jar %s" % (self.javaPath, self.javaOpts, commandString) 27 | return commander.runOnce(cmd) 28 | 29 | def _interpResultsDecodeCmd(self, returnCode, cmdOutput): 30 | output = "Return code is: [%s].\nCommand output: %s" % (returnCode, cmdOutput) 31 | #TODO: later we can select different routines to process different errors 32 | if returnCode: 33 | return (False, output) 34 | return (True, output) 35 | 36 | 37 | def decode(self, apkPath, dirToDecompile, quiet=True, noSrc=False, noRes=False, debug=True, noDebugInfo=False, force=True, frameworkTag="", frameworkDir="", keepBrokenRes=True): 38 | options = "decode" 39 | if noSrc: 40 | options += " --no-src" 41 | if noRes: 42 | options += " --no-res" 43 | if debug: 44 | options += " --debug" 45 | if noDebugInfo: 46 | options += " --no-debug-info" 47 | if force: 48 | options += " --force" 49 | if frameworkTag: 50 | options += " --frame-tag '%s'" % frameworkTag 51 | if frameworkDir: 52 | options += " --frame-path '%s'" % frameworkDir 53 | if keepBrokenRes: 54 | options += " --keep-broken-res" 55 | 56 | options = "%s '%s' '%s'" % (options, apkPath, dirToDecompile) 57 | cmd = self._previewApktoolCommand(options, quiet) 58 | (returnCode, cmdOutput) = self._runApktoolCommand(cmd) 59 | return self._interpResultsDecodeCmd(returnCode, cmdOutput) 60 | 61 | 62 | def _interpResultsBuildCmd(self, returnCode, outputStr): 63 | retCode = "Return code is: %s" % returnCode 64 | #NOTE: later we can select different routines to process different errors 65 | if returnCode: 66 | output = "%s\n%s" % (retCode, outputStr) 67 | return (False, output) 68 | return (True, None) 69 | 70 | 71 | def build(self, srcPath, finalApk, quiet=True, forceAll=False, debug=True, aaptPath=""): 72 | options = "build" 73 | if forceAll: 74 | options += " --force-all" 75 | if debug: 76 | options += " --debug" 77 | if aaptPath: 78 | options += " --aapt '%s'" % aaptPath 79 | 80 | options = "%s '%s' '%s'" % (options, srcPath, finalApk) 81 | cmd = self._previewApktoolCommand(options, quiet) 82 | (returnCode, outputStr) = self._runApktoolCommand(cmd) 83 | return self._interpResultsBuildCmd(returnCode, outputStr) 84 | 85 | 86 | def _interpResultsVersionCmd(self, returnCode, outputStr): 87 | if returnCode == 1: 88 | return (True, outputStr) 89 | retCode = "Return code is: %s" % returnCode 90 | output = "%s\n%s" (retCode, outputStr) 91 | return (False, output) 92 | 93 | 94 | def version(self, quiet=True): 95 | options = " --version" 96 | cmd = self._previewApktoolCommand(options, quiet) 97 | (returnCode, outputStr) = self._runApktoolCommand(cmd) 98 | return self._interpResultsVersionCmd(returnCode, outputStr.strip('\n')) 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /BBoxTester/utils/auxiliary_utils.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Jul 4, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import os, errno, shutil 7 | 8 | 9 | def mkdir(path, mode=0777, overwrite=False): 10 | ''' 11 | This method creates directory, additionally creating intermediate directories, 12 | if they do not exist. If overwrite == False and directory exists, the method 13 | returns happily. 14 | 15 | Args: 16 | :param path: path to the directory to create 17 | :param mode: permissions to the directory 18 | :param overwrite: True - to overwrite path if it exists 19 | ''' 20 | if os.path.exists(path) and overwrite: 21 | shutil.rmtree(path) 22 | #if overwrite==False and path exists mkdirs returns happily 23 | try: 24 | os.makedirs(path) 25 | except OSError as exc: # Python >2.5 26 | if exc.errno == errno.EEXIST and os.path.isdir(path): 27 | pass 28 | else: raise 29 | 30 | def ensureDirExists(path, mode=0777): 31 | ''' 32 | This method ensures that a directory exists. If it does not exists this 33 | method creates this directory. 34 | 35 | Args: 36 | :param path: path to the directory 37 | :param mode: permissions to the directory 38 | ''' 39 | if not os.path.exists(path): 40 | os.makedirs(path, mode) 41 | 42 | def searchFiles(where, extension): 43 | searched_files = [] 44 | searched_extension = ".%s" % extension.lower() 45 | for root, dirs, files in os.walk(where): 46 | for f in files: 47 | if f.lower().endswith(searched_extension): 48 | searched_files.append(os.path.join(root, f)) 49 | return searched_files 50 | 51 | def searchFilesRelativeToDir(target, extension): 52 | ''' 53 | This method searches for files with the provided extension in the provided 54 | directory recursively and returns path to these files relative to the 55 | specified directory. 56 | 57 | Args: 58 | :param target: directory in which 59 | :param extension: 60 | Returns: 61 | :ret paths to files relative to the target 62 | ''' 63 | searched_files = [] 64 | searched_extension = ".%s" % extension.lower() 65 | for root, dirs, files in os.walk(target): 66 | for f in files: 67 | if f.lower().endswith(searched_extension): 68 | searched_files.append(os.path.join(root[len(target):], f)) 69 | return searched_files 70 | 71 | def to_bool(value): 72 | """ 73 | Converts 'something' to boolean. Raises exception for invalid formats 74 | Possible True values: 1, True, "1", "TRue", "yes", "y", "t" 75 | Possible False values: 0, False, None, [], {}, "", "0", "faLse", "no", "n", "f", 0.0, ... 76 | """ 77 | if str(value).lower() in ("yes", "y", "true", "t", "1"): return True 78 | if str(value).lower() in ("no", "n", "false", "f", "0", "0.0", "", "none", "[]", "{}"): return False 79 | raise Exception('Invalid value for boolean conversion: ' + str(value)) 80 | 81 | # def checkInputFile(inputPath): 82 | # logger.debug("Checking input path [%s]..." % inputPath) 83 | # if not os.path.isfile(inputPath): 84 | # logger.error("Input path [%s] does not point to a file!" % inputPath) 85 | # return False 86 | # logger.debug("The path [%s] point to the file!" % inputPath) 87 | # 88 | # ret_type = androconf.is_android(inputPath) 89 | # if ret_type != "APK": 90 | # logger.error("Input file [%s] is not APK file!" % inputPath) 91 | # return False 92 | # 93 | # logger.debug("File [%s] is an APK file!" % inputPath) 94 | # return True 95 | # 96 | # def checkOutputPath(dst): 97 | # if os.path.exists(dst): 98 | # if not os.path.isdir(dst): 99 | # logger.error("[%s] is not a directory!" % dst) 100 | # return False 101 | # else: 102 | # logger.info("The path [%s] does not exist! Creating it!" % dst) 103 | # os.makedirs(dst) 104 | # 105 | # return True 106 | # 107 | # def copyFileToDir(src, dst): 108 | # logger.debug("Coping file [%s] to output directory [%s]..." % (os.path.basename(src), dst)) 109 | # 110 | # if not os.path.isfile(src): 111 | # logger.debug("[%s] is not a file! Cannot be copied!" % src) 112 | # return False 113 | # try: 114 | # shutil.copy2(src, dst) 115 | # except Exception as e: 116 | # logger.error(e) 117 | # logger.error("Could not copy file [%s] to directory [%s]!" % (src, dst)) 118 | # return False 119 | # 120 | # logger.debug("File [%s] has been copied to directory [%s] successfully!" % (src, dst)) 121 | # return True 122 | -------------------------------------------------------------------------------- /BBoxTester/main_activity_strategy.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Nov 26, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import os, time 7 | 8 | from interfaces.adb_interface import AdbInterface 9 | from bboxcoverage import BBoxCoverage 10 | from running_strategies import MainActivityInvocationStrategy 11 | 12 | import smtplib 13 | import email.utils 14 | from email.mime.text import MIMEText 15 | 16 | APK_DIR_SOURCES = ["", ""] 17 | 18 | SMTP_SERVER = 'smtp.gmail.com' 19 | SMTP_PORT = 587 20 | SENDER = "" 21 | PASSWORD = "" 22 | TO_EMAIL = "" 23 | 24 | def sendMessage(subj, email_message): 25 | msg = MIMEText(email_message) 26 | msg['To'] = email.utils.formataddr(('Recipient', TO_EMAIL)) 27 | msg['From'] = email.utils.formataddr(('Author', SENDER)) 28 | msg['Subject'] = subj 29 | 30 | server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT) 31 | try: 32 | server.set_debuglevel(True) 33 | 34 | # identify ourselves, prompting server for supported features 35 | server.ehlo() 36 | 37 | # If we can encrypt this session, do it 38 | if server.has_extn('STARTTLS'): 39 | server.starttls() 40 | server.ehlo() # re-identify ourselves over TLS connection 41 | 42 | server.login(SENDER, PASSWORD) 43 | server.sendmail(SENDER, [TO_EMAIL], msg.as_string()) 44 | finally: 45 | server.quit() 46 | 47 | def getExecutionDevice(): 48 | ''' 49 | This method allows a user to select a device that is used to for further 50 | analysis. 51 | ''' 52 | dev_list = AdbInterface.getDeviceSerialsList() 53 | devNum = len(dev_list) 54 | 55 | if devNum <= 0: 56 | print "No device has been detected! Connect your device and restart the application!" 57 | return 58 | 59 | if devNum == 1: 60 | return dev_list[0] 61 | 62 | choice = None 63 | if devNum > 1: 64 | print "Select the device to use for analysis:\n" 65 | for i in xrange(0, devNum): 66 | print "%d. %s\n" % ((i + 1), dev_list[i]) 67 | 68 | while not choice: 69 | try: 70 | choice = int(raw_input()) 71 | if choice not in range(1, devNum+1): 72 | choice = None 73 | print 'Invalid choice! Choose right number!' 74 | 75 | except ValueError: 76 | print 'Invalid Number! Choose right number!' 77 | 78 | return dev_list[choice-1] 79 | 80 | 81 | def getSubdirs(rootDir): 82 | return [os.path.join(rootDir, name) for name in os.listdir(rootDir) 83 | if os.path.isdir(os.path.join(rootDir, name))] 84 | 85 | def getInstrApkInFolder(folder): 86 | for f in os.listdir(folder): 87 | if f.endswith("_aligned.apk"): 88 | filepath = os.path.join(folder, f) 89 | return filepath 90 | return None 91 | 92 | 93 | def runMainActivityStrategy(adb, androidManifest): 94 | automaticTriggeringStrategy = MainActivityInvocationStrategy(adbDevice=adb, pathToAndroidManifest=androidManifest) 95 | automaticTriggeringStrategy.run() 96 | 97 | #main part 98 | adb = AdbInterface() 99 | device = getExecutionDevice() 100 | if not device: 101 | exit(1) 102 | 103 | adb.setTargetSerial(device) 104 | bboxcoverage = BBoxCoverage() 105 | 106 | for apk_dir_source in APK_DIR_SOURCES: 107 | print "\n\nStarting experiment for directory: [%s]" % apk_dir_source 108 | result_directories = getSubdirs(apk_dir_source) 109 | for directory in result_directories: 110 | apk_file = getInstrApkInFolder(directory) 111 | if apk_file: 112 | print "Starting experiment for apk: [%s]" % apk_file 113 | try: 114 | bboxcoverage.initAlreadyInstrApkEnv(pathToInstrApk=apk_file, resultsDir=directory) 115 | except: 116 | print "Exception while initialization!" 117 | continue 118 | try: 119 | bboxcoverage.installApkOnDevice() 120 | except: 121 | print "Exception while installation apk on device!" 122 | bboxcoverage.uninstallPackage() 123 | try: 124 | bboxcoverage.installApkOnDevice() 125 | except: 126 | continue 127 | 128 | package_name = bboxcoverage.getPackageName() 129 | params = {} 130 | params["strategy"] = "main_activity" 131 | params["package_name"] = package_name 132 | params["main_activity"] = bboxcoverage.androidManifest.getMainActivity() 133 | 134 | try: 135 | bboxcoverage.startTesting() 136 | except: 137 | print "Exception while startTesting!" 138 | bboxcoverage.uninstallPackage() 139 | continue 140 | 141 | try: 142 | runMainActivityStrategy(adb=adb, androidManifest=bboxcoverage.androidManifestFile) 143 | except: 144 | print "Exception while running strategy!" 145 | bboxcoverage.uninstallPackage() 146 | continue 147 | 148 | try: 149 | bboxcoverage.stopTesting("main_activity", paramsToWrite=params) 150 | except: 151 | print "Exception while running strategy!" 152 | bboxcoverage.uninstallPackage() 153 | continue 154 | 155 | time.sleep(3) 156 | bboxcoverage.uninstallPackage() 157 | time.sleep(5) 158 | 159 | sendMessage("[BBoxTester]", "Experiments done for directory [%s]!" % apk_dir_source) 160 | -------------------------------------------------------------------------------- /BBoxTester/main_intents_strategy.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Nov 26, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import os, time 7 | 8 | from interfaces.adb_interface import AdbInterface 9 | from bboxcoverage import BBoxCoverage 10 | from running_strategies import IntentInvocationStrategy 11 | 12 | import smtplib 13 | import email.utils 14 | from email.mime.text import MIMEText 15 | 16 | APK_DIR_SOURCES = ["", ""] 17 | 18 | SMTP_SERVER = 'smtp.gmail.com' 19 | SMTP_PORT = 587 20 | SENDER = "" 21 | PASSWORD = "" 22 | TO_EMAIL = "" 23 | 24 | def sendMessage(subj, email_message): 25 | msg = MIMEText(email_message) 26 | msg['To'] = email.utils.formataddr(('Recipient', TO_EMAIL)) 27 | msg['From'] = email.utils.formataddr(('Author', SENDER)) 28 | msg['Subject'] = subj 29 | 30 | server = smtplib.SMTP(SMTP_SERVER, SMTP_PORT) 31 | try: 32 | server.set_debuglevel(True) 33 | 34 | # identify ourselves, prompting server for supported features 35 | server.ehlo() 36 | 37 | # If we can encrypt this session, do it 38 | if server.has_extn('STARTTLS'): 39 | server.starttls() 40 | server.ehlo() # re-identify ourselves over TLS connection 41 | 42 | server.login(SENDER, PASSWORD) 43 | server.sendmail(SENDER, [TO_EMAIL], msg.as_string()) 44 | finally: 45 | server.quit() 46 | 47 | def getExecutionDevice(): 48 | ''' 49 | This method allows a user to select a device that is used to for further 50 | analysis. 51 | ''' 52 | dev_list = AdbInterface.getDeviceSerialsList() 53 | devNum = len(dev_list) 54 | 55 | if devNum <= 0: 56 | print "No device has been detected! Connect your device and restart the application!" 57 | return 58 | 59 | if devNum == 1: 60 | return dev_list[0] 61 | 62 | choice = None 63 | if devNum > 1: 64 | print "Select the device to use for analysis:\n" 65 | for i in xrange(0, devNum): 66 | print "%d. %s\n" % ((i + 1), dev_list[i]) 67 | 68 | while not choice: 69 | try: 70 | choice = int(raw_input()) 71 | if choice not in range(1, devNum+1): 72 | choice = None 73 | print 'Invalid choice! Choose right number!' 74 | 75 | except ValueError: 76 | print 'Invalid Number! Choose right number!' 77 | 78 | return dev_list[choice-1] 79 | 80 | 81 | def getSubdirs(rootDir): 82 | return [os.path.join(rootDir, name) for name in os.listdir(rootDir) 83 | if os.path.isdir(os.path.join(rootDir, name))] 84 | 85 | def getInstrApkInFolder(folder): 86 | for f in os.listdir(folder): 87 | if f.endswith("_aligned.apk"): 88 | filepath = os.path.join(folder, f) 89 | return filepath 90 | return None 91 | 92 | 93 | def runMainIntentsStrategy(adb, androidManifest, delay=10): 94 | automaticTriggeringStrategy = IntentInvocationStrategy(adbDevice=adb, pathToAndroidManifest=androidManifest) 95 | automaticTriggeringStrategy.run(delay=delay) 96 | 97 | #main part 98 | adb = AdbInterface() 99 | device = getExecutionDevice() 100 | if not device: 101 | exit(1) 102 | 103 | adb.setTargetSerial(device) 104 | bboxcoverage = BBoxCoverage() 105 | 106 | for apk_dir_source in APK_DIR_SOURCES: 107 | print "\n\nStarting experiment for directory: [%s]" % apk_dir_source 108 | result_directories = getSubdirs(apk_dir_source) 109 | for directory in result_directories: 110 | apk_file = getInstrApkInFolder(directory) 111 | if apk_file: 112 | print "Starting experiment for apk: [%s]" % apk_file 113 | try: 114 | bboxcoverage.initAlreadyInstrApkEnv(pathToInstrApk=apk_file, resultsDir=directory) 115 | except: 116 | print "Exception while initialization!" 117 | continue 118 | try: 119 | bboxcoverage.installApkOnDevice() 120 | except: 121 | print "Exception while installation apk on device!" 122 | bboxcoverage.uninstallPackage() 123 | try: 124 | bboxcoverage.installApkOnDevice() 125 | except: 126 | continue 127 | 128 | package_name = bboxcoverage.getPackageName() 129 | params = {} 130 | params["strategy"] = "main_intents" 131 | params["package_name"] = package_name 132 | params["main_activity"] = bboxcoverage.androidManifest.getMainActivity() 133 | 134 | try: 135 | bboxcoverage.startTesting() 136 | except: 137 | print "Exception while startTesting!" 138 | bboxcoverage.uninstallPackage() 139 | continue 140 | 141 | try: 142 | runMainIntentsStrategy(adb=adb, androidManifest=bboxcoverage.androidManifestFile, delay=10) 143 | except: 144 | print "Exception while running strategy!" 145 | bboxcoverage.uninstallPackage() 146 | continue 147 | 148 | try: 149 | bboxcoverage.stopTesting("main_intents", paramsToWrite=params) 150 | except: 151 | print "Exception while running strategy!" 152 | bboxcoverage.uninstallPackage() 153 | continue 154 | 155 | time.sleep(3) 156 | bboxcoverage.uninstallPackage() 157 | time.sleep(5) 158 | 159 | sendMessage("[BBoxTester]", "Experiments done for directory [%s]!" % apk_dir_source) 160 | -------------------------------------------------------------------------------- /BBoxTester/running_strategies.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Nov 11, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import time 7 | from utils.android_manifest import AndroidManifest 8 | from interfaces.adb_interface import CATEGORY_DEFAULT 9 | 10 | class RunningStrategy(): 11 | def run(self): 12 | pass 13 | 14 | class MonkeyStrategy(RunningStrategy): 15 | ''' 16 | 17 | ''' 18 | 19 | 20 | def __init__(self, adbDevice, packageName, eventsCount, seed, verbosityLevel, throttle, timeout=None): 21 | ''' 22 | Constructor 23 | ''' 24 | self.adbDevice = adbDevice 25 | self.eventsCount = eventsCount 26 | self.packageName = packageName 27 | self.seed = seed 28 | self.verbosityLevel = verbosityLevel 29 | self.throttle = throttle 30 | self.timeout = timeout 31 | 32 | 33 | def run(self): 34 | self.adbDevice.runMonkeyTest(timeout=self.timeout, packageName=self.packageName, 35 | verbosityLevel=self.verbosityLevel, seed=self.seed, throttle=self.throttle, 36 | eventsCount=self.eventsCount, dbgNoEvents=False, hprof=False, ignoreCrashes=True, 37 | ignoreTimeouts=True, ignoreSecurityExceptions=True, killProcessAfterError=False, 38 | monitorNativeCrashes=False, waitDbg=False) 39 | 40 | 41 | 42 | 43 | class IntentInvocationStrategy(RunningStrategy): 44 | def __init__(self, adbDevice, pathToAndroidManifest): 45 | self.adbDevice = adbDevice 46 | self.androidManifest=AndroidManifest(pathToAndroidManifest) 47 | 48 | 49 | def run(self, delay=10): 50 | print "Activities:" 51 | activities = self.androidManifest.getActivities() 52 | for activity in activities: 53 | self._invokeActivityExplicitely(activity) 54 | time.sleep(delay) 55 | 56 | print "Services:" 57 | services = self.androidManifest.getServices() 58 | for service in services: 59 | self._invokeServiceExplicitely(service) 60 | time.sleep(delay) 61 | 62 | print "Receivers:" 63 | receivers = self.androidManifest.getReceivers() 64 | for receiver in receivers: 65 | self._invokeReceiver(receiver) 66 | time.sleep(delay) 67 | 68 | 69 | def _invokeActivityExplicitely(self, activity): 70 | self.adbDevice.startActivityExplicitly(package_name=self.androidManifest.getPackageName(), 71 | activity_name=activity) 72 | 73 | def _invokeActivity(self, activity): 74 | intentFilters = self.androidManifest.getActivityIntentFilters(activity) 75 | if not intentFilters: 76 | self.adbDevice.startActivityExplicitly(package_name=self.androidManifest.getPackageName(), 77 | activity_name=activity) 78 | return 79 | for filt in intentFilters: 80 | action = self._getAction(filt) 81 | category = self._getCategory(filt) 82 | mimeType = self._getMiMeType(filt) 83 | self.adbDevice.startActivityImplicitely(action=action, mimeType=mimeType, category=category) 84 | 85 | def _invokeServiceExplicitely(self, service): 86 | self.adbDevice.startServiceExplicitly(package_name=self.androidManifest.getPackageName(), 87 | service_name=service) 88 | 89 | def _invokeService(self, service): 90 | intentFilters = self.androidManifest.getServiceIntentFilters(service) 91 | if not intentFilters: 92 | self.adbDevice.startServiceExplicitly(package_name=self.androidManifest.getPackageName(), 93 | service_name=service) 94 | return 95 | 96 | for filt in intentFilters: 97 | action = self._getAction(filt) 98 | category = self._getCategory(filt) 99 | mimeType = self._getMiMeType(filt) 100 | self.adbDevice.startServiceImplicitely(action=action, mimeType=mimeType, category=category) 101 | 102 | def _invokeReceiver(self, receiver): 103 | intentFilters = self.androidManifest.getReceiverIntentFilters(receiver) 104 | if not intentFilters: 105 | return 106 | 107 | for filt in intentFilters: 108 | action = self._getAction(filt) 109 | category = self._getCategory(filt) 110 | mimeType = self._getMiMeType(filt) 111 | self.adbDevice.sendBroadcast(action=action, mimeType=mimeType, category=category) 112 | 113 | 114 | def _getAction(self, filt): 115 | action = None 116 | actions = filt.get("action") 117 | if actions: 118 | action = actions[0] 119 | return action 120 | 121 | def _getCategory(self, filt): 122 | category = None 123 | categories = filt.get("category") 124 | if categories: 125 | category = categories[0] 126 | else: 127 | category = CATEGORY_DEFAULT 128 | return category 129 | 130 | def _getMiMeType(self, filt): 131 | mimeType = None 132 | mimeTypes = filt.get("mimeType") 133 | if mimeTypes: 134 | mimeType = mimeTypes[0] 135 | return mimeType 136 | 137 | class MainActivityInvocationStrategy(RunningStrategy): 138 | def __init__(self, adbDevice, pathToAndroidManifest): 139 | self.adbDevice = adbDevice 140 | self.androidManifest=AndroidManifest(pathToAndroidManifest) 141 | 142 | def run(self, delay=10): 143 | mainActivity = self.androidManifest.getMainActivity() 144 | if mainActivity: 145 | self.adbDevice.startActivityExplicitly(package_name=self.androidManifest.getPackageName(), 146 | activity_name=mainActivity) 147 | time.sleep(delay) 148 | 149 | -------------------------------------------------------------------------------- /BBoxTester/bbox_core/bboxexecutor.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Sep 30, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | import string 7 | 8 | from bbox_core.general_exceptions import MsgException 9 | from interfaces.adb_interface import AdbInterface, TYPE_STRING, TYPE_BOOLEAN 10 | from logconfig import logger 11 | import os 12 | 13 | 14 | #taken from EmmaInstrumentation.java 15 | # TAG_COVERAGE = "coverage" 16 | # TAG_PREANALYSIS_COVERAGE_FILE_PATH = "coverageFile" 17 | # TAG_GENERATE_REPORT = "generateReport" 18 | # TAG_POSTANALYSIS_COVERAGE_FILE_PATH = "reportFilePath" 19 | 20 | 21 | KEY_COVERAGE = "coverage" 22 | KEY_REPORT_FOLDER = "coverageDir" 23 | KEY_CANCEL_ANALYSIS = "cancelAnalysis" 24 | KEY_PROCEED_ON_ERROR = "proceedOnError" 25 | KEY_GENERATE_COVERAGE_REPORT_ON_ERROR = "generateCoverageReportOnError" 26 | 27 | ACTION_FINISH_TESTING = "com.zhauniarovich.bbtester.finishtesting" 28 | DEFAULT_COVERAGE_FILE_PATH = "/mnt/sdcard/coverage.ec" 29 | 30 | class BBoxExecutor: 31 | #TODO: State machine? 32 | def __init__(self, config): 33 | self.isDeviceActive = False 34 | self.testStarted = False 35 | self.device = AdbInterface() 36 | self.config = config #maybe it will be required for future use 37 | 38 | def selectExecutionDevice(self): 39 | ''' 40 | This method allows a user to select a device that is used to for further 41 | analysis. 42 | ''' 43 | dev_list = AdbInterface.getDeviceSerialsList() 44 | devNum = len(dev_list) 45 | 46 | if devNum <= 0: 47 | print "No device has been detected! Connect your device and restart the application!" 48 | return 49 | 50 | if devNum == 1: 51 | self.device.setTargetSerial(dev_list[0]) 52 | self.isDeviceActive = True 53 | return 54 | 55 | choice = None 56 | if devNum > 1: 57 | print "Select the device to use for analysis:\n" 58 | for i in xrange(0, devNum): 59 | print "%d. %s\n" % ((i + 1), dev_list[i]) 60 | 61 | while not choice: 62 | try: 63 | choice = int(raw_input()) 64 | if choice not in range(1, devNum+1): 65 | choice = None 66 | print 'Invalid choice! Choose right number!' 67 | 68 | except ValueError: 69 | print 'Invalid Number! Choose right number!' 70 | 71 | self.device.setTargetSerial(dev_list[choice - 1]) 72 | self.isDeviceActive = True 73 | 74 | 75 | def setExecutionDevice(self, device): 76 | if not isinstance(device, AdbInterface): 77 | logger.error("Provided object is not of AdbInterface class") 78 | self.device=device 79 | self.isDeviceActive = True 80 | 81 | def installApkOnDevice(self, pathToApk): 82 | ''' 83 | This method installs selected apk file on the device. 84 | 85 | Args: 86 | :param pathToApk: path to the apk file that has to be installed on 87 | the device 88 | Raises: 89 | ApkCannotBeInstalledException: if the error occurred during the 90 | installation process. 91 | ''' 92 | if not self.isDeviceActive: 93 | self.selectExecutionDevice() 94 | 95 | output = self.device.install(pathToApk) 96 | success = self._interpretApkInstallCmd(output) 97 | if not success: 98 | raise ApkCannotBeInstalledException(output) 99 | 100 | 101 | def uninstallPackage(self, packageName, keepData=False): 102 | ''' 103 | This method uninstalls specified package from the device. 104 | 105 | Args: 106 | :param packageName: the name of the package to uninstall 107 | :param keepData: True if the data of the application should be 108 | preserved (should be not deleted) 109 | ''' 110 | if not self.isDeviceActive: 111 | self.selectExecutionDevice() 112 | output = self.device.uninstall(package_name=packageName, 113 | keep_data=keepData) 114 | #logger.info(output) 115 | 116 | 117 | def startOndeviceTesting(self, packageName, runnerName, coverage=True, reportFolder=None, proceedOnError=False, generateCoverageReportOnError=True): 118 | ''' 119 | This methods starts testing process on the device. 120 | 121 | Args: 122 | :param packageName: the name of the package that is instrumented and 123 | needs to be tested 124 | :param runnerName: the name of the runner that runs the testing 125 | :param coverage: True - if the coverage report should be generated 126 | :param coverageFile: the path to the file, where the coverage report 127 | is stored. Notice, that there are two main ways to provide this 128 | file path: before the analysis or after the analysis. The path 129 | provided after analysis has more power then the file path 130 | provided before the analysis. This means that if you provided 131 | file path before and after analysis, the file will be stored in 132 | the place according to the latter. 133 | ''' 134 | #Checking if there is an available device for execution 135 | #if not self.isDeviceActive: 136 | # self.selectExecutionDevice() 137 | if not self.isDeviceActive: 138 | self.selectExecutionDevice() 139 | 140 | 141 | instrArgs = {} 142 | instrArgs[KEY_COVERAGE] = coverage 143 | if reportFolder: 144 | instrArgs[KEY_REPORT_FOLDER] = reportFolder 145 | 146 | instrArgs[KEY_PROCEED_ON_ERROR] = proceedOnError 147 | instrArgs[KEY_GENERATE_COVERAGE_REPORT_ON_ERROR] = generateCoverageReportOnError 148 | 149 | self.device.startInstrumentationNoResults(package_name=packageName, 150 | runner_name=runnerName, 151 | wait=False, 152 | instrumentation_args=instrArgs) 153 | self.testStarted = True 154 | 155 | 156 | def stopOndeviceTesting(self, cancelAnalysis=False): 157 | ''' 158 | This method stops testing the application on the device. 159 | 160 | Args: 161 | :param generateReport: True - if the coverage report needs to be 162 | generated 163 | ''' 164 | if not self.testStarted: 165 | print "The testing on the device has not be started. Nothing to stop!" 166 | return 167 | extra = {} 168 | extra[KEY_CANCEL_ANALYSIS] = (TYPE_BOOLEAN, cancelAnalysis) 169 | 170 | self.device.sendBroadcast(action=ACTION_FINISH_TESTING, extra=extra) 171 | self.testStarted = False 172 | 173 | 174 | def cancelAnalysis(self): 175 | ''' 176 | This method stops the analysis without storing coverage report. 177 | ''' 178 | self.stopOndeviceTesting(cancelAnalysis=True) 179 | 180 | def getFileFromDevice(self, srcPath, dstPath): 181 | ''' 182 | The method gets a file (usually it is used to get a report) from a 183 | device. 184 | 185 | Args: 186 | :param srcPath: the path on the device that needs to be copied 187 | :param dstPath: destination where to copy the file 188 | ''' 189 | return self.device.pull(srcPath, dstPath) 190 | 191 | 192 | def _interpretApkInstallCmd(self, output): 193 | ''' 194 | A helper method used to interpret the output of the app install command. 195 | 196 | Args: 197 | :param output: output of the install command that needs to be parsed 198 | ''' 199 | for line in output.split('\n'): 200 | line = line.strip(string.whitespace) 201 | if "Success" in line: 202 | return True 203 | 204 | return False 205 | 206 | def removeFile(self, target): 207 | return self.device.remove(target) 208 | 209 | 210 | #Exceptions 211 | class ApkCannotBeInstalledException(MsgException): 212 | ''' 213 | Apk cannot be installed. 214 | ''' 215 | 216 | 217 | # bboxexecutor = BBoxExecutor() 218 | # bboxexecutor.selectExecutionDevice() 219 | # print bboxexecutor.device.getSerialNumber() 220 | # print bboxexecutor.installApkOnDevice("/home/yury/research_tmp/bboxtester/Notepad.apk") 221 | #bboxexecutor.startOndeviceTesting("package", "runner", True, coverageFile = "/mnt/sd") 222 | # print bboxexecutor.device.previewInstrumentationCommand(package_name="packageName", 223 | # runner_name="runnerName", 224 | # wait=False) 225 | 226 | # bboxexecutor.stopOndeviceTesting(generateReport=False, postAnalysisCoverageFilePath="/my_path") -------------------------------------------------------------------------------- /BBoxTester/utils/android_manifest.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on Jul 8, 2014 3 | 4 | @author: Yury Zhauniarovich 5 | ''' 6 | from xml.dom import minidom 7 | from bbox_core.general_exceptions import MsgException 8 | 9 | 10 | 11 | class AndroidManifest: 12 | def __init__(self, pathAndroidManifest): 13 | self.pathAndroidManifest = pathAndroidManifest 14 | self.xml = minidom.parse(pathAndroidManifest) 15 | self.packageName = self.getElement("manifest", "package") 16 | 17 | def getUsesPermissions(self): 18 | return self.getElements("uses-permission", "android:name") 19 | 20 | def addUsesPermission(self, permName): 21 | if permName not in self.getUsesPermissions(): 22 | self.createElement("manifest", "uses-permission", {"android:name" : permName}) 23 | 24 | def getMainActivity(self): 25 | """ 26 | Return the name of the main activity 27 | 28 | :rtype: string 29 | """ 30 | x = set() 31 | y = set() 32 | 33 | for item in self.xml.getElementsByTagName("activity"): 34 | for sitem in item.getElementsByTagName("action") : 35 | val = sitem.getAttribute("android:name") 36 | if val == "android.intent.action.MAIN": 37 | x.add(item.getAttribute("android:name")) 38 | 39 | for sitem in item.getElementsByTagName("category") : 40 | val = sitem.getAttribute("android:name") 41 | if val == "android.intent.category.LAUNCHER": 42 | y.add(item.getAttribute("android:name")) 43 | 44 | z = x.intersection(y) 45 | if len(z) > 0 : 46 | return self.formatValue(z.pop()) 47 | return None 48 | 49 | def getActivities(self): 50 | """ 51 | Return the android:name attribute of all activities 52 | Return: 53 | :rtype: a list of string 54 | """ 55 | return self.getElements("activity", "android:name") 56 | 57 | def getServices(self): 58 | """ 59 | Return the android:name attribute of all services 60 | 61 | Return: 62 | :rtype: a list of string 63 | """ 64 | return self.getElements("service", "android:name") 65 | 66 | def getReceivers(self) : 67 | """ 68 | Return the android:name attribute of all receivers 69 | 70 | :rtype: a list of string 71 | """ 72 | return self.getElements("receiver", "android:name") 73 | 74 | def getIntentFilters(self, category, name): 75 | filters = [] 76 | for item in self.xml.getElementsByTagName(category): 77 | if self.formatValue(item.getAttribute("android:name")) == name: 78 | for sitem in item.getElementsByTagName("intent-filter"): 79 | filter = self._getIntentFilterDetails(sitem) 80 | filters.append(filter) 81 | return filters 82 | 83 | 84 | def _getIntentFilterDetails(self, sitem): 85 | d = {} 86 | d["action"] = [] 87 | d["category"] = [] 88 | d["mimeType"] = [] 89 | 90 | for ssitem in sitem.getElementsByTagName("action"): 91 | if ssitem.getAttribute("android:name") not in d["action"]: 92 | d["action"].append(ssitem.getAttribute("android:name")) 93 | for ssitem in sitem.getElementsByTagName("category"): 94 | if ssitem.getAttribute("android:name") not in d["category"]: 95 | d["category"].append(ssitem.getAttribute("android:name")) 96 | for ssitem in sitem.getElementsByTagName("data"): 97 | if ssitem.getAttribute("android:mimeType") not in d["mimeType"]: 98 | d["mimeType"].append(ssitem.getAttribute("android:mimeType")) 99 | 100 | if not d["action"]: 101 | del d["action"] 102 | 103 | if not d["category"]: 104 | del d["category"] 105 | 106 | if not d["mimeType"]: 107 | del d["mimeType"] 108 | 109 | return d 110 | 111 | def getActivityIntentFilters(self, name): 112 | return self.getIntentFilters("activity", name) 113 | 114 | def getServiceIntentFilters(self, name): 115 | return self.getIntentFilters("service", name) 116 | 117 | def getReceiverIntentFilters(self, name): 118 | return self.getIntentFilters("receiver", name) 119 | 120 | def addInstrumentation(self, instrumentationClassName, targetPackage): 121 | instr = self.getElements("instrumentation", "android:name") 122 | #TODO: Check if several instrumentations are possible 123 | if len(instr) > 0: 124 | raise ManifestAlreadyInstrumentedException() 125 | 126 | self.createElement("manifest", "instrumentation", 127 | {"android:name" : instrumentationClassName, 128 | "android:targetPackage" : targetPackage}) 129 | 130 | def removeExistingInstrumentation(self): 131 | instr = self.getElements("instrumentation", "android:name") 132 | if len(instr) <= 0: 133 | raise NoInstrumentationTagFound() 134 | for elem in instr: 135 | self.xml.removeChild(elem) 136 | 137 | 138 | def getPackageName(self): 139 | return self.packageName 140 | 141 | def getInstrumentationRunnerName(self): 142 | return self.getElement("instrumentation", "android:name") 143 | 144 | def getInstrumentationTargetPackage(self): 145 | return self.getElement("instrumentation", "android:targetPackage") 146 | 147 | def getElement(self, tag_name, attribute): 148 | """ 149 | Return element in xml files which matches with the tag name and the specific attribute 150 | 151 | :param tag_name: specify the tag name 152 | :type tag_name: string 153 | :param attribute: specify the attribute 154 | :type attribute: string 155 | 156 | :rtype: string 157 | """ 158 | for item in self.xml.getElementsByTagName(tag_name) : 159 | value = item.getAttribute(attribute) 160 | 161 | if len(value) > 0 : 162 | return value 163 | 164 | return None 165 | 166 | def getElements(self, tag_name, attribute): 167 | """ 168 | Return elements in xml files which match with the tag name and the specific attribute 169 | 170 | :param tag_name: a string which specify the tag name 171 | :param attribute: a string which specify the attribute 172 | """ 173 | l = [] 174 | for item in self.xml.getElementsByTagName(tag_name) : 175 | value = item.getAttribute(attribute) 176 | value = self.formatValue(value) 177 | l.append(str(value)) 178 | 179 | return l 180 | 181 | def formatValue(self, value) : 182 | if len(value) > 0 : 183 | if value[0] == "." : 184 | value = self.packageName + value 185 | else : 186 | v_dot = value.find(".") 187 | if v_dot == 0 : 188 | value = self.packageName + "." + value 189 | elif v_dot == -1 : 190 | value = self.packageName + "." + value 191 | return value 192 | 193 | def createElement(self, under_tag, tag, attributes): 194 | where = self.xml.getElementsByTagName(under_tag) #adding after the first occurrence 195 | if len(where) <= 0: 196 | raise NoTagException("Cannot find tag: %s" % under_tag) 197 | elem = self.xml.createElement(tag) 198 | if attributes: 199 | for entry in attributes.iteritems(): 200 | elem.setAttribute(entry[0], entry[1]) 201 | where[0].appendChild(elem) 202 | 203 | def getAndroidManifestXml(self): 204 | return self.xml.toprettyxml() 205 | 206 | def exportManifest(self, path=None): 207 | if not path: 208 | with open(self.pathAndroidManifest, "wb") as f: 209 | self.xml.writexml(f) 210 | else: 211 | with open(path, "wb") as f: 212 | self.xml.writexml(f) 213 | 214 | 215 | 216 | # Exception classes 217 | class NoTagException(MsgException): 218 | ''' 219 | No tag found in the manifest file. 220 | ''' 221 | 222 | class ManifestAlreadyInstrumentedException(MsgException): 223 | ''' 224 | Manifest already contains instrumentation tag. 225 | ''' 226 | 227 | class NoInstrumentationTagFound(MsgException): 228 | ''' 229 | No instrumentation tag found. 230 | ''' 231 | 232 | 233 | #=============================================================================== 234 | # androidManifest = AndroidManifest("/home/yury/research_tmp/BBTester_tst/notepad/AndroidManifest.xml") 235 | # print androidManifest.getPackageName() 236 | #=============================================================================== 237 | #=============================================================================== 238 | # androidManifest.addUsesPermission("com.zhauniarovich.permission") 239 | # androidManifest.addInstrumentation("com.example.instrumentation.EmmaInstrumentation", "com.example.i2at.tc") 240 | # print androidManifest.getAndroidManifestXml() 241 | # androidManifest.exportManifest("/home/yury/research_tmp/BBTester_tst/notepad/AndroidManifest1.xml") 242 | #=============================================================================== 243 | 244 | -------------------------------------------------------------------------------- /BBoxTester/interfaces/emma_interface.py: -------------------------------------------------------------------------------- 1 | import os 2 | import commander 3 | 4 | class EMMA_OUTMODE: 5 | COPY = "copy" 6 | OVERWRITE = "overwrite" 7 | FULLCOPY = "fullcopy" 8 | 9 | class EMMA_MERGE: 10 | YES = "yes" 11 | NO = "no" 12 | 13 | class EMMA_REPORT: 14 | HTML = "html" 15 | TXT = "txt" 16 | XML = "xml" 17 | 18 | class EmmaInterface: 19 | def __init__(self, javaPath="java", javaOpts="-Xms512m -Xmx1024m", pathEmma="./auxiliary/emma/", jarEmma="emma.jar", jarEmmaDevice="emma_device.jar"): 20 | self.javaPath = javaPath 21 | self.javaOpts = javaOpts 22 | self.pathEmma = pathEmma 23 | self.jarEmma = jarEmma 24 | self.jarEmmaDevice = jarEmmaDevice 25 | 26 | def _runEmmaCommand(self, commandString): 27 | cmd = "'%s' %s -cp %s" % (self.javaPath, self.javaOpts, commandString) 28 | return commander.runOnce(cmd) 29 | 30 | 31 | def _previewEmmaCmd(self, action, options): 32 | path = os.path.join(self.pathEmma, self.jarEmma) 33 | cmd = "'%s' %s %s" % (path, action, options) 34 | return cmd 35 | 36 | 37 | def _interpResultsEmmaInstrCmd(self, returnCode, outputStr): 38 | retCode = "Return code is: %s" % returnCode 39 | #NOTE: later we can select different routines to process different errors 40 | if returnCode == 1: 41 | output = "%s\n%s\n%s" % (retCode, "Failure due to incorrect option usage. This error code is also returned when command line usage (-h) is requested explicitly.", outputStr) 42 | return (False, output) 43 | if returnCode == 2: 44 | output = "%s\n%s\n%s" % (retCode, "Unknown failure happened.", outputStr) 45 | return (False, output) 46 | return (True, None) 47 | 48 | 49 | def getEmmaDeviceJarPath(self): 50 | path = os.path.join(self.pathEmma, self.jarEmmaDevice) 51 | return path 52 | 53 | def instr(self, instrpaths=[], outdir=None, emmaMetadataFile=None, merge=EMMA_MERGE.YES, outmode=EMMA_OUTMODE.COPY, commonOptions={}, filters=[]): 54 | ''' 55 | The command line interface can be found here: http://emma.sourceforge.net/reference/ch02s03s03.html 56 | Args: 57 | :param instrpaths: 58 | :param outdir: 59 | :param emmaMetadataFile: 60 | :param merge: 61 | :param outmode: 62 | :param filters: 63 | 64 | Returns: 65 | ''' 66 | options = "" 67 | if instrpaths: 68 | options += " -instrpath " 69 | for pth in instrpaths: 70 | options += "'%s'," % pth 71 | options = options[0:-1] 72 | 73 | if outdir: 74 | options += " -outdir '%s'" % outdir 75 | 76 | if emmaMetadataFile: 77 | options += " -outfile '%s'" % emmaMetadataFile 78 | 79 | options += " -merge %s" % merge 80 | options += " -outmode %s" % outmode 81 | 82 | if commonOptions: 83 | for entry in commonOptions.iteritems(): 84 | options += " -D%s=%s" % entry 85 | 86 | if filters: 87 | options += " -filter " 88 | for fltr in filters: 89 | options += "%s," % fltr 90 | options = options[0:-1] 91 | 92 | cmd = self._previewEmmaCmd("emma instr", options) 93 | (returnCode, outputStr) = self._runEmmaCommand(cmd) 94 | 95 | return self._interpResultsEmmaInstrCmd(returnCode, outputStr) 96 | 97 | 98 | def _interpResultsEmmaReportCmd(self, returnCode, outputStr): 99 | retCode = "Return code is: %s" % returnCode 100 | #NOTE: later we can select different routines to process different errors 101 | if returnCode == 1: 102 | output = "%s\n%s\n%s" % (retCode, "Failure due to incorrect option usage. This error code is also returned when command line usage (-h) is requested explicitly.", outputStr) 103 | return (False, output) 104 | if returnCode == 2: 105 | output = "%s\n%s\n%s" % (retCode, "Unknown failure happened.", outputStr) 106 | return (False, output) 107 | return (True, None) 108 | 109 | 110 | def report(self, inputs=[], report=EMMA_REPORT.HTML, sourcepath=[], commonOptions={}): 111 | ''' 112 | The description of the command can be found here: http://emma.sourceforge.net/reference/ch02s04s03.html 113 | :param inputs: 114 | :param report: 115 | :param sourcepath: 116 | :param commonOptions: 117 | ''' 118 | """Genoptions can be seen here: http://emma.sourceforge.net/reference/ch03s02.html#prop-ref.report.out.file""" 119 | options = "" 120 | if inputs: 121 | options += " -input " 122 | for f in inputs: 123 | options += f + "," 124 | options = options[0:-1] 125 | 126 | options += " -report " + report 127 | 128 | if sourcepath: 129 | options += " -sourcepath " 130 | for src in sourcepath: 131 | options += src + "," 132 | options = options[0:-1] 133 | 134 | if commonOptions: 135 | for entry in commonOptions.iteritems(): 136 | options += " -D" + entry[0] + "=" + entry[1] 137 | 138 | cmd = self._previewEmmaCmd("emma report", options) 139 | (returnCode, outputStr) = self._runEmmaCommand(cmd) 140 | return self._interpResultsEmmaReportCmd(returnCode, outputStr) 141 | 142 | def reportToDir(self, inputs=[], toDir=None, report=EMMA_REPORT.HTML, sourcepath=[], commonoptions={}): 143 | ''' 144 | This method produce a report into the specified directory. 145 | 146 | Args: 147 | :param inputs: 148 | :param toDir: 149 | :param report: 150 | :param sourcepath: 151 | :param commonoptions: 152 | 153 | Returns: 154 | ''' 155 | options = "" 156 | if inputs: 157 | options += " -input " 158 | for f in inputs: 159 | options += f + "," 160 | options = options[0:-1] 161 | 162 | options += " -report " + report 163 | 164 | if sourcepath: 165 | options += " -sourcepath " 166 | for src in sourcepath: 167 | options += src + "," 168 | options = options[0:-1] 169 | 170 | if toDir: 171 | if report == EMMA_REPORT.HTML: 172 | opt = "report.html.out.file" 173 | value = os.path.join(toDir, "coverage", "index.html") 174 | elif report == EMMA_REPORT.XML: 175 | opt = "report.xml.out.file" 176 | value = os.path.join(toDir, "coverage.xml") 177 | elif report == EMMA_REPORT.TXT: 178 | opt = "report.txt.out.file" 179 | value = os.path.join(toDir, "coverage.txt") 180 | options += " -D%s=%s" % (opt, value) 181 | 182 | if commonoptions: 183 | for entry in commonoptions.iteritems(): 184 | options += " -D" + entry[0] + "=" + entry[1] 185 | 186 | cmd = self._previewEmmaCmd("emma report", options) 187 | (returnCode, outputStr) = self._runEmmaCommand(cmd) 188 | return self._interpResultsEmmaReportCmd(returnCode, outputStr) 189 | 190 | 191 | def reportToDirWithName(self, inputs=[], toDir=None, mainFileName=None, report=EMMA_REPORT.HTML, sourcepath=[], commonoptions={}): 192 | ''' 193 | This method produce a report into the specified directory. 194 | 195 | Args: 196 | :param inputs: 197 | :param toDir: 198 | :param mainFileName: 199 | :param report: 200 | :param sourcepath: 201 | :param commonoptions: 202 | 203 | Returns: 204 | ''' 205 | options = "" 206 | if inputs: 207 | options += " -input " 208 | for f in inputs: 209 | options += f + "," 210 | options = options[0:-1] 211 | 212 | options += " -report " + report 213 | 214 | if sourcepath: 215 | options += " -sourcepath " 216 | for src in sourcepath: 217 | options += src + "," 218 | options = options[0:-1] 219 | 220 | if not mainFileName: 221 | mainFileName = "coverage" 222 | if not toDir: 223 | toDir="" 224 | 225 | if report == EMMA_REPORT.HTML: 226 | opt = "report.html.out.file" 227 | value = os.path.join(toDir, "coverage", "%s.html" % mainFileName) 228 | elif report == EMMA_REPORT.XML: 229 | opt = "report.xml.out.file" 230 | value = os.path.join(toDir, "%s.xml" % mainFileName) 231 | elif report == EMMA_REPORT.TXT: 232 | opt = "report.txt.out.file" 233 | value = os.path.join(toDir, "%s.txt" % mainFileName) 234 | options += " -D%s=%s" % (opt, value) 235 | 236 | if commonoptions: 237 | for entry in commonoptions.iteritems(): 238 | options += " -D" + entry[0] + "=" + entry[1] 239 | 240 | cmd = self._previewEmmaCmd("emma report", options) 241 | (returnCode, outputStr) = self._runEmmaCommand(cmd) 242 | return self._interpResultsEmmaReportCmd(returnCode, outputStr) 243 | 244 | #=============================================================================== 245 | # emma_helper = EmmaInterface() 246 | # emma_helper.report(inputs=["coverage.ec", "coverage.em"], commonoptions={"report.html.out.file" : "mycoverage/coverage.html", "testkey" : "testvalue"}) 247 | #=============================================================================== 248 | 249 | -------------------------------------------------------------------------------- /BBoxTester/bbox_core/bbox_config.py: -------------------------------------------------------------------------------- 1 | import os 2 | import ConfigParser 3 | from utils import auxiliary_utils 4 | 5 | 6 | DEFAULT_CONFIG= { 7 | "GENERAL" : { 8 | "DECOMPILED_APK_RELATIVE_DIR" : "decompiled_apk", 9 | "COVERAGE_METADATA_RELATIVE_DIR" : "coverage_metadata", 10 | "COVERAGE_METADATA_FILENAME" : "coverage.em", 11 | "REPORTS_RELATIVE_DIR" : "reports", 12 | "RUNTIME_REPORTS_RELATIVE_DIR" : "runtime_reports", 13 | "TMP_JAR_RELATIVE_DIR" : "jars", 14 | "INSTRUMENTED_FILES_RELATIVE_DIR" : "instrumented", 15 | "INSTRUMENTED_FILE_SUFFIX" : "_instr", 16 | "FINAL_INSTRUMENTED_FILE_SUFFIX" : "_instr_final", 17 | "SIGNED_FILE_SUFFIX" : "_signed", 18 | "ALIGNED_FILE_SUFFIX" : "_aligned", 19 | # "DELETE_TMP_DIR" : "False", 20 | }, 21 | "AAPT" : { 22 | "AAPT_DIR" : "./auxiliary/aapt", 23 | "AAPT_EXECUTABLE" : "aapt", 24 | }, 25 | "APKTOOL" : { 26 | "APKTOOL_JAVA_PATH" : "java", # it is possible that some tools will require different versions of java 27 | "APKTOOL_JAVA_OPTS" : "-Xms512m -Xmx1024m", 28 | "APKTOOL_PATH" : "./auxiliary/apktool", 29 | "APKTOOL_JAR" : "apktool.jar", 30 | "APKTOOL_QUITE" : "True" 31 | }, 32 | "DEX2JAR" : { 33 | "DEX2JAR_JAVA_PATH" : "java", 34 | "DEX2JAR_JAVA_OPTS" : "-Xms512m -Xmx1024m", 35 | "DEX2JAR_LIBS_PATH" : "./auxiliary/dex2jar/lib", 36 | "DEX2JAR_CLASS_DEX2JAR" : "com.googlecode.dex2jar.tools.Dex2jarCmd", 37 | "DEX2JAR_CLASS_APKSIGN" : "com.googlecode.dex2jar.tools.ApkSign", 38 | #"DEX2JAR_" : "", 39 | #"DEX2JAR_" : "", 40 | }, 41 | "DX" : { 42 | "DX_JAVA_PATH" : "java", 43 | "DX_JAVA_OPTS" : "-Xms512m -Xmx1024m", 44 | "DX_PATH" : "./auxiliary/dx", 45 | "DX_JAR" : "dx.jar" 46 | }, 47 | "EMMA" : { 48 | "EMMA_JAVA_PATH" : "java", 49 | "EMMA_JAVA_OPTS" : "-Xms512m -Xmx1024m", 50 | "EMMA_DIR" : "./auxiliary/emma", 51 | "EMMA_JAR" : "emma.jar", 52 | "EMMA_DEVICE_JAR" : "emma_device.jar", 53 | "EMMA_RESOURCES_DIR" : "./auxiliary/emma/resources", 54 | "ANDROID_SPECIFIC_INSTRUMENTATION_CLASSES_PATH": "./auxiliary/instrument_classes/", #trailing slash is important 55 | }, 56 | "ZIPALIGN" : { 57 | "ZIPALIGN_DIR" : "./auxiliary/zipalign", 58 | "ZIPALIGN_EXE" : "zipalign", 59 | }, 60 | } 61 | 62 | class BBoxConfig: 63 | def __init__(self, pathToConfigFile="./config/bbox_config.ini"): 64 | #TODO: May be it's worth to add check if path is None or exist 65 | self.config = ConfigParser.ConfigParser() 66 | read_files = self.config.read(pathToConfigFile) 67 | self.isRealFile = False 68 | if read_files: #file is read 69 | self.isRealFile = True 70 | 71 | 72 | 73 | # #GENERAL 74 | # def deleteTmpDirAfterInstrumentation(self): 75 | # section = "GENERAL" 76 | # option = "DELETE_TMP_DIR" 77 | # return auxiliary_utils.to_bool(self._getOption(section, option)) 78 | 79 | def getDecompiledApkRelativeDir(self): 80 | section = "GENERAL" 81 | option = "DECOMPILED_APK_RELATIVE_DIR" 82 | return self._getOption(section, option) 83 | 84 | def getCoverageMetadataRelativeDir(self): 85 | section = "GENERAL" 86 | option = "COVERAGE_METADATA_RELATIVE_DIR" 87 | return self._getOption(section, option) 88 | 89 | def getCoverageMetadataFilename(self): 90 | section = "GENERAL" 91 | option = "COVERAGE_METADATA_FILENAME" 92 | return self._getOption(section, option) 93 | 94 | def getReportsRelativeDir(self): 95 | section = "GENERAL" 96 | option = "REPORTS_RELATIVE_DIR" 97 | return self._getOption(section, option) 98 | 99 | def getRuntimeReportsRelativeDir(self): 100 | section = "GENERAL" 101 | option = "RUNTIME_REPORTS_RELATIVE_DIR" 102 | return self._getOption(section, option) 103 | 104 | def getInstrumentedFilesRelativeDir(self): 105 | section = "GENERAL" 106 | option = "INSTRUMENTED_FILES_RELATIVE_DIR" 107 | return self._getOption(section, option) 108 | 109 | def getTmpJarRelativeDir(self): 110 | section = "GENERAL" 111 | option = "TMP_JAR_RELATIVE_DIR" 112 | return self._getOption(section, option) 113 | 114 | def getInstrFileSuffix(self): 115 | section = "GENERAL" 116 | option = "INSTRUMENTED_FILE_SUFFIX" 117 | return self._getOption(section, option) 118 | 119 | def getFinalInstrFileSuffix(self): 120 | section = "GENERAL" 121 | option = "FINAL_INSTRUMENTED_FILE_SUFFIX" 122 | return self._getOption(section, option) 123 | 124 | def getSignedFileSuffix(self): 125 | section = "GENERAL" 126 | option = "SIGNED_FILE_SUFFIX" 127 | return self._getOption(section, option) 128 | 129 | def getAlignedFileSuffix(self): 130 | section = "GENERAL" 131 | option = "ALIGNED_FILE_SUFFIX" 132 | return self._getOption(section, option) 133 | 134 | 135 | 136 | #AAPT 137 | def getAaptDir(self): 138 | section = "AAPT" 139 | option = "AAPT_DIR" 140 | return self._getOption(section, option) 141 | 142 | def getAaptExecutable(self): 143 | section = "AAPT" 144 | option = "AAPT_EXECUTABLE" 145 | return self._getOption(section, option) 146 | 147 | def getAaptPath(self): 148 | return os.path.join(self.getAaptDir(), self.getAaptExecutable()) 149 | 150 | 151 | 152 | #APKTOOL 153 | def getApktoolJavaPath(self): 154 | section = "APKTOOL" 155 | option = "APKTOOL_JAVA_PATH" 156 | return self._getOption(section, option) 157 | 158 | def getApktoolJavaOpts(self): 159 | section = "APKTOOL" 160 | option = "APKTOOL_JAVA_OPTS" 161 | return self._getOption(section, option) 162 | 163 | def getApktoolPath(self): 164 | section = "APKTOOL" 165 | option = "APKTOOL_PATH" 166 | return self._getOption(section, option) 167 | 168 | def getApktoolJar(self): 169 | section = "APKTOOL" 170 | option = "APKTOOL_JAR" 171 | return self._getOption(section, option) 172 | 173 | def getQuiteOptionValue(self): 174 | section = "APKTOOL" 175 | option = "APKTOOL_QUITE" 176 | return self._getOption(section, option) 177 | 178 | 179 | 180 | #DEX2JAR 181 | def getDex2JarJavaPath(self): 182 | section = "DEX2JAR" 183 | option = "DEX2JAR_JAVA_PATH" 184 | return self._getOption(section, option) 185 | 186 | def getDex2JarJavaOpts(self): 187 | section = "DEX2JAR" 188 | option = "DEX2JAR_JAVA_OPTS" 189 | return self._getOption(section, option) 190 | 191 | def getDex2LibsPath(self): 192 | section = "DEX2JAR" 193 | option = "DEX2JAR_LIBS_PATH" 194 | return self._getOption(section, option) 195 | 196 | def getDex2JarClassForDex2Jar(self): 197 | section = "DEX2JAR" 198 | option = "DEX2JAR_CLASS_DEX2JAR" 199 | return self._getOption(section, option) 200 | 201 | def getDex2JarClassForApksign(self): 202 | section = "DEX2JAR" 203 | option = "DEX2JAR_CLASS_APKSIGN" 204 | return self._getOption(section, option) 205 | 206 | 207 | 208 | #DX 209 | def getDxJavaPath(self): 210 | section = "DX" 211 | option = "DX_JAVA_PATH" 212 | return self._getOption(section, option) 213 | 214 | def getDxJavaOpts(self): 215 | section = "DX" 216 | option = "DX_JAVA_OPTS" 217 | return self._getOption(section, option) 218 | 219 | def getDxPath(self): 220 | section = "DX" 221 | option = "DX_PATH" 222 | return self._getOption(section, option) 223 | 224 | def getDxJar(self): 225 | section = "DX" 226 | option = "DX_JAR" 227 | return self._getOption(section, option) 228 | 229 | 230 | 231 | #EMMA 232 | def getEmmaJavaPath(self): 233 | section = "EMMA" 234 | option = "EMMA_JAVA_PATH" 235 | return self._getOption(section, option) 236 | 237 | def getEmmaJavaOpts(self): 238 | section = "EMMA" 239 | option = "EMMA_JAVA_OPTS" 240 | return self._getOption(section, option) 241 | 242 | def getEmmaDir(self): 243 | section = "EMMA" 244 | option = "EMMA_DIR" 245 | return self._getOption(section, option) 246 | 247 | def getEmmaJar(self): 248 | section = "EMMA" 249 | option = "EMMA_JAR" 250 | return self._getOption(section, option) 251 | 252 | def getEmmaDeviceJar(self): 253 | section = "EMMA" 254 | option = "EMMA_DEVICE_JAR" 255 | return self._getOption(section, option) 256 | 257 | def getEmmaResourcesDir(self): 258 | section = "EMMA" 259 | option = "EMMA_RESOURCES_DIR" 260 | return self._getOption(section, option) 261 | 262 | def getAndroidSpecificInstrumentationClassesPath(self): 263 | section = "EMMA" 264 | option = "ANDROID_SPECIFIC_INSTRUMENTATION_CLASSES_PATH" 265 | return self._getOption(section, option) 266 | 267 | 268 | 269 | #ZIPALIGN 270 | def getZipalignDir(self): 271 | section = "ZIPALIGN" 272 | option = "ZIPALIGN_DIR" 273 | return self._getOption(section, option) 274 | 275 | def getZipalingExe(self): 276 | section = "ZIPALIGN" 277 | option = "ZIPALIGN_EXE" 278 | return self._getOption(section, option) 279 | 280 | 281 | #AUXILIARY METHODS 282 | def _getOption(self, section, option): 283 | value = self._getOptionFromConfigFile(section, option) 284 | if not value: 285 | value = DEFAULT_CONFIG[section][option] 286 | return value 287 | 288 | def _getOptionFromConfigFile(self, section, option): 289 | value = None 290 | if self.isRealFile: 291 | try: 292 | value = self.config.get(section, option) 293 | except: 294 | value = None 295 | return value 296 | 297 | 298 | 299 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/dx-NOTICE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2005-2008, The Android Open Source Project 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | 13 | 14 | Apache License 15 | Version 2.0, January 2004 16 | http://www.apache.org/licenses/ 17 | 18 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 19 | 20 | 1. Definitions. 21 | 22 | "License" shall mean the terms and conditions for use, reproduction, 23 | and distribution as defined by Sections 1 through 9 of this document. 24 | 25 | "Licensor" shall mean the copyright owner or entity authorized by 26 | the copyright owner that is granting the License. 27 | 28 | "Legal Entity" shall mean the union of the acting entity and all 29 | other entities that control, are controlled by, or are under common 30 | control with that entity. For the purposes of this definition, 31 | "control" means (i) the power, direct or indirect, to cause the 32 | direction or management of such entity, whether by contract or 33 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 34 | outstanding shares, or (iii) beneficial ownership of such entity. 35 | 36 | "You" (or "Your") shall mean an individual or Legal Entity 37 | exercising permissions granted by this License. 38 | 39 | "Source" form shall mean the preferred form for making modifications, 40 | including but not limited to software source code, documentation 41 | source, and configuration files. 42 | 43 | "Object" form shall mean any form resulting from mechanical 44 | transformation or translation of a Source form, including but 45 | not limited to compiled object code, generated documentation, 46 | and conversions to other media types. 47 | 48 | "Work" shall mean the work of authorship, whether in Source or 49 | Object form, made available under the License, as indicated by a 50 | copyright notice that is included in or attached to the work 51 | (an example is provided in the Appendix below). 52 | 53 | "Derivative Works" shall mean any work, whether in Source or Object 54 | form, that is based on (or derived from) the Work and for which the 55 | editorial revisions, annotations, elaborations, or other modifications 56 | represent, as a whole, an original work of authorship. For the purposes 57 | of this License, Derivative Works shall not include works that remain 58 | separable from, or merely link (or bind by name) to the interfaces of, 59 | the Work and Derivative Works thereof. 60 | 61 | "Contribution" shall mean any work of authorship, including 62 | the original version of the Work and any modifications or additions 63 | to that Work or Derivative Works thereof, that is intentionally 64 | submitted to Licensor for inclusion in the Work by the copyright owner 65 | or by an individual or Legal Entity authorized to submit on behalf of 66 | the copyright owner. For the purposes of this definition, "submitted" 67 | means any form of electronic, verbal, or written communication sent 68 | to the Licensor or its representatives, including but not limited to 69 | communication on electronic mailing lists, source code control systems, 70 | and issue tracking systems that are managed by, or on behalf of, the 71 | Licensor for the purpose of discussing and improving the Work, but 72 | excluding communication that is conspicuously marked or otherwise 73 | designated in writing by the copyright owner as "Not a Contribution." 74 | 75 | "Contributor" shall mean Licensor and any individual or Legal Entity 76 | on behalf of whom a Contribution has been received by Licensor and 77 | subsequently incorporated within the Work. 78 | 79 | 2. Grant of Copyright License. Subject to the terms and conditions of 80 | this License, each Contributor hereby grants to You a perpetual, 81 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 82 | copyright license to reproduce, prepare Derivative Works of, 83 | publicly display, publicly perform, sublicense, and distribute the 84 | Work and such Derivative Works in Source or Object form. 85 | 86 | 3. Grant of Patent License. Subject to the terms and conditions of 87 | this License, each Contributor hereby grants to You a perpetual, 88 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 89 | (except as stated in this section) patent license to make, have made, 90 | use, offer to sell, sell, import, and otherwise transfer the Work, 91 | where such license applies only to those patent claims licensable 92 | by such Contributor that are necessarily infringed by their 93 | Contribution(s) alone or by combination of their Contribution(s) 94 | with the Work to which such Contribution(s) was submitted. If You 95 | institute patent litigation against any entity (including a 96 | cross-claim or counterclaim in a lawsuit) alleging that the Work 97 | or a Contribution incorporated within the Work constitutes direct 98 | or contributory patent infringement, then any patent licenses 99 | granted to You under this License for that Work shall terminate 100 | as of the date such litigation is filed. 101 | 102 | 4. Redistribution. You may reproduce and distribute copies of the 103 | Work or Derivative Works thereof in any medium, with or without 104 | modifications, and in Source or Object form, provided that You 105 | meet the following conditions: 106 | 107 | (a) You must give any other recipients of the Work or 108 | Derivative Works a copy of this License; and 109 | 110 | (b) You must cause any modified files to carry prominent notices 111 | stating that You changed the files; and 112 | 113 | (c) You must retain, in the Source form of any Derivative Works 114 | that You distribute, all copyright, patent, trademark, and 115 | attribution notices from the Source form of the Work, 116 | excluding those notices that do not pertain to any part of 117 | the Derivative Works; and 118 | 119 | (d) If the Work includes a "NOTICE" text file as part of its 120 | distribution, then any Derivative Works that You distribute must 121 | include a readable copy of the attribution notices contained 122 | within such NOTICE file, excluding those notices that do not 123 | pertain to any part of the Derivative Works, in at least one 124 | of the following places: within a NOTICE text file distributed 125 | as part of the Derivative Works; within the Source form or 126 | documentation, if provided along with the Derivative Works; or, 127 | within a display generated by the Derivative Works, if and 128 | wherever such third-party notices normally appear. The contents 129 | of the NOTICE file are for informational purposes only and 130 | do not modify the License. You may add Your own attribution 131 | notices within Derivative Works that You distribute, alongside 132 | or as an addendum to the NOTICE text from the Work, provided 133 | that such additional attribution notices cannot be construed 134 | as modifying the License. 135 | 136 | You may add Your own copyright statement to Your modifications and 137 | may provide additional or different license terms and conditions 138 | for use, reproduction, or distribution of Your modifications, or 139 | for any such Derivative Works as a whole, provided Your use, 140 | reproduction, and distribution of the Work otherwise complies with 141 | the conditions stated in this License. 142 | 143 | 5. Submission of Contributions. Unless You explicitly state otherwise, 144 | any Contribution intentionally submitted for inclusion in the Work 145 | by You to the Licensor shall be under the terms and conditions of 146 | this License, without any additional terms or conditions. 147 | Notwithstanding the above, nothing herein shall supersede or modify 148 | the terms of any separate license agreement you may have executed 149 | with Licensor regarding such Contributions. 150 | 151 | 6. Trademarks. This License does not grant permission to use the trade 152 | names, trademarks, service marks, or product names of the Licensor, 153 | except as required for reasonable and customary use in describing the 154 | origin of the Work and reproducing the content of the NOTICE file. 155 | 156 | 7. Disclaimer of Warranty. Unless required by applicable law or 157 | agreed to in writing, Licensor provides the Work (and each 158 | Contributor provides its Contributions) on an "AS IS" BASIS, 159 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 160 | implied, including, without limitation, any warranties or conditions 161 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 162 | PARTICULAR PURPOSE. You are solely responsible for determining the 163 | appropriateness of using or redistributing the Work and assume any 164 | risks associated with Your exercise of permissions under this License. 165 | 166 | 8. Limitation of Liability. In no event and under no legal theory, 167 | whether in tort (including negligence), contract, or otherwise, 168 | unless required by applicable law (such as deliberate and grossly 169 | negligent acts) or agreed to in writing, shall any Contributor be 170 | liable to You for damages, including any direct, indirect, special, 171 | incidental, or consequential damages of any character arising as a 172 | result of this License or out of the use or inability to use the 173 | Work (including but not limited to damages for loss of goodwill, 174 | work stoppage, computer failure or malfunction, or any and all 175 | other commercial damages or losses), even if such Contributor 176 | has been advised of the possibility of such damages. 177 | 178 | 9. Accepting Warranty or Additional Liability. While redistributing 179 | the Work or Derivative Works thereof, You may choose to offer, 180 | and charge a fee for, acceptance of support, warranty, indemnity, 181 | or other liability obligations and/or rights consistent with this 182 | License. However, in accepting such obligations, You may act only 183 | on Your own behalf and on Your sole responsibility, not on behalf 184 | of any other Contributor, and only if You agree to indemnify, 185 | defend, and hold each Contributor harmless for any liability 186 | incurred by, or claims asserted against, such Contributor by reason 187 | of your accepting any such warranty or additional liability. 188 | 189 | END OF TERMS AND CONDITIONS 190 | 191 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | -------------------------------------------------------------------------------- /BBoxTester/auxiliary/dex2jar/lib/commons-io-LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | -------------------------------------------------------------------------------- /BBoxTester_Instr_Sources/src/com/zhauniarovich/bbtester/EmmaInstrumentation.java: -------------------------------------------------------------------------------- 1 | package com.zhauniarovich.bbtester; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.File; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.io.PrintWriter; 8 | import java.io.StringWriter; 9 | import java.lang.reflect.InvocationTargetException; 10 | import java.lang.reflect.Method; 11 | import java.util.Map; 12 | import java.util.Set; 13 | 14 | import android.app.Activity; 15 | import android.app.Application; 16 | import android.app.Instrumentation; 17 | import android.app.Service; 18 | import android.content.BroadcastReceiver; 19 | import android.content.Context; 20 | import android.content.Intent; 21 | import android.content.IntentFilter; 22 | import android.os.Bundle; 23 | import android.os.Handler; 24 | import android.os.HandlerThread; 25 | import android.os.Looper; 26 | import android.os.Message; 27 | import android.util.Log; 28 | import android.os.Process; 29 | 30 | public class EmmaInstrumentation extends Instrumentation implements Handler.Callback { 31 | private static final String TAG = "EmmaInstrumentation"; 32 | private static final boolean LOGD = true; 33 | 34 | private final static String DEFAULT_REPORT_ROOTDIR = "/mnt/sdcard"; 35 | private static final String ERRORS_FILENAME = "errors.txt"; 36 | // private static final int SHELL_UID = android.os.Process.getUidForName("shell"); 37 | 38 | private static final String ACTION_FINISH_TESTING = "com.zhauniarovich.bbtester.finishtesting"; 39 | 40 | private static final String PREFIX_ONSTOP = "onstop"; 41 | private static final String PREFIX_ONERROR = "onerror"; 42 | 43 | 44 | private final Bundle mResults = new Bundle(); 45 | 46 | private static final String KEY_COVERAGE = "coverage"; 47 | private static final String KEY_PROCEED_ON_ERROR = "proceedOnError"; 48 | private static final String KEY_GENERATE_COVERAGE_REPORT_ON_ERROR = "generateCoverageReportOnError"; 49 | private static final String KEY_REPORT_FOLDER = "coverageDir"; 50 | private static final String KEY_CANCEL_ANALYSIS = "cancelAnalysis"; 51 | 52 | private boolean mCoverage = true; 53 | private boolean generateCoverageOnError = true; 54 | private boolean proceedOnError = false; 55 | private boolean cancelAnalysis = false; 56 | 57 | private File reportDir = null; 58 | private File errorFile = null; 59 | 60 | private static int errorCounter = 0; 61 | 62 | 63 | private Handler handler; 64 | 65 | /** 66 | * Constructor 67 | */ 68 | public EmmaInstrumentation() { 69 | super(); 70 | if (LOGD) { 71 | Log.d(TAG, "Constructor Thread: " + Thread.currentThread().getName()); 72 | } 73 | } 74 | 75 | @Override 76 | public void onCreate(Bundle arguments) { 77 | super.onCreate(arguments); 78 | if (LOGD) { 79 | Log.d(TAG, "onCreate Thread: " + Thread.currentThread().getName()); 80 | } 81 | if (arguments == null) { 82 | Log.e(TAG, "Cannot start our instrumentation! Arguments are null!"); 83 | finish(Activity.RESULT_CANCELED, mResults); 84 | return; 85 | } 86 | 87 | String reportDirPath; 88 | 89 | mCoverage = getBooleanArgument(arguments, KEY_COVERAGE); 90 | reportDirPath = arguments.getString(KEY_REPORT_FOLDER, null); 91 | if (reportDirPath == null) { 92 | reportDirPath = (new File(DEFAULT_REPORT_ROOTDIR, getComponentName().getPackageName())).getAbsolutePath(); 93 | } 94 | proceedOnError = getBooleanArgument(arguments, KEY_PROCEED_ON_ERROR); 95 | generateCoverageOnError = getBooleanArgument(arguments, KEY_GENERATE_COVERAGE_REPORT_ON_ERROR); 96 | 97 | 98 | reportDir = new File(reportDirPath); 99 | boolean success = reportDir.mkdirs(); 100 | if (LOGD) { 101 | Log.d(TAG, "ReportDir created: " + success); 102 | } 103 | errorFile = new File(reportDir, ERRORS_FILENAME); 104 | 105 | if (LOGD) { 106 | Log.d(TAG, "Intent: " + arguments.toString()); 107 | } 108 | 109 | HandlerThread handlerThread = new HandlerThread("MyNewThread"); 110 | handlerThread.start(); 111 | Looper looper = handlerThread.getLooper(); 112 | handler = new Handler(looper, this); 113 | 114 | IntentFilter iFilter = new IntentFilter(ACTION_FINISH_TESTING); 115 | getContext().registerReceiver(mMessageReceiver, iFilter, null, handler); 116 | 117 | start(); 118 | if (LOGD) { 119 | Log.d(TAG, "After start!"); 120 | } 121 | } 122 | 123 | @Override 124 | public void onStart() { 125 | super.onStart(); 126 | if (LOGD) { 127 | Log.d(TAG, "onStart Thread: " + Thread.currentThread().getName()); 128 | } 129 | Looper.prepare(); 130 | } 131 | 132 | private boolean getBooleanArgument(Bundle arguments, String tag) { 133 | String tagString = arguments.getString(tag); 134 | return tagString != null && Boolean.parseBoolean(tagString); 135 | } 136 | 137 | private void generateCoverageReport(String filename) { 138 | if (LOGD) { 139 | Log.d(TAG, ""); 140 | } 141 | java.io.File coverageFile = new java.io.File(reportDir, filename); 142 | if (LOGD) 143 | Log.d(TAG, "generateCoverageReport(): " + coverageFile.getAbsolutePath()); 144 | // We may use this if we want to avoid reflection and we include 145 | // emma.jar 146 | // RT.dumpCoverageData(coverageFile, false, false); 147 | 148 | // Use reflection to call emma dump coverage method, to avoid 149 | // always statically compiling against emma jar 150 | try { 151 | Class emmaRTClass = Class.forName("com.vladium.emma.rt.RT"); 152 | Method dumpCoverageMethod = emmaRTClass.getMethod( 153 | "dumpCoverageData", coverageFile.getClass(), boolean.class, 154 | boolean.class); 155 | dumpCoverageMethod.invoke(null, coverageFile, false, false); 156 | } catch (ClassNotFoundException e) { 157 | reportEmmaError("Is emma jar on classpath?", e); 158 | } catch (SecurityException e) { 159 | reportEmmaError(e); 160 | } catch (NoSuchMethodException e) { 161 | reportEmmaError(e); 162 | } catch (IllegalArgumentException e) { 163 | reportEmmaError(e); 164 | } catch (IllegalAccessException e) { 165 | reportEmmaError(e); 166 | } catch (InvocationTargetException e) { 167 | reportEmmaError(e); 168 | } 169 | } 170 | 171 | private void reportEmmaError(Exception e) { 172 | reportEmmaError("", e); 173 | } 174 | 175 | private void reportEmmaError(String hint, Exception e) { 176 | String msg = "Failed to generate emma coverage. " + hint; 177 | Log.e(TAG, msg, e); 178 | mResults.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "\nError: " 179 | + msg); 180 | } 181 | 182 | 183 | 184 | /** 185 | * BroadcastReceiver handler for intent sending to finish testing of application. 186 | */ 187 | private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { 188 | @Override 189 | public void onReceive(Context context, Intent intent) { 190 | // TODO: Check this code later 191 | //checking that the intent is sent from the adb shell 192 | // final int callingUid = Binder.getCallingUid(); 193 | // if (callingUid != SHELL_UID) { 194 | // return; 195 | // } 196 | if (LOGD) { 197 | Log.d(TAG, "onReceive Thread: " + Thread.currentThread().getName()); 198 | } 199 | 200 | final Bundle arguments = intent.getExtras(); 201 | if (arguments != null) { 202 | cancelAnalysis = arguments.getBoolean(KEY_CANCEL_ANALYSIS, false); 203 | } 204 | 205 | if (cancelAnalysis) { 206 | removeDirectory(reportDir); 207 | handler.sendEmptyMessage(0); 208 | return; 209 | } 210 | 211 | if (mCoverage) { 212 | final long currentTime = System.currentTimeMillis(); 213 | String filename = PREFIX_ONSTOP + "_coverage_" + String.valueOf(currentTime) + ".ec"; 214 | generateCoverageReport(filename); 215 | } 216 | 217 | handler.sendEmptyMessage(0); 218 | } 219 | }; 220 | 221 | @Override 222 | public void finish(int resultCode, Bundle results) { 223 | if (LOGD) { 224 | Log.d(TAG, "Finish Thread: " + Thread.currentThread().getName()); 225 | } 226 | super.finish(resultCode, results); 227 | } 228 | 229 | @Override 230 | public void onDestroy() { 231 | if (LOGD) { 232 | Log.d(TAG, "OnDestroy Thread: " + Thread.currentThread().getName()); 233 | } 234 | getContext().unregisterReceiver(mMessageReceiver); 235 | handler = null; 236 | super.onDestroy(); 237 | } 238 | 239 | @Override 240 | public boolean onException(Object obj, Throwable e) { 241 | if (LOGD) { 242 | Log.d(TAG, "OnException Thread: " + Thread.currentThread().getName()); 243 | } 244 | 245 | long currentTimeMillis = System.currentTimeMillis(); 246 | String coverageFileName = null; 247 | if (generateCoverageOnError) { 248 | coverageFileName = PREFIX_ONERROR + "_coverage_" + String.valueOf(currentTimeMillis) + ".ec"; 249 | generateCoverageReport(coverageFileName); 250 | } 251 | 252 | try { 253 | appendError(currentTimeMillis, coverageFileName, obj, e); 254 | } 255 | catch(IOException exc) { 256 | exc.printStackTrace(); 257 | } 258 | 259 | //true - continue to execute tests, false - let the exception to be fired 260 | return proceedOnError; 261 | } 262 | 263 | private void appendError(long timeMillis, String coverageFileName, Object obj, Throwable e) throws IOException { 264 | String errorComp; 265 | if (obj == null) { 266 | errorComp = "null"; 267 | } 268 | else if (obj instanceof Application) { 269 | errorComp = "Application"; 270 | } 271 | else if (obj instanceof Activity) { 272 | errorComp = "Activity"; 273 | } 274 | else if (obj instanceof Service) { 275 | errorComp = "Service"; 276 | } 277 | else if (obj instanceof BroadcastReceiver) { 278 | errorComp = "BroadcastReceiver"; 279 | } 280 | else { 281 | errorComp = obj.getClass().getSimpleName(); 282 | } 283 | 284 | String errorSource = "null"; 285 | if (obj != null) { 286 | errorSource = obj.getClass().getName(); 287 | } 288 | 289 | 290 | StringBuffer errorStr = new StringBuffer(); 291 | 292 | errorStr.append("ErrorCount: ").append(errorCounter++).append("\n"); 293 | errorStr.append("Time: ").append(timeMillis).append("\n"); 294 | errorStr.append("CoverageFile: ").append(coverageFileName != null ? coverageFileName : "").append("\n"); 295 | errorStr.append("PackageName: ").append(getComponentName().getPackageName()).append("\n"); 296 | errorStr.append("ProcessPid: ").append(Process.myPid()).append("\n"); 297 | errorStr.append("ErrorComponent: ").append(errorComp).append("\n"); 298 | errorStr.append("ErrorSource: ").append(errorSource).append("\n"); 299 | errorStr.append("ShortMsg: ").append(e.toString()).append("\n"); 300 | errorStr.append("LongMsg: ").append(e.getMessage()).append("\n"); 301 | errorStr.append("Stack: \n").append(getStackTrace(e)).append("\n"); 302 | // errorStr.append("------------------------------------------------------------").append("\n"); 303 | // errorStr.append("THREAD_STATE: \n").append(getThreadState()).append("\n"); 304 | errorStr.append("============================================================").append("\n\n"); 305 | 306 | if (LOGD) { 307 | Log.d(TAG, "Error:\n" + errorStr.toString()); 308 | } 309 | 310 | if (!errorFile.exists()) { 311 | errorFile.createNewFile(); 312 | } 313 | FileWriter fileWritter = new FileWriter(errorFile, true); 314 | BufferedWriter bufferWritter = new BufferedWriter(fileWritter); 315 | bufferWritter.write(errorStr.toString()); 316 | bufferWritter.close(); 317 | } 318 | 319 | private String getStackTrace(Throwable e) { 320 | StringWriter sw = new StringWriter(); 321 | PrintWriter pw = new PrintWriter(sw); 322 | e.printStackTrace(pw); 323 | return sw.toString(); // stack trace as a string; 324 | } 325 | 326 | // private static String getThreadState() { 327 | // Set> threads = Thread.getAllStackTraces().entrySet(); 328 | // StringBuilder threadState = new StringBuilder(); 329 | // for (Map.Entry threadAndStack : threads) { 330 | // StringBuilder threadMessage = new StringBuilder(" ").append(threadAndStack.getKey()); 331 | // threadMessage.append("\n"); 332 | // for (StackTraceElement ste : threadAndStack.getValue()) { 333 | // threadMessage.append(" "); 334 | // threadMessage.append(ste.toString()); 335 | // threadMessage.append("\n"); 336 | // } 337 | // threadMessage.append("\n"); 338 | // threadState.append(threadMessage.toString()); 339 | // } 340 | // return threadState.toString(); 341 | // } 342 | 343 | private static void removeDirectory(File dir) { 344 | if (dir.isDirectory()) { 345 | File[] files = dir.listFiles(); 346 | if (files != null && files.length > 0) { 347 | for (File aFile : files) { 348 | removeDirectory(aFile); 349 | } 350 | } 351 | dir.delete(); 352 | } else { 353 | dir.delete(); 354 | } 355 | } 356 | 357 | @Override 358 | public boolean handleMessage(Message msg) { 359 | if (LOGD) { 360 | Log.d(TAG, "handleMessage Thread: " + Thread.currentThread().getName()); 361 | } 362 | finish(Activity.RESULT_OK, mResults); 363 | return false; 364 | } 365 | } 366 | 367 | --------------------------------------------------------------------------------