public static void loadAllClassesOnClassPathToSignatures() { for (String path : SourceLocator.explodeClassPath(Scene.v().getSootClassPath())) { for (String cl : SourceLocator.v().getClassesUnder(path)) { Scene.v().forceResolve(cl, SootClass.SIGNATURES); } } }
private synchronized void ensureClassHasBodies(SootClass cl) { assert Scene.v().hasFastHierarchy(); if (cl.resolvingLevel() < SootClass.BODIES) { Scene.v().forceResolve(cl.getName(), SootClass.BODIES); Scene.v().getOrMakeFastHierarchy(); } assert Scene.v().hasFastHierarchy(); }
@Override public void visit(Node n) { if (n instanceof ClassConstantNode) { ClassConstantNode ccn = (ClassConstantNode) n; Type ccnType = ccn.getClassConstant().toSootType(); // If the referenced class has not been loaded, // we do this now SootClass targetClass = ((RefType) ccnType).getSootClass(); if (targetClass.resolvingLevel() == SootClass.DANGLING) { Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES); } // We can only create alloc nodes for types that // we know edgeTgt.makeP2Set().add(pag.makeAllocNode(edgeSrc.getValue(), ccnType, ccn.getMethod())); varNodeWorkList.add(edgeTgt); } }
@Override public void visit(Node n) { if (n instanceof ClassConstantNode) { ClassConstantNode ccn = (ClassConstantNode) n; Type ccnType = ccn.getClassConstant().toSootType(); // If the referenced class has not been loaded, we do // this now SootClass targetClass = ((RefType) ccnType).getSootClass(); if (targetClass.resolvingLevel() == SootClass.DANGLING) { Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES); } instance.makeP2Set().add(pag.makeAllocNode(src.getValue(), ccnType, ccn.getMethod())); } }
@Override public void visit(Node n) { if (n instanceof ClassConstantNode) { ClassConstantNode ccn = (ClassConstantNode) n; Type ccnType = ccn.getClassConstant().toSootType(); // If the referenced class has not been loaded, // we do this now SootClass targetClass = ((RefType) ccnType).getSootClass(); if (targetClass.resolvingLevel() == SootClass.DANGLING) { Scene.v().forceResolve(targetClass.getName(), SootClass.SIGNATURES); } edgeTgt.makeP2Set().add(pag.makeAllocNode(edgeSrc.getValue(), ccnType, ccn.getMethod())); addToWorklist(edgeTgt); } }
SootClass clazz = Scene.v().forceResolve(cl, SootClass.SIGNATURES); clazz.setApplicationClass();
private SootClass getLayoutClass(String className) { // Cut off some junk returned by the parser if (className.startsWith(";")) className = className.substring(1); if (className.contains("(") || className.contains("<") || className.contains("/")) { logger.warn("Invalid class name %s", className); return null; } SootClass sc = Scene.v().forceResolve(className, SootClass.BODIES); if ((sc == null || sc.isPhantom()) && !packageName.isEmpty()) sc = Scene.v().forceResolve(packageName + "." + className, SootClass.BODIES); if (!isRealClass(sc)) sc = Scene.v().forceResolve("android.view." + className, SootClass.BODIES); if (!isRealClass(sc)) sc = Scene.v().forceResolve("android.widget." + className, SootClass.BODIES); if (!isRealClass(sc)) sc = Scene.v().forceResolve("android.webkit." + className, SootClass.BODIES); if (!isRealClass(sc)) { logger.warn(String.format("Could not find layout class %s", className)); return null; } return sc; }
SootClass rClass = Scene.v().forceResolve("android.R$attr", SootClass.BODIES); if (!rClass.declaresFieldByName(name)) return -1;
Options.v().set_allow_phantom_refs(true); SootClass sootClass = Scene.v().forceResolve(className, SootClass.SIGNATURES);
Options.v().set_allow_phantom_refs(true); SootClass sootClass = Scene.v().forceResolve(cleanString(filePath, true), SootClass.SIGNATURES);
if (expr != null) { if (expr.getMethodRef().getDeclaringClass().equals(Scene.v() .forceResolve(VariableMap.class.getName(), SootClass.SIGNATURES))) { initialOperations.putAll(parseInitialExpression(expr, element, resourceFilePath)); invoke = leftBox;
Options.v().set_allow_phantom_refs(true); SootClass sootClass = Scene.v().forceResolve(className, SootClass.SIGNATURES);
/** * Loads the class with the given name into the scene. This makes sure that * there is at least a phantom class with the given name * * @param className The name of the class to load */ private void loadClass(String className) { SootClass sc = Scene.v().getSootClassUnsafe(className); if (sc == null) { sc = Scene.v().makeSootClass(className); sc.setPhantomClass(); Scene.v().addClass(sc); } else if (sc.resolvingLevel() < SootClass.HIERARCHY) Scene.v().forceResolve(className, SootClass.HIERARCHY); }
if (tname == null) { try { SootClass rClass = Scene.v().forceResolve("android.R$attr", SootClass.BODIES); if (rClass == null) {
SootClass createdClass = Scene.v().forceResolve(className, SootClass.BODIES); createdClass.setApplicationClass(); Local localVal = generateClassConstructor(createdClass, body);
SootClass createdClass = Scene.v().forceResolve(className, SootClass.BODIES); createdClass.setApplicationClass();
@Override public SootMethod createDummyMain() { // Load the substitution classes if (substituteCallParams) for (String className : substituteClasses) Scene.v().forceResolve(className, SootClass.BODIES).setApplicationClass(); // Create the empty main method createAdditionalFields(); createAdditionalMethods(); createEmptyMainMethod(); body = mainMethod.getActiveBody(); // We provide some helper objects final Body body = mainMethod.getActiveBody(); generator = new LocalGenerator(body); // Make sure that we have an opaque predicate conditionCounter = 0; intCounter = generator.generateLocal(IntType.v()); body.getUnits().add(Jimple.v().newAssignStmt(intCounter, IntConstant.v(conditionCounter))); return createDummyMainInternal(); }
SootClass c = Scene.v().forceResolve(className, SootClass.BODIES); if (c != null) { c.setApplicationClass();
/** * Modifies Activity::getFragmentManager() to return new * MyFragmentManager(this); */ private void patchActivityGetFragmentManager() { SootClass sc = Scene.v().getSootClassUnsafe("android.app.Activity"); if (sc == null || sc.resolvingLevel() < SootClass.SIGNATURES) return; sc.setLibraryClass(); SootMethod smGetFM = sc.getMethodUnsafe("android.app.FragmentManager getFragmentManager()"); if (smGetFM == null || smGetFM.hasActiveBody()) return; Body b = Jimple.v().newBody(smGetFM); smGetFM.setActiveBody(b); Local thisLocal = Jimple.v().newLocal("this", sc.getType()); b.getLocals().add(thisLocal); b.getUnits().add(Jimple.v().newIdentityStmt(thisLocal, Jimple.v().newThisRef(sc.getType()))); SootClass scFragmentTransaction = Scene.v().forceResolve("android.app.FragmentManager", SootClass.SIGNATURES); Local retLocal = Jimple.v().newLocal("retFragMan", Scene.v().getSootClassUnsafe("android.app.FragmentManager").getType()); b.getLocals().add(retLocal); b.getUnits().add(Jimple.v().newAssignStmt(retLocal, Jimple.v().newNewExpr(scFragmentTransaction.getType()))); b.getUnits().add(Jimple.v().newReturnStmt(retLocal)); }
@Override protected void initializeAnalysis(A commandLineArguments) { addSceneTransformer(); Options.v().set_no_bodies_for_excluded(true); Options.v().set_allow_phantom_refs(true); Options.v().set_output_format(Options.output_format_none); Options.v().set_whole_program(true); Options.v().set_soot_classpath( commandLineArguments.getInput() + File.pathSeparator + commandLineArguments.getClasspath()); Options.v().setPhaseOption("cg.spark", "on"); // do not merge variables (causes problems with PointsToSets) Options.v().setPhaseOption("jb.ulp", "off"); // Options.v().setPhaseOption("jb.ne", "off"); Options.v().setPhaseOption("jb.uce", "remove-unreachable-traps:true"); Options.v().setPhaseOption("cg", "trim-clinit:false"); Options.v().set_prepend_classpath(true); Options.v().set_src_prec(Options.src_prec_java); for (String analysisClass : AnalysisParameters.v().getAnalysisClasses()) { SootClass sootClass = Scene.v().loadClassAndSupport(analysisClass); Scene.v().forceResolve(analysisClass, SootClass.BODIES); sootClass.setApplicationClass(); } Scene.v().loadNecessaryClasses(); Scene.v().setMainClassFromOptions(); Scene.v().setEntryPoints(EntryPoints.v().application()); }