Beispiel #1
0
        void analyzeApk(string apkPath)
        {
            APKInfoExtractor apkInfoExtrator = new APKInfoExtractor(apkPath); //after this line the apk name changed

            apkInfoExtrator.startExtraction();

            //here you can take information you need from apkInfoExtrator object
            TaintAnalyser taintAnalyser = new TaintAnalyser(apkInfoExtrator.realApkPath);
            //here you can take information you need from taintAnalyser object
        }
Beispiel #2
0
        void analyzeApk(string path)
        {
            Session["user"] = userAccountTable.findUserByEmail(Session["username"].ToString());
            Session["apkInfoExtraction"] = new APKInfoExtractor(path);
            ((APKInfoExtractor)Session["apkInfoExtraction"]).startExtraction();
            Session["taintAnalysis"]      = new TaintAnalyser(((APKInfoExtractor)Session["apkInfoExtraction"]).realApkPath);
            Session["apkVulnerabilities"] = new List <Vulnerability>();
            ((List <Vulnerability>)Session["apkVulnerabilities"]).AddRange(((APKInfoExtractor)Session["apkInfoExtraction"]).vulnerabilities);
            ((List <Vulnerability>)Session["apkVulnerabilities"]).AddRange(((TaintAnalyser)Session["taintAnalysis"]).vulnerabilities);

            //Amr dynamic
            //dynamic analysis

            /*  if (((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.x86 && !((APKInfoExtractor)Session["apkInfoExtraction"]).testFlag)//able to run dynamic analysis
             * {
             *    UserSimulator userSimulator = new UserSimulator();
             *    userSimulator.startSimulation(((APKInfoExtractor)Session["apkInfoExtraction"]).realApkPath, 200);
             *
             *    HttpRequestsDetector httpRequestsDetector = new HttpRequestsDetector(userSimulator.getHttplinesPath());
             *   if (httpRequestsDetector.inSecureVulnerability.category != null)
             *       ((List<Vulnerability>)Session["apkVulnerabilities"]).Add(httpRequestsDetector.inSecureVulnerability);
             *
             *    IntentCrashesDetector intentCrashesDetector = new IntentCrashesDetector(userSimulator.getLogcatPath());
             *    ((List<Vulnerability>)Session["apkVulnerabilities"]).AddRange(intentCrashesDetector.vulnerabilities);
             *
             *    userSimulator.removeOutputFolder();
             * }*/
            //end of dynamic analysis
            //Total Apk Risk Level
            Session["sumOfVulnerabilitiesRiskLevels"] = (0.0).ToString();
            for (int i = 0; i < ((List <Vulnerability>)Session["apkVulnerabilities"]).Count; i++)
            {
                Session["sumOfVulnerabilitiesRiskLevels"] = (float.Parse(Session["sumOfVulnerabilitiesRiskLevels"].ToString()) + float.Parse(((List <Vulnerability>)Session["apkVulnerabilities"])[i].severity.ToString())).ToString();
            }
            Session["apkRiskLevel"] = float.Parse(Session["sumOfVulnerabilitiesRiskLevels"].ToString()) / ((List <Vulnerability>)Session["apkVulnerabilities"]).Count;

            Session["apk"]       = apkInfoTable.insertAPKInfo(float.Parse(Session["apkRiskLevel"].ToString()), Session["apkName"].ToString(), ((APKInfoExtractor)Session["apkInfoExtraction"]).minSDKVersion, ((APKInfoExtractor)Session["apkInfoExtraction"]).targetSDKVersion, ((APKInfoExtractor)Session["apkInfoExtraction"]).packageName, ((APKInfoExtractor)Session["apkInfoExtraction"]).versionCode, ((APKInfoExtractor)Session["apkInfoExtraction"]).versionName, ((APKInfoExtractor)Session["apkInfoExtraction"]).testFlag, ((APKInfoExtractor)Session["apkInfoExtraction"]).debuggableFlag, ((APKInfoExtractor)Session["apkInfoExtraction"]).backupFlag, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.all, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.armeabi, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.armeabi_v7a, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.arm64_v8a, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.x86, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.x86_64, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.mips, ((APKInfoExtractor)Session["apkInfoExtraction"]).supportedArchitectures.mips64);
            Session["apkReport"] = reportTable.addNewReport(DateTime.Now.Date, true, false, ((apkInfoTable)Session["apk"]).apkInfoID, ((userAccountTable)Session["user"]).ID);


            for (int i = 0; i < ((List <Vulnerability>)Session["apkVulnerabilities"]).Count; i++)
            {
                Session["dbVulnerability"] = vulnerabilityTable.addOrFindVulnerability(((List <Vulnerability>)Session["apkVulnerabilities"])[i].severity, ((List <Vulnerability>)Session["apkVulnerabilities"])[i].category, ((List <Vulnerability>)Session["apkVulnerabilities"])[i].type);
                ((reportTable)Session["apkReport"]).createRelationBetweenReportAndVulnerability(((reportTable)Session["apkReport"]).reportId, ((vulnerabilityTable)Session["dbVulnerability"]).vulnID, ((List <Vulnerability>)Session["apkVulnerabilities"])[i].extraInfo);
            }

            Session["upladPagePermissions"] = ((APKInfoExtractor)Session["apkInfoExtraction"]).permissions;

            for (int i = 0; i < ((string[])Session["upladPagePermissions"]).Length; i++)
            {
                permissionTable.addNewPermission(((string[])Session["upladPagePermissions"])[i]);
                ((apkInfoTable)Session["apk"]).createRelationBetweenAPKInfoAndPermission(((apkInfoTable)Session["apk"]).apkInfoID, ((string[])Session["upladPagePermissions"])[i]);
            }
            Session["launchableActivities"] = ((APKInfoExtractor)Session["apkInfoExtraction"]).launchableActivities;
            for (int i = 0; i < ((string[])Session["launchableActivities"]).Length; i++)
            {
                launchableActivityTable.addNewActivity(((string[])Session["launchableActivities"])[i], ((apkInfoTable)Session["apk"]).apkInfoID);
            }
            Session["reportID"] = ((reportTable)Session["apkReport"]).reportId;

            Session.Contents.Remove("apkName");
            Session.Contents.Remove("taintAnalysis");
            Session.Contents.Remove("apkVulnerabilities");
            Session.Contents.Remove("dbVulnerability");
            Session.Contents.Remove("apkInfoExtraction");
            Session.Contents.Remove("apk");
            Session.Contents.Remove("apkReport");
            Session.Contents.Remove("launchableActivities");
            Session.Contents.Remove("sumOfVulnerabilitiesRiskLevels");
            Session.Contents.Remove("apkRiskLevel");
        }