def main(options, arguments) : ri = risk.RiskIndicator() ri.add_risk_analysis( risk.RedFlags() ) ri.add_risk_analysis( risk.FuzzyRisk() ) if options.input != None : ret_type = androconf.is_android( options.input ) if ret_type == "APK" : a = apk.APK( options.input ) analyze_app( options.input, ri, a ) elif ret_type == "DEX" : analyze_dex( options.input, ri, open(options.input, "r").read() ) elif options.directory != None : for root, dirs, files in os.walk( options.directory, followlinks=True ) : if files != [] : for f in files : real_filename = root if real_filename[-1] != "/" : real_filename += "/" real_filename += f ret_type = androconf.is_android( real_filename ) if ret_type == "APK" : try : a = apk.APK( real_filename ) analyze_app( real_filename, ri, a ) except Exception, e : print e elif ret_type == "DEX" : analyze_dex( real_filename, ri, open(real_filename, "r").read() )
def check_risk(self): if self.isvalid: ri = risk.RiskIndicator() ri.add_risk_analysis(risk.RedFlags()) ri.add_risk_analysis(risk.FuzzyRisk()) return ri.with_apk(self.app) else: if self.debug: print "[-] File was not a valid Android Application!" return ''
def run(name, dir=""): ri = risk.RiskIndicator() ri.add_risk_analysis(risk.RedFlags()) ri.add_risk_analysis(risk.FuzzyRisk()) ret_type = androconf.is_android(dir + name + ".apk") if ret_type == "APK": a = apk.APK(dir + name + ".apk") return analyze_app(name, ri, a) else: print "ret_type was not APK"
def getRisk(self): """ Use Androrisk in androguard to fuzzy risk """ try: ri = risk.RiskIndicator() ri.add_risk_analysis(risk.RedFlags()) ri.add_risk_analysis(risk.FuzzyRisk()) res = ri.with_apk(self.apkObj) self.riskValue = res['FuzzyRisk']['VALUE'] self.sensitiveCodes = res['RedFlags']['DEX'] except Exception: ex = traceback.format_exc() self.log.exce(ex)
# -*- coding: utf-8 -*- from __future__ import print_function __author__ = 'xuyn' import sys import os from androguard.core.bytecodes import apk from androguard.core.analysis import risk from androguard.misc import * ri = risk.RiskIndicator() ri.add_risk_analysis(risk.RedFlags()) ri.add_risk_analysis(risk.FuzzyRisk()) def getAPKandroguardSecureInfo(apkfile, dex, output): if os.path.exists(apkfile): a = apk.APK(apkfile) res = ri.with_apk(a) with open(output, "a") as out: for i in res: print("\t", i, file=out) for j in res[i]: print("\t\t", j, res[i][j], file=out) else: print(apkfile, "not exists") if __name__ == '__main__': if len(sys.argv) != 3: print("Usage: ./RunOnApk.py APK.apk OUTPUTDIR")