-
-
Save flankerhqd/5c0fc6381077daf3b62d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.sireum.util._ | |
import org.sireum.jawa.MessageCenter._ | |
import org.sireum.amandroid.alir.reachingFactsAnalysis.AndroidReachingFactsAnalysisConfig | |
import org.sireum.jawa.util.Timer | |
import org.sireum.amandroid.security.apiMisuse.InterestingApiCollector | |
import org.sireum.jawa.MessageCenter._ | |
import org.sireum.amandroid.util.AndroidLibraryAPISummary | |
import org.sireum.amandroid.AppCenter | |
import org.sireum.jawa.alir.reachability.ReachabilityAnalysis | |
import org.sireum.jawa.JawaCodeSource | |
import org.sireum.amandroid.AndroidGlobalConfig | |
import org.sireum.jawa.GlobalConfig | |
import java.io.File | |
import org.sireum.jawa.util.APKFileResolver | |
import org.sireum.amandroid.decompile.Dex2PilarConverter | |
import org.sireum.jawa.MessageCenter | |
import org.sireum.amandroid.appInfo.AppInfoCollector | |
import org.sireum.amandroid.security.AmandroidSocket | |
/** | |
* @author <a href="mailto:[email protected]">Fengguo Wei</a> | |
*/ | |
object Test_run { | |
private final val TITLE = "Test_run" | |
def main(args: Array[String]): Unit = { | |
if(args.size != 2){ | |
System.err.print("Usage: source_path dest_path") | |
return | |
} | |
val sourcePath = args(0) | |
val outputPath = args(1) | |
MessageCenter.msglevel = MessageCenter.MSG_LEVEL.CRITICAL | |
try{ | |
AndroidReachingFactsAnalysisConfig.k_context = 1 | |
AndroidReachingFactsAnalysisConfig.resolve_icc = true | |
AndroidReachingFactsAnalysisConfig.resolve_static_init = false | |
val socket = new AmandroidSocket | |
socket.preProcess | |
val files = FileUtil.listFiles(FileUtil.toUri(sourcePath), ".apk", true).toSet | |
files.foreach{ | |
file => | |
try{ | |
msg_critical(TITLE, "####" + file + "#####") | |
AndroidReachingFactsAnalysisConfig.timerOpt = Some(new Timer(10)) | |
val app_info = new AppInfoCollector(file) | |
socket.loadApk(file, outputPath, AndroidLibraryAPISummary, app_info) | |
socket.runWithoutDDA(false, true) | |
val idfgs = AppCenter.getInterproceduralReachingFactsAnalysisResults | |
idfgs.foreach{ | |
idfg=> | |
val icfg = idfg._2._1 | |
val rProcs = icfg.getReachableProcedures(Set("Lcom/example/testwebview/MainActivity;.onCreate:(Landroid/os/Bundle;)V")) | |
if(rProcs.contains("Lcom/example/testwebview/TestActivity;.env:(Landroid/content/Intent;)V")) | |
println(rProcs) | |
} | |
} catch { | |
case e : Throwable => | |
e.printStackTrace() | |
} finally { | |
socket.cleanEnv | |
} | |
} | |
} catch { | |
case e : Throwable => | |
e.printStackTrace() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment