示例#1
0
 def on_menu_adb_path(self, event):
     dialog = wx.TextEntryDialog(
         self, 'Example: "yourpath/android-sdk-macosx/platform-tools/"',
         'Set Your Adb Path', '')
     if dialog.ShowModal() == wx.ID_OK:
         new_adb_path = dialog.GetValue()
         tree = ET.parse("./config.xml")
         root = tree.getroot()
         # "/Users/wnagzihxa1n/Library/Android/android-sdk-macosx/platform-tools"
         root[0].text = new_adb_path
         tree.write("./config.xml")
         SelectItem.set_adb_path(new_adb_path)
         ShellTool.init_shell_env()
示例#2
0
 def refresh_devices_list(self):
     self.clear_all_textctrl()
     out, err = ShellTool.run("adb devices")
     devices = out.split('\n')
     self.devices_list = []
     for device in devices:
         if len(device) > 0 and '\tdevice' in device:
             self.devices_list.append(device.replace('\tdevice', ''))
     self.combobox_devices.SetItems(self.devices_list)
     if len(self.devices_list) > 0:
         self.combobox_devices.SetValue(self.devices_list[0])
         SelectItem.set_selected_device_name(self.devices_list[0])
         device_name = DeviceTool.getprop_ro_product_name()
         device_os_version = DeviceTool.getprop_ro_build_version_release()
         self.statictext_device_name.SetLabel('Name: {}'.format(
             device_name[0]).strip())
         self.statictext_device_os_version.SetLabel('OS Version: {}'.format(
             device_os_version[0]).strip())
         pub.sendMessage('re_select_device')
     else:
         SelectItem.set_selected_device_name('')
         device_name = '          '
         device_os_version = '          '
         self.statictext_device_name.SetLabel(
             'Name: {}'.format(device_name))
         self.statictext_device_os_version.SetLabel(
             'OS Version: {}'.format(device_os_version))
         SelectItem.clear_all()
         pub.sendMessage('no_device')
示例#3
0
 def on_get_device_info(self, event):
     self.clear_all_textctrl()
     shell = 'adb -s {} shell getprop'.format(SelectItem.get_selected_device_name())
     self.textctrl_shell.SetValue(shell)
     out, err = ShellTool.run(shell)
     self.textctrl_output.SetValue(out)
     self.textctrl_output.AppendText('\n')
     self.textctrl_output.AppendText(err)
示例#4
0
 def get_top_activity(device_panel):
     device_build_version = DeviceTool.getprop_ro_build_version_release()
     shell = ''
     if device_build_version[0].startswith("7"):
         shell = 'adb -s {} shell dumpsys activity | grep "mFocusedActivity"' \
             .format(SelectItem.get_selected_device_name())
     elif device_build_version[0].startswith("8"):
         shell = 'adb -s {} shell dumpsys activity activities | grep "mResumedActivity"' \
             .format(SelectItem.get_selected_device_name())
     elif device_build_version[0].startswith("9"):
         shell = 'adb -s {} shell dumpsys activity activities | grep "mResumedActivity"' \
             .format(SelectItem.get_selected_device_name())
     elif device_build_version[0].startswith("10"):
         shell = 'adb -s {} shell dumpsys activity activities | grep "mResumedActivity"' \
             .format(SelectItem.get_selected_device_name())
     device_panel.textctrl_shell.SetValue(shell)
     out, err = ShellTool.run(shell)
     device_panel.textctrl_output.SetValue(out)
     device_panel.textctrl_output.AppendText('\n')
     device_panel.textctrl_output.AppendText(err)
示例#5
0
 def on_command_exec(self, event):
     shell = self.textctrl_shell.GetValue()
     out, err = ShellTool.run(shell)
     self.textctrl_output.SetValue(out)
     self.textctrl_output.AppendText('\n')
     self.textctrl_output.AppendText(err)
示例#6
0
 def get_all_packages_with_filepath():
     return ShellTool.run("adb -s {} shell pm list packages -f".format(SelectItem.get_selected_device_name()))
示例#7
0
 def getprop_ro_build_version_release():
     return ShellTool.run(
         "adb -s {} shell getprop ro.build.version.release".format(SelectItem.get_selected_device_name()))
示例#8
0
 def getprop_ro_product_name():
     return ShellTool.run("adb -s {} shell getprop ro.product.name".format(SelectItem.get_selected_device_name()))
示例#9
0
    def __init__(self, parent):
        super(QuickAttackPanel, self).__init__(parent=parent,
                                               style=wx.BORDER_NONE)
        self.boxsizer_main = wx.BoxSizer(wx.VERTICAL)

        # device operation
        self.staticboxsizer_devices = wx.StaticBoxSizer(
            wx.StaticBox(self, label='Device Operation'))
        self.boxsizer_devices = wx.BoxSizer(wx.HORIZONTAL)
        self.statictext_device_name = wx.StaticText(self,
                                                    -1,
                                                    label='Name:          ')
        self.statictext_device_os_version = wx.StaticText(
            self, -1, label='OS Version:          ')
        self.boxsizer_devices.Add(self.statictext_device_name,
                                  flag=wx.CENTER | wx.ALL,
                                  border=0)
        self.boxsizer_devices.AddSpacer(10)
        self.boxsizer_devices.Add(self.statictext_device_os_version,
                                  flag=wx.CENTER | wx.ALL,
                                  border=0)
        self.boxsizer_devices.AddSpacer(10)
        self.devices_list = []
        self.combobox_devices = wx.ComboBox(self, choices=self.devices_list)
        # self.combobox_devices.SetBackgroundColour(wx.WHITE)
        self.button_refresh_devices = wx.Button(self,
                                                label='Refresh Device List')
        self.boxsizer_devices.Add(self.combobox_devices,
                                  flag=wx.EXPAND | wx.ALL,
                                  border=0)
        self.boxsizer_devices.AddSpacer(10)
        self.boxsizer_devices.Add(self.button_refresh_devices,
                                  flag=wx.EXPAND | wx.ALL,
                                  border=0)
        self.Bind(wx.EVT_COMBOBOX, self.on_combobox_device_select,
                  self.combobox_devices)
        self.Bind(wx.EVT_BUTTON, self.on_refresh_devices_list,
                  self.button_refresh_devices)
        self.staticboxsizer_devices.Add(self.boxsizer_devices)

        # component operation
        self.staticboxsizer_component = wx.StaticBoxSizer(
            wx.StaticBox(self, label='Quick Attack'))
        self.boxsizer_component = wx.BoxSizer(wx.HORIZONTAL)
        self.button_activity = wx.Button(self, label='Start Activity')
        self.button_service = wx.Button(self, label='Start Service')
        self.button_broadcast = wx.Button(self, label='Send Broadcast')
        self.boxsizer_component.Add(self.button_activity,
                                    flag=wx.EXPAND | wx.ALL,
                                    border=0)
        self.boxsizer_component.AddSpacer(10)
        self.boxsizer_component.Add(self.button_service,
                                    flag=wx.EXPAND | wx.ALL,
                                    border=0)
        self.boxsizer_component.AddSpacer(10)
        self.boxsizer_component.Add(self.button_broadcast,
                                    flag=wx.EXPAND | wx.ALL,
                                    border=0)
        self.boxsizer_component.AddSpacer(10)
        self.Bind(wx.EVT_BUTTON, self.on_start_activity, self.button_activity)
        self.Bind(wx.EVT_BUTTON, self.on_start_service, self.button_service)
        self.Bind(wx.EVT_BUTTON, self.on_send_broadcast, self.button_broadcast)
        self.staticboxsizer_component.Add(self.boxsizer_component)

        # Add all staticboxsizers to boxsizer_main
        self.boxsizer_main.Add(self.staticboxsizer_devices,
                               flag=wx.EXPAND | wx.ALL,
                               border=0)
        self.boxsizer_main.Add(self.staticboxsizer_component,
                               flag=wx.EXPAND | wx.ALL,
                               border=0)

        # command param hint
        self.textctrl_hint = wx.TextCtrl(self,
                                         style=wx.TE_MULTILINE
                                         | wx.TE_READONLY)
        self.textctrl_hint.SetBackgroundColour(wx.WHITE)
        self.boxsizer_main.Add(self.textctrl_hint,
                               flag=wx.EXPAND | wx.ALL,
                               proportion=1,
                               border=5)

        # command editor
        self.boxsizer_command = wx.BoxSizer(wx.HORIZONTAL)
        self.textctrl_shell = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        self.shell_exec_button = wx.Button(self, label="Execute")
        self.boxsizer_command.Add(self.textctrl_shell,
                                  flag=wx.EXPAND | wx.ALL,
                                  proportion=1,
                                  border=5)
        self.boxsizer_command.Add(self.shell_exec_button,
                                  flag=wx.EXPAND | wx.ALL,
                                  border=5)
        self.boxsizer_main.Add(self.boxsizer_command,
                               flag=wx.EXPAND | wx.ALL,
                               proportion=1)
        self.Bind(wx.EVT_BUTTON, self.on_command_exec, self.shell_exec_button)

        # command execute output
        self.textctrl_output = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        self.textctrl_output.SetBackgroundColour(wx.WHITE)
        self.boxsizer_main.Add(self.textctrl_output,
                               flag=wx.EXPAND | wx.ALL,
                               proportion=1,
                               border=5)

        self.SetSizer(self.boxsizer_main)

        tree = ET.parse("./config.xml")
        adb_path = tree.getroot()[0].text.strip()
        SelectItem.set_adb_path(adb_path)

        ShellTool.init_shell_env()

        # refresh device list while starting Toolgy
        self.refresh_devices_list()