(source_directory, vt_analysis_directory, bw_directory_name=None, mw_directory_name=None,
                threshold=1)
Filter apks between malware and benignware based on the report received from VirusTotal

    Parameters
    ----------
    :param source_directory: Folder containing apk files
    :param vt_analysis_directory: Folder containing reports received from VirusTotal
    :param bw_directory_name: Folder where benignware applications are moved to
    :param mw_directory_name: Folder where malware applications are moved to
    :param threshold: Minimum number of antivirus testing for positive to consider a sample as malicious. Default: 1
    :return:
Filter apks between malware and benignware based on the report received from VirusTotal
Filter apks between malware and benignware based on the report received from VirusTotal
def filter_apks(source_directory, vt_analysis_directory, bw_directory_name=None, mw_directory_name=None,
                threshold=1):
    """
    Filter apks between malware and benignware based on the report received from VirusTotal

    Parameters
    ----------
    :param source_directory: Folder containing apk files
    :param vt_analysis_directory: Folder containing reports received from VirusTotal
    :param bw_directory_name: Folder where benignware applications are moved to
    :param mw_directory_name: Folder where malware applications are moved to
    :param threshold: Minimum number of antivirus testing for positive to consider a sample as malicious. Default: 1
    :return:
    """

    files_apks = [f for f in listdir(source_directory) if isfile(join(source_directory, f)) and f.endswith(".apk")]

    if bw_directory_name is None:
        bw_directory_name = join_dir(source_directory, BW_DIRECTORY_NAME)

    if mw_directory_name is None:
        mw_directory_name = join_dir(source_directory, MW_DIRECTORY_NAME)

    if not os.path.exists(bw_directory_name):
        os.makedirs(bw_directory_name)

    if not os.path.exists(mw_directory_name):
        os.makedirs(mw_directory_name)

    for apk in tqdm(files_apks):
        app_id = apk.replace(".apk", "")
        json_id = join_dir(vt_analysis_directory, app_id + ".json")
        apk_path = join_dir(source_directory, apk)

        if not os.path.isfile(json_id):
            print 'ERROR! - NO VT ANALYSIS FOUND FOR APK: ' + app_id
            continue

        data_file = open(json_id)

        try:
            data = json.load(data_file)
        except ValueError:
            continue

        positives = data["positives"]

        if positives < threshold:
            shutil.move(apk_path, join_dir(bw_directory_name, apk))

        if positives >= threshold:
            shutil.move(apk_path, join_dir(mw_directory_name, apk))
def filter_apks ( source_directory , vt_analysis_directory , bw_directory_name = None , mw_directory_name = None , threshold = 1 ) : files_apks = [ f for f in listdir ( source_directory ) if isfile ( join ( source_directory , f ) ) and f . endswith ( ".apk" ) ] if bw_directory_name is None : bw_directory_name = join_dir ( source_directory , BW_DIRECTORY_NAME ) if mw_directory_name is None : mw_directory_name = join_dir ( source_directory , MW_DIRECTORY_NAME ) if not os . path . exists ( bw_directory_name ) : os . makedirs ( bw_directory_name ) if not os . path . exists ( mw_directory_name ) : os . makedirs ( mw_directory_name ) for apk in tqdm ( files_apks ) : app_id = apk . replace ( ".apk" , "" ) json_id = join_dir ( vt_analysis_directory , app_id + ".json" ) apk_path = join_dir ( source_directory , apk ) if not os . path . isfile ( json_id ) : print 'ERROR! - NO VT ANALYSIS FOUND FOR APK: ' + app_id continue data_file = open ( json_id ) try : data = json . load ( data_file ) except ValueError : continue positives = data [ "positives" ] if positives < threshold : shutil . move ( apk_path , join_dir ( bw_directory_name , apk ) ) if positives >= threshold : shutil . move ( apk_path , join_dir ( mw_directory_name , apk ) )