From f2417a080245761f3aada8c0bb32d734b693c21a Mon Sep 17 00:00:00 2001 From: Henry Hoggard Date: Fri, 20 Jan 2017 16:19:01 +0000 Subject: [PATCH] [Feature] Architecture and Platform API --- src/drozer/modules/common/__init__.py | 1 + src/drozer/modules/common/platform.py | 31 +++++++++++++++++++++++ src/drozer/modules/tools/setup/busybox.py | 7 ++--- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/drozer/modules/common/platform.py diff --git a/src/drozer/modules/common/__init__.py b/src/drozer/modules/common/__init__.py index 0dbc50d5..98afbf89 100644 --- a/src/drozer/modules/common/__init__.py +++ b/src/drozer/modules/common/__init__.py @@ -15,6 +15,7 @@ from drozer.modules.common.loader import ClassLoader from drozer.modules.common.package_manager import PackageManager from drozer.modules.common import path_completion +from drozer.modules.common.platform import Platform from drozer.modules.common.provider import Provider from drozer.modules.common.shell import Shell from drozer.modules.common.shell_code import ShellCode diff --git a/src/drozer/modules/common/platform.py b/src/drozer/modules/common/platform.py new file mode 100644 index 00000000..2059b38e --- /dev/null +++ b/src/drozer/modules/common/platform.py @@ -0,0 +1,31 @@ + + + +class Platform(object): + """ + Methods for identifying platform information + """ + + def getArchitecture(self): + """ + Get device architecture + """ + + return self.klass('java.lang.System').getProperty("os.arch").upper() + + def isPIE(self): + """ + Is PIE enforced on the device + """ + + if self.klass("android.os.Build$VERSION").SDK_INT >= 21: + return True + else: + return False + + def getBuildVersion(self): + """ + Get Android Device Version + """ + + return self.klass("android.os.Build$VERSION").SDK_INT \ No newline at end of file diff --git a/src/drozer/modules/tools/setup/busybox.py b/src/drozer/modules/tools/setup/busybox.py index 25d01c97..98f630ae 100644 --- a/src/drozer/modules/tools/setup/busybox.py +++ b/src/drozer/modules/tools/setup/busybox.py @@ -1,6 +1,6 @@ from drozer.modules import common, Module -class BusyBox(Module, common.BusyBox, common.Shell): +class BusyBox(Module, common.BusyBox, common.Shell, common.Platform): name = "Install Busybox." description = """Installs Busybox on the Agent. @@ -25,9 +25,9 @@ def execute(self, arguments): # if "Y" not in response.upper(): # return - if self.klass("android.os.Build$VERSION").SDK_INT >= 21: + if self.isPIE(): if self.installBusyBox(True): - self.stdout.write("BusyBox installed " + + self.busyboxPath() + "\n") + self.stdout.write("BusyBox installed " + self.busyboxPath() + "\n") else: self.stdout.write("BusyBox installation failed.\n") else: @@ -36,3 +36,4 @@ def execute(self, arguments): else: self.stdout.write("BusyBox installation failed.\n") +