Skip to content

Commit

Permalink
Merge branch 'develop' into refactorModuleStructure
Browse files Browse the repository at this point in the history
  • Loading branch information
stschott authored Aug 30, 2024
2 parents 6637eb3 + e489617 commit 9559132
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 103 deletions.
37 changes: 35 additions & 2 deletions docs/analysisinput.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,49 @@ AnalysisInputLocation jimpleLocation = new JimpleAnalysisInputLocation(path);
JavaView view = new JavaView(jimpleLocation);
```


### Android Bytecode
File-Extensions: `.apk`

The `ApkAnalysisInputLocation` is the APK frontend written for Sootup

```java
Path path = Paths.get("Banana.apk");
AnalysisInputLocation inputLocation = new ApkAnalysisInputLocation(path, "", DexBodyInterceptors.Default.bodyInterceptors());
JavaView view = new JavaView(inputLocation);
```


### Android Bytecode with Dex2Jar
File-Extensions: `.apk`

The `ApkAnalysisInputLocation` currently uses dex2jar internally

```java
Path path = Paths.get("Banana.apk");
AnalysisInputLocation inputLocation = new ApkAnalysisInputLocation(path);
AnalysisInputLocation inputLocation = new Dex2JarAnalysisInputLocation(path);
JavaView view = new JavaView(inputLocation);

```

```java
public class Dex2JarAnalysisInputLocation extends ArchiveBasedAnalysisInputLocation {

public Dex2JarAnalysisInputLocation(@Nonnull Path path, @Nullable SourceType srcType) {
super(path, srcType);
String jarPath = dex2jar(path);
this.path = Paths.get(jarPath);
}

private String dex2jar(Path path) {
String apkPath = path.toAbsolutePath().toString();
String outDir = "./tmp/";
int start = apkPath.lastIndexOf(File.separator);
int end = apkPath.lastIndexOf(".apk");
String outputFile = outDir + apkPath.substring(start + 1, end) + ".jar";
Dex2jarCmd.main("-f", apkPath, "-o", outputFile);
return outputFile;
}
}
```

!!! info "A SootUp solution to directly generate Jimple is WIP!"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@
@Tag(TestCategories.JAVA_8_CATEGORY)
public class PathBasedAnalysisInputLocationTest extends AnalysisInputLocationTest {

@Test
public void testApk() {
PathBasedAnalysisInputLocation pathBasedNamespace =
new ApkAnalysisInputLocation(apk, SourceType.Application);
final ClassType mainClass =
getIdentifierFactory().getClassType("de.upb.futuresoot.fields.MainActivity");
testClassReceival(pathBasedNamespace, Collections.singletonList(mainClass), 1392);
}

@Test
public void testSingleClass() {
PathBasedAnalysisInputLocation pathBasedNamespace =
Expand Down

0 comments on commit 9559132

Please sign in to comment.