Skip to content

Commit

Permalink
v1.3 additional bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jakev committed Oct 30, 2015
1 parent dacce92 commit da4f529
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 6 deletions.
3 changes: 3 additions & 0 deletions dtf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ TAG = "dtf"
BUILT_IN_LIST = ['archive', 'client', 'local', 'prop', 'reset',
'source', 'status']

# No file logging
#log.LOG_LEVEL_FILE = 0

def usage():

"""Print dtf usage brief"""
Expand Down
35 changes: 35 additions & 0 deletions included/dtf_drozer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Android Device Testing Framework ("dtf")
# Copyright 2013-2015 Jake Valletta (@jake_valletta)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This this is a wraper script for "drozer".

name=dtf_drozer


dtf_drozer()
{

# Make sure we can get to our device.
echo "Waiting for device..."
adb wait-for-device

# Set up the port forward rules
adb forward tcp:31415 tcp:31415

drozer console connect

return 0
}
2 changes: 1 addition & 1 deletion included/dtf_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This this is a wraper script for "smali".
# This this is a wraper script for spawning a adb shell.

name=dtf_shell

Expand Down
13 changes: 12 additions & 1 deletion install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ apt-get -qqy update || exit 6

# General stuff
echo "[+] Installing general purpose tools..."
apt-get -qqy install xz-utils sqlite3 build-essential || exit 3
apt-get -qqy install gdebi-core xz-utils sqlite3 build-essential || exit 3

# Android stuff
echo "[+] Installing required Android tools..."
Expand All @@ -102,6 +102,17 @@ pip install colored --upgrade || exit 10
echo "[+] Checking for Java (openjdk) 1.7..."
apt-get -qqy install openjdk-7-jdk || exit 11

echo "[+] Checking for Drozer..."

if [ `which drozer` ]; then
echo "[+] Drozer already installed!"
else
echo "[+] Getting drozer .deb and installing..."
wget -O drozer.deb https://www.mwrinfosecurity.com/system/assets/931/original/drozer_2.3.4.deb
gdebi --option=APT::Get::force-yes=1,APT::Get::Assume-Yes=1 -n -q drozer.deb
rm drozer.deb 2>/dev/null
fi

echo "[+] Confirming true bash shell.."

shell=$(readlink -f $(which sh)|grep -o '....$')
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

TAG = "dtf-setup"

# No file logging yet please
log.LOG_LEVEL_FILE = 0

def get_pydtf_dir():

"""Return the location of the dtf dist-packages directory."""
Expand Down
12 changes: 10 additions & 2 deletions src/dtf/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from time import localtime, strftime
from sys import stdout

import dtf.core.utils as utils

#pylint: disable-msg=C0103

# Can override just like the shell
Expand All @@ -26,6 +28,7 @@

# Internals ###########################################################
LOG_FILE_NAME = '.dtflog'
LOG_FILE = None

# Terminal Coloring
COLOR_ERR = fg('#d70000')
Expand All @@ -35,7 +38,9 @@
COLOR_DEB = fg('#d700af')

# Open file on module import
LOG_FILE = open(LOG_FILE_NAME, 'a')
TOP = utils.get_project_root()
if TOP is not None:
LOG_FILE = open(LOG_FILE_NAME, 'a')

def __get_date():

Expand All @@ -46,7 +51,7 @@ def __get_date():
# Low level printing function
def __log(buf, entry):

"""Write entry to buffer"""


buf.write(entry)

Expand All @@ -63,6 +68,9 @@ def __log_to_file(date, tag, message):

"""Write entry to stderr"""

if LOG_FILE is None:
return

entry = "[%s] %s - %s\n" % (date, tag, message)
__log(LOG_FILE, entry)

Expand Down
2 changes: 1 addition & 1 deletion src/dtf/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __launch_bash_module(module_path, args):
popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=new_env)
except OSError:
log.e(TAG, "Unable to execute '%s'. Are the permission flags correct?"
% mod_name)
% module_path)
return -5

lines_iterator = iter(popen.stdout.readline, b"")
Expand Down
2 changes: 1 addition & 1 deletion src/dtf/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_prop(section, prop):
err = "Property section not found: %s" % section
raise PropertyError(err)
except ConfigParser.NoOptionError:
err = "Property not found: %s\%s" % (section, prop)
err = r"Property not found: %s\%s" % (section, prop)
raise PropertyError(err)

return rtn
Expand Down
1 change: 1 addition & 0 deletions templates/dtf_core_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ DTF_INCLUDED=__INCLUDED__
. ${DTF_INCLUDED}/dtf_apktool.sh
. ${DTF_INCLUDED}/dtf_baksmali.sh
. ${DTF_INCLUDED}/dtf_dex2jar.sh
. ${DTF_INCLUDED}/dtf_drozer.sh
. ${DTF_INCLUDED}/dtf_shell.sh
. ${DTF_INCLUDED}/dtf_smali.sh
. ${DTF_INCLUDED}/dtf_axmlprinter2.sh
Expand Down

0 comments on commit da4f529

Please sign in to comment.