public boolean containsMethod(String methodSignature) { return grabMethod(methodSignature) != null; }
public SootMethod getMethod(String methodSignature) { SootMethod m = grabMethod(methodSignature); if (m != null) { return m; } throw new RuntimeException("tried to get nonexistent method " + methodSignature); }
@Override protected void internalTransform(Body b, String phaseName, Map<String, String> options) { for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext();) { Unit u = unitIt.next(); if (u instanceof Stmt) { Stmt s = (Stmt) u; if (s.containsInvokeExpr()) { InvokeExpr iexpr = s.getInvokeExpr(); if (iexpr instanceof StaticInvokeExpr) { if (isClassLoaded(iexpr.getMethodRef().declaringClass())) { SootMethod target = Scene.v().grabMethod(iexpr.getMethodRef().getSignature()); if (target != null && !target.isStatic()) { if (canBeMadeStatic(target)) { // Remove the this-assignment to prevent // 'this-assignment in a static method!' exception target.getActiveBody().getUnits().remove(target.getActiveBody().getThisUnit()); target.setModifiers(target.getModifiers() | Modifier.STATIC); logger.warn(target.getName() + " changed into a static method"); } } } } } } } }
public boolean containsMethod(String methodSignature) { return grabMethod(methodSignature) != null; }
public boolean containsMethod(String methodSignature) { return grabMethod(methodSignature) != null; }
public SootMethod getMethod(String methodSignature) { SootMethod m = grabMethod( methodSignature ); if (m != null) return m; throw new RuntimeException("tried to get nonexistent method "+methodSignature); }
public SootMethod getMethod(String methodSignature) { SootMethod m = grabMethod( methodSignature ); if (m != null) return m; throw new RuntimeException("tried to get nonexistent method "+methodSignature); }
public IccInstrumenter(String iccModel, SootClass dummyMainClass, ComponentEntryPointCollection componentToEntryPoint) { this.iccModel = iccModel; this.dummyMainClass = dummyMainClass; this.componentToEntryPoint = componentToEntryPoint; // Fetch some Soot methods smMessengerSend = Scene.v().grabMethod("<android.os.Messenger: void send(android.os.Message)>"); }
sources = new HashSet<>(); for (String signature : sourceDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) sources.add(sm); sinks = new HashSet<>(); for (String signature : sinkDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) sinks.add(sm); returnTaintMethods = new HashSet<>(); for (String signature : returnTaintMethodDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) returnTaintMethods.add(sm); parameterTaintMethods = new HashSet<>(); for (String signature : parameterTaintMethodDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) parameterTaintMethods.add(sm);
sources = new HashSet<>(); for (String signature : sourceDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) sources.add(sm); sinks = new HashSet<>(); for (String signature : sinkDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) sinks.add(sm); returnTaintMethods = new HashSet<>(); for (String signature : returnTaintMethodDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) returnTaintMethods.add(sm); parameterTaintMethods = new HashSet<>(); for (String signature : parameterTaintMethodDefs) { SootMethod sm = Scene.v().grabMethod(signature); if (sm != null) parameterTaintMethods.add(sm);
sourceMethods.put(sootMethod, sourceSinkDef); } else { SootMethod sm = Scene.v().grabMethod(entry.getO1()); if (sm != null) sourceMethods.put(sm, sourceSinkDef); if (methodSourceSinkDef.getCallType() == CallType.Return) { SootMethodAndClass method = methodSourceSinkDef.getMethod(); SootMethod m = Scene.v().grabMethod(method.getSignature()); if (m != null) sinkReturnMethods.put(m, methodSourceSinkDef); sinkMethods.put(sootMethod, sourceSinkDef); } else { SootMethod sm = Scene.v().grabMethod(entry.getO1()); if (sm != null) sinkMethods.put(sm, entry.getO2()); this.smActivityFindViewById = Scene.v().grabMethod(Activity_FindViewById); this.smViewFindViewById = Scene.v().grabMethod(View_FindViewById);
SootMethod sm = Scene.v().grabMethod(gd.getSignature()); if (sm != null && sm.isStatic()) continue;
SootMethod callee = Scene.v().grabMethod(curGap.getSignature()); if (callee != null) for (SootMethod implementor : getAllImplementors(callee))
public SkipSystemClassRule(InfoflowManager manager, Abstraction zeroValue, TaintPropagationResults results) { super(manager, zeroValue, results); // Get the system methods this.objectCons = Scene.v().getObjectType().getSootClass().getMethodUnsafe("void <init>()"); this.objectClinit = Scene.v().getObjectType().getSootClass().getMethodUnsafe("void <clinit>()"); this.objectGetClass = Scene.v().getObjectType().getSootClass().getMethodUnsafe("java.lang.Class getClass()"); this.threadCons = Scene.v().grabMethod("<java.lang.Thread: void <init>()>"); }
final SootMethod m = Scene.v().grabMethod(method); if (m == null) return MethodSummaries.EMPTY_SUMMARIES;
SootMethod fromSM = Scene.v().grabMethod(intent.getLoggingPoint().getCallerMethodSignature()); Stmt fromU = linkWithTarget(fromSM, intent.getLoggingPoint().getStmtSequence()); IccLink iccLink = new IccLink(fromSM, fromU, Scene.v().getSootClassUnsafe(targetComp.getName())); SootMethod fromSM = Scene.v().grabMethod(intent.getLoggingPoint().getCallerMethodSignature()); if (fromSM != null) { Stmt fromU = linkWithTarget(fromSM, intent.getLoggingPoint().getStmtSequence());
/** * Creates an implementation of setResult() that writes the given intent into * the correct field */ private void createSetResultMethod() { // We need to create an implementation of "getIntent". If there is already such // an implementation, we don't touch it. if (component.declaresMethod("void setResult(int,android.content.Intent)")) return; Type intentType = RefType.v("android.content.Intent"); List<Type> params = new ArrayList<>(); params.add(IntType.v()); params.add(intentType); SootMethod sm = Scene.v().makeSootMethod("setResult", params, VoidType.v(), Modifier.PUBLIC); component.addMethod(sm); sm.addTag(SimulatedCodeElementTag.TAG); JimpleBody b = Jimple.v().newBody(sm); sm.setActiveBody(b); b.insertIdentityStmts(); Local lcIntent = b.getParameterLocal(1); b.getUnits().add(Jimple.v().newAssignStmt( Jimple.v().newInstanceFieldRef(b.getThisLocal(), resultIntentField.makeRef()), lcIntent)); b.getUnits().add(Jimple.v().newReturnVoidStmt()); // Activity.setResult() is final. We need to change that SootMethod smSetResult = Scene.v() .grabMethod("<android.app.Activity: void setResult(int,android.content.Intent)>"); if (smSetResult != null && smSetResult.getDeclaringClass().isApplicationClass()) smSetResult.setModifiers(smSetResult.getModifiers() & ~Modifier.FINAL); }
.grabMethod("<android.view.View$OnClickListener: void onClick(android.view.View)>");
/** * Creates a new implementation for the given method * * @param sm * The method for which to generate a new implementation * @param injector * Callback to inject additional code into the new method */ private void generateMessageObtainMethod(SootMethod sm, IMessageObtainCodeInjector injector) { // Create the method RefType tpMessage = RefType.v("android.os.Message"); sm.getDeclaringClass().setLibraryClass(); sm.setPhantom(false); sm.addTag(new FlowDroidEssentialMethodTag()); // Create a body for the method JimpleBody body = Jimple.v().newBody(sm); sm.setActiveBody(body); body.insertIdentityStmts(); SootMethod smMessageConstructor = Scene.v().grabMethod("<android.os.Message: void <init>()>"); LocalGenerator lg = new LocalGenerator(body); Local messageLocal = lg.generateLocal(tpMessage); body.getUnits().add(Jimple.v().newAssignStmt(messageLocal, Jimple.v().newNewExpr(tpMessage))); body.getUnits().add(Jimple.v() .newInvokeStmt(Jimple.v().newSpecialInvokeExpr(messageLocal, smMessageConstructor.makeRef()))); if (injector != null) injector.injectCode(body, messageLocal); body.getUnits().add(Jimple.v().newReturnStmt(messageLocal)); }
SootMethod runMethod = Scene.v().grabMethod("<java.util.TimerTask: void run()>"); if (runMethod != null) { Stmt invokeStmt = Jimple.v()