コード例 #1
0
 def root_emulator(self):
     # Remount system
     self.log.info('Remount...')
     if not self.remount():
         self.log.info('Remount failed!')
         return
     
     # Push su
     self.log.info('Push su...')
     su_src = utils.get_tool_path('su')
     if not os.path.exists(su_src):
         self.log.info('%s not exists!' % su_src)
         return
     
     su_dst = r'/system/xbin/su'
     self.push_file(su_src, su_dst)
     
     # Chmod
     self.log.info('Chmod 06755 on su...')
     self.change_mode('/system/xbin', '06755')
     self.change_mode('/system/xbin/su', '06755')
     
     # Install tool apks
     superuser_apk = utils.get_tool_apk_path('Superuser.apk')
     xposed_apk = utils.get_tool_apk_path('Xposed.apk')
     if os.path.exists(superuser_apk) and os.path.exists(xposed_apk):
         self.log.info('Install Superuser & Xposed...')
         self.install_app(superuser_apk)
         self.install_app(xposed_apk)
     else:
         self.log.info('%s or %s not exists' %(superuser_apk, xposed_apk))
コード例 #2
0
ファイル: repackage.py プロジェクト: Android-sec/PacSec2014
 def __sign(self):
     try:
         sign_key_path = utils.get_tool_path('sign_key')
         if not sign_key_path:
             self.log.info('%s not exists' % sign_key_path)
             return
         
         if os.path.exists(self.repackaged_path):
             jarsigner_args = ['jarsigner',
                               '-sigalg',
                               'MD5withRSA',
                               '-digestalg',
                               'SHA1',
                               '-storepass',
                               SIGN_KEY_PASS,
                               '-keystore',
                               sign_key_path,
                               self.repackaged_path,
                               SIGN_KEY_ALIAS,
                               '-signedjar',
                               self.repackaged_path
                               ]
             jarsigner_popen = subprocess.Popen(jarsigner_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             retval = jarsigner_popen.communicate()
     except Exception, ex:
         self.has_error = True
         self.log.exception(ex)
コード例 #3
0
    def decompile(self, decompile_type):
        try:
            apktool_path = utils.get_tool_path('apktool.jar')
            if not apktool_path:
                self.log.info('%s not exists!' % apktool_path)
                return

            apktool_args = []
            if decompile_type == NO_SRC:
                apktool_args = [
                    'java', '-jar', apktool_path, 'd', '-s', '-f', '-o',
                    self.decompiled_dir, self.apk_path
                ]
            elif decompile_type == NO_RES:
                apktool_args = [
                    'java', '-jar', apktool_path, 'd', '-r', '-f', '-o',
                    self.decompiled_dir, self.apk_path
                ]
            if apktool_args:
                apktool_popen = subprocess.Popen(apktool_args,
                                                 stdout=subprocess.PIPE,
                                                 stderr=subprocess.PIPE)
                retval = apktool_popen.communicate()
                self.log.info(retval)
        except Exception, ex:
            self.has_error = True
            self.log.exception(ex)
コード例 #4
0
    def root_emulator(self):
        # Remount system
        self.log.info('Remount...')
        if not self.remount():
            self.log.info('Remount failed!')
            return

        # Push su
        self.log.info('Push su...')
        su_src = utils.get_tool_path('su')
        if not os.path.exists(su_src):
            self.log.info('%s not exists!' % su_src)
            return

        su_dst = r'/system/xbin/su'
        self.push_file(su_src, su_dst)

        # Chmod
        self.log.info('Chmod 06755 on su...')
        self.change_mode('/system/xbin', '06755')
        self.change_mode('/system/xbin/su', '06755')

        # Install tool apks
        superuser_apk = utils.get_tool_apk_path('Superuser.apk')
        xposed_apk = utils.get_tool_apk_path('Xposed.apk')
        if os.path.exists(superuser_apk) and os.path.exists(xposed_apk):
            self.log.info('Install Superuser & Xposed...')
            self.install_app(superuser_apk)
            self.install_app(xposed_apk)
        else:
            self.log.info('%s or %s not exists' % (superuser_apk, xposed_apk))
コード例 #5
0
ファイル: repackage.py プロジェクト: Android-sec/PacSec2014
 def __repackage(self):
     try:
         apktool_path = utils.get_tool_path('apktool.jar')
         if not apktool_path:
             self.log.info('%s not exists!' % apktool_path)
             return
         
         print self.repackaged_path
         args = ['java', '-jar', apktool_path, 'b', '-f', self.decompiled_dir, '-o', self.repackaged_path]
         apktool_popen = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         retval = apktool_popen.communicate()
         self.log.info(retval)
     except Exception, ex:
         self.has_error = True
         self.log.exception(ex)
コード例 #6
0
ファイル: repackage.py プロジェクト: Android-sec/PacSec2014
 def decompile(self, decompile_type):
     try:
         apktool_path = utils.get_tool_path('apktool.jar')
         if not apktool_path:
             self.log.info('%s not exists!' % apktool_path)
             return
         
         apktool_args = []
         if decompile_type == NO_SRC:
             apktool_args = ['java', '-jar', apktool_path, 'd', '-s', '-f', '-o', self.decompiled_dir, self.apk_path]
         elif decompile_type == NO_RES:
             apktool_args = ['java', '-jar', apktool_path, 'd', '-r', '-f', '-o', self.decompiled_dir, self.apk_path]
         if apktool_args:
             apktool_popen = subprocess.Popen(apktool_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             retval = apktool_popen.communicate()
             self.log.info(retval)
     except Exception, ex:
         self.has_error = True
         self.log.exception(ex)
コード例 #7
0
    def __repackage(self):
        try:
            apktool_path = utils.get_tool_path('apktool.jar')
            if not apktool_path:
                self.log.info('%s not exists!' % apktool_path)
                return

            print self.repackaged_path
            args = [
                'java', '-jar', apktool_path, 'b', '-f', self.decompiled_dir,
                '-o', self.repackaged_path
            ]
            apktool_popen = subprocess.Popen(args,
                                             stdout=subprocess.PIPE,
                                             stderr=subprocess.PIPE)
            retval = apktool_popen.communicate()
            self.log.info(retval)
        except Exception, ex:
            self.has_error = True
            self.log.exception(ex)
コード例 #8
0
    def __sign(self):
        try:
            sign_key_path = utils.get_tool_path('sign_key')
            if not sign_key_path:
                self.log.info('%s not exists' % sign_key_path)
                return

            if os.path.exists(self.repackaged_path):
                jarsigner_args = [
                    'jarsigner', '-sigalg', 'MD5withRSA', '-digestalg', 'SHA1',
                    '-storepass', SIGN_KEY_PASS, '-keystore', sign_key_path,
                    self.repackaged_path, SIGN_KEY_ALIAS, '-signedjar',
                    self.repackaged_path
                ]
                jarsigner_popen = subprocess.Popen(jarsigner_args,
                                                   stdout=subprocess.PIPE,
                                                   stderr=subprocess.PIPE)
                retval = jarsigner_popen.communicate()
        except Exception, ex:
            self.has_error = True
            self.log.exception(ex)
コード例 #9
0
ファイル: emu_hide.py プロジェクト: nexthacker/PacSec2014
 def __scan_build_prop(self, decompiled_dir):
     is_build_prop = False
     smali_dir = os.path.join(decompiled_dir, 'smali')
     
     if os.path.exists(smali_dir):
         for root, dir, smali_files in os.walk(smali_dir):
             for smali_file in smali_files:
                 ori_smali_path = os.path.join(root, smali_file)
                 ori_smali_obj = open(ori_smali_path, 'r')
                 
                 modified_smali_path = os.path.join(root, '%s.new' % smali_file)
                 modified_smali_obj = open(modified_smali_path, 'w')
                 
                 line = ori_smali_obj.readline()
                 while line:
                     new_line = line.strip()
                     if new_line.startswith('sget-object'):
                         for build_str in BUILD_LIST:
                             if build_str in new_line:
                                 is_build_prop = True
                                 line = line.replace('Landroid/os', 'Lbndroid/os')
                                 break
                     modified_smali_obj.write(line)
                     line = ori_smali_obj.readline()
                 ori_smali_obj.close()
                 modified_smali_obj.close()
                 
                 os.remove(ori_smali_path)
                 os.rename(modified_smali_path, ori_smali_path)
                 
         if is_build_prop:
             build_smali_dir = os.path.join(decompiled_dir, 'smali', 
                                            'bndroid', 'os')
             if not os.path.exists(build_smali_dir):
                 os.makedirs(build_smali_dir)
             build_smali_file = utils.get_tool_path('Build.smali')
             if not os.path.exists(build_smali_file):
                 self.log.info('%s not exists!' % build_smali_file)
             build_smali_dst_file = os.path.join(build_smali_dir, 'Build.smali')
             shutil.copy(build_smali_file, build_smali_dst_file)