Exemplo n.º 1
0
    def _walk_dir(self, dir, path_out):
        try:
            for root, dirs, files in os.walk(dir):
                for file in files:
                    file.replace('$', '\$')

                    if Utils.is_zip(root, file) or \
                            Utils.is_rar(root, file) or \
                            Utils.is_tar(root, file):
                        self._extract_file(root, file)
                        Utils.remove_file(root, file)
                    else:
                        if Utils.is_apk(root, file):
                            Utils.rename_file(root, path_out, file)
                        else:
                            Utils.remove_file(root, file)
        except OSError, e:
            logging.error("Error walking dir '%s': %s" % (dir, e))
            raise OSError
Exemplo n.º 2
0
 def run(self, mode='long'):
     logging.debug("Dumping trails...")
     trails_list = []
     try:
         for root, dirs, files in os.walk(self._cfg['dir_out']):
             for file in files:
                 if Utils.is_apk(root, file):
                     apk_file = APK(root, file)
                     if apk_file.is_valid_APK():
                         trails = self._dump_trails(apk_file, mode)
                         if len(trails) > 0 and trails not in trails_list:
                             trails_list.append(trails)
                         else:
                             logging.error("Empty dict for '%s'" % (os.path.join(root, file)))
                 else:
                     logging.error("Unsupported file type '%s' for '%s'" % (
                         os.path.splitext(file)[1], os.path.join(root, file)))
     except OSError, e:
         logging.error("Error dumping trails: %s" % (e))
         raise OSError