Skip to content

Commit

Permalink
Swap dex2jar dependency for proguard-core-android
Browse files Browse the repository at this point in the history
Uses Jitpack since ProGuardCORE with dex support has not been released yet.
  • Loading branch information
mrjameshamilton committed Aug 5, 2022
1 parent 6677ce3 commit a222b70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 122 deletions.
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ repositories {
}

dependencies {
implementation("com.guardsquare:proguard-core:8.0.5")
implementation("com.github.pxb1988:dex2jar:v2.1")
implementation("com.github.Guardsquare:proguard-core:89f74ba111")
testImplementation(kotlin("test"))
testImplementation("io.kotest:kotest-runner-junit5-jvm:5.0.3")
testImplementation("io.kotest:kotest-assertions-core-jvm:5.0.3")
Expand Down
72 changes: 10 additions & 62 deletions src/main/kotlin/eu/jameshamilton/log4shell/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,14 @@ import proguard.classfile.AccessConstants.PRIVATE
import proguard.classfile.ClassPool
import proguard.classfile.visitor.AllMemberVisitor
import proguard.classfile.visitor.ClassCounter
import proguard.classfile.visitor.ClassPoolFiller
import proguard.classfile.visitor.ConstructorMethodFilter
import proguard.classfile.visitor.MemberAccessFilter
import proguard.classfile.visitor.MemberCounter
import proguard.classfile.visitor.MemberDescriptorFilter
import proguard.classfile.visitor.MethodFilter
import proguard.io.ClassReader
import proguard.io.DataEntryNameFilter
import proguard.io.DataEntryReader
import proguard.io.Dex2JarReader
import proguard.io.DirectorySource
import proguard.io.FilteredDataEntryReader
import proguard.io.JarReader
import proguard.io.DexClassReader
import proguard.io.NameFilteredDataEntryReader
import proguard.util.ExtensionMatcher
import proguard.util.OrMatcher
import proguard.io.util.IOUtil.read
import java.io.File

fun main(args: Array<String>) {
Expand Down Expand Up @@ -91,58 +83,14 @@ fun check(programClassPool: ClassPool): Boolean {
return jndiManagerOldConstructorCounter.count > 0
}

private fun readInput(inputFile: File): ClassPool {
val programClassPool = ClassPool()
var classReader: DataEntryReader = NameFilteredDataEntryReader(
"**.class",
ClassReader(
/* isLibrary = */ false,
/* skipNonPublicLibraryClasses = */ false,
/* skipNonPublicLibraryClassMembers = */ false,
/* ignoreStackMapAttributes = */ false,
/* warningPrinter = */ null,
ClassPoolFiller(programClassPool)
)
)

classReader = NameFilteredDataEntryReader(
"classes*.dex",
Dex2JarReader(
false,
classReader
),
classReader
)

classReader = FilteredDataEntryReader(
DataEntryNameFilter(ExtensionMatcher(".aar")),
JarReader(
NameFilteredDataEntryReader(
"classes.jar",
JarReader(classReader)
)
),
FilteredDataEntryReader(
DataEntryNameFilter(
OrMatcher(
ExtensionMatcher(".jar"),
ExtensionMatcher(".war"),
ExtensionMatcher(".zip"),
ExtensionMatcher(".apk")
)
private fun readInput(inputFile: File): ClassPool =
read(inputFile.absolutePath, "**", true) { dataEntryReader, classPoolFiller ->
NameFilteredDataEntryReader(
"classes*.dex",
DexClassReader(
false,
classPoolFiller
),
JarReader(classReader),
classReader
dataEntryReader
)
)

DirectorySource(inputFile).pumpDataEntries {
try {
classReader.read(it)
} catch (e: Exception) {
println("ERROR: Failed to read '${it.name}'")
}
}

return programClassPool
}
58 changes: 0 additions & 58 deletions src/main/kotlin/proguard/io/Dex2JarReader.kt

This file was deleted.

0 comments on commit a222b70

Please sign in to comment.