from androguard.core import androconf from androguard.core.bytecodes import apk from sklearn.externals import joblib from sklearn.ensemble import RandomForestClassifier from sklearn.naive_bayes import BernoulliNB from sklearn.naive_bayes import GaussianNB from sklearn.naive_bayes import MultinomialNB from sklearn.svm import SVC from detector.config import CLASSIFIER_PATH from detector.config import TRAIN_PERMISSION from detector.error import AdDetectorException from detector.logger import AdDetectorLogger from detector.ad.permission.base import BasePermission logger = AdDetectorLogger() class AdBasePredict(BasePermission): predictor = None def __init__(self): super(AdBasePredict, self).__init__() if self.predictor is None: raise AdDetectorException('You must init an predictor' ' using an method!') # init predictor trained_permissions = self.session.query_sort(TRAIN_PERMISSION, 'create',
import json import re from datetime import datetime from androguard.core import androconf from androguard.core.bytecodes import apk import numpy from numpy import zeros from sklearn.naive_bayes import * from sklearn import svm from sklearn.externals import joblib from detector.config import * from detector.db.session import MongDBSession from detector.logger import AdDetectorLogger logger = AdDetectorLogger() def check_adware_from_config(real_filename, config=AD_FEATURE_FILE): """ Check app is adware from ad feature db. :param apk: the path of checking app :param config: adware feature db :return: True or False """ ret_type = androconf.is_android(real_filename) if ret_type == "APK": logger.info(os.path.basename(real_filename) + ':') try: a = apk.APK(real_filename) if a.is_valid_APK():
from androguard.core import androconf from androguard.core.bytecodes import apk from sklearn.externals import joblib from sklearn.ensemble import RandomForestClassifier from sklearn.naive_bayes import BernoulliNB from sklearn.naive_bayes import GaussianNB from sklearn.naive_bayes import MultinomialNB from sklearn.svm import SVC from detector.config import CLASSIFIER_PATH from detector.config import TRAIN_PERMISSION from detector.error import AdDetectorException from detector.logger import AdDetectorLogger from .base import BasePermission logger = AdDetectorLogger() class AdBasePredict(BasePermission): predictor = None def __init__(self): super(AdBasePredict, self).__init__() if self.predictor is None: raise AdDetectorException('You must init an predictor' ' using an method!') # init predictor trained_permissions = self.session.query_sort(TRAIN_PERMISSION, 'create', limit=1)