Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
c801269d
J
jadx
项目概览
Quincy379
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c801269d
编写于
12月 28, 2020
作者:
J
Jan Peter Stotz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Support decompilation of Jar files with Java 8+ code and embedded Jar files
上级
7227f1ac
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
84 addition
and
52 deletion
+84
-52
jadx-plugins/jadx-java-convert/build.gradle
jadx-plugins/jadx-java-convert/build.gradle
+1
-1
jadx-plugins/jadx-java-convert/lib/dx-1.16.jar
jadx-plugins/jadx-java-convert/lib/dx-1.16.jar
+0
-0
jadx-plugins/jadx-java-convert/src/main/java/jadx/plugins/input/javaconvert/D8Converter.java
...main/java/jadx/plugins/input/javaconvert/D8Converter.java
+56
-0
jadx-plugins/jadx-java-convert/src/main/java/jadx/plugins/input/javaconvert/DxConverter.java
...main/java/jadx/plugins/input/javaconvert/DxConverter.java
+0
-49
jadx-plugins/jadx-java-convert/src/main/java/jadx/plugins/input/javaconvert/JavaConvertLoader.java
...ava/jadx/plugins/input/javaconvert/JavaConvertLoader.java
+27
-2
未找到文件。
jadx-plugins/jadx-java-convert/build.gradle
浏览文件 @
c801269d
...
...
@@ -6,7 +6,7 @@ dependencies {
api
(
project
(
":jadx-plugins:jadx-plugins-api"
))
implementation
(
project
(
":jadx-plugins:jadx-dex-input"
))
implementation
(
files
(
'lib/dx-1.16.jar'
))
implementation
'com.android.tools:r8:2.1.75'
implementation
'org.ow2.asm:asm:8.0.1'
}
jadx-plugins/jadx-java-convert/lib/dx-1.16.jar
已删除
100644 → 0
浏览文件 @
7227f1ac
文件已删除
jadx-plugins/jadx-java-convert/src/main/java/jadx/plugins/input/javaconvert/D8Converter.java
0 → 100644
浏览文件 @
c801269d
package
jadx.plugins.input.javaconvert
;
import
java.nio.file.Path
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.android.tools.r8.CompilationMode
;
import
com.android.tools.r8.D8
;
import
com.android.tools.r8.D8Command
;
import
com.android.tools.r8.Diagnostic
;
import
com.android.tools.r8.DiagnosticsHandler
;
import
com.android.tools.r8.OutputMode
;
public
class
D8Converter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
D8Converter
.
class
);
public
static
void
run
(
Path
pathToBeConverted
,
Path
outputDirectory
)
{
LOG
.
info
(
"Converting {} to dex - output dir {}"
,
pathToBeConverted
,
outputDirectory
);
D8Command
.
Builder
builder
=
D8Command
.
builder
(
new
LogHelper
()).
addProgramFiles
(
pathToBeConverted
)
.
setMinApiLevel
(
28
)
.
setMode
(
CompilationMode
.
DEBUG
)
.
setDisableDesugaring
(
true
)
.
setOutput
(
outputDirectory
,
OutputMode
.
DexIndexed
);
try
{
D8Command
command
=
builder
.
build
();
D8
.
run
(
command
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"d8 conversion failed: "
+
e
.
getMessage
(),
e
);
}
}
private
static
class
LogHelper
implements
DiagnosticsHandler
{
@Override
public
void
error
(
Diagnostic
diagnostic
)
{
LOG
.
error
(
diagnosticToString
(
diagnostic
));
}
@Override
public
void
warning
(
Diagnostic
diagnostic
)
{
LOG
.
warn
(
diagnosticToString
(
diagnostic
));
}
@Override
public
void
info
(
Diagnostic
diagnostic
)
{
LOG
.
info
(
diagnosticToString
(
diagnostic
));
}
private
static
String
diagnosticToString
(
Diagnostic
diagnostic
)
{
return
"D8:"
+
diagnostic
.
getDiagnosticMessage
()
+
" origin="
+
diagnostic
.
getOrigin
()
+
" position="
+
diagnostic
.
getPosition
();
}
}
}
jadx-plugins/jadx-java-convert/src/main/java/jadx/plugins/input/javaconvert/DxConverter.java
已删除
100644 → 0
浏览文件 @
7227f1ac
package
jadx.plugins.input.javaconvert
;
import
java.io.ByteArrayOutputStream
;
import
java.nio.file.Path
;
import
com.android.dx.command.dexer.DxContext
;
import
com.android.dx.command.dexer.Main
;
public
class
DxConverter
{
private
static
final
String
CHARSET_NAME
=
"UTF-8"
;
private
static
class
DxArgs
extends
com
.
android
.
dx
.
command
.
dexer
.
Main
.
Arguments
{
public
DxArgs
(
DxContext
context
,
String
dexDir
,
String
[]
input
)
{
super
(
context
);
outName
=
dexDir
;
fileNames
=
input
;
jarOutput
=
false
;
multiDex
=
true
;
optimize
=
true
;
localInfo
=
true
;
coreLibrary
=
true
;
debug
=
true
;
warnings
=
true
;
minSdkVersion
=
28
;
}
}
public
static
void
run
(
Path
path
,
Path
tempDirectory
)
{
int
result
;
String
dxErrors
;
try
(
ByteArrayOutputStream
out
=
new
ByteArrayOutputStream
();
ByteArrayOutputStream
errOut
=
new
ByteArrayOutputStream
())
{
DxContext
context
=
new
DxContext
(
out
,
errOut
);
DxArgs
args
=
new
DxArgs
(
context
,
tempDirectory
.
toAbsolutePath
().
toString
(),
new
String
[]
{
path
.
toAbsolutePath
().
toString
()
});
result
=
new
Main
(
context
).
runDx
(
args
);
dxErrors
=
errOut
.
toString
(
CHARSET_NAME
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"dx exception: "
+
e
.
getMessage
(),
e
);
}
if
(
result
!=
0
)
{
throw
new
RuntimeException
(
"Java to dex conversion error, code: "
+
result
+
"\n errors: "
+
dxErrors
);
}
}
}
jadx-plugins/jadx-java-convert/src/main/java/jadx/plugins/input/javaconvert/JavaConvertLoader.java
浏览文件 @
c801269d
...
...
@@ -99,13 +99,38 @@ public class JavaConvertLoader {
}));
}
/**
* Process a jar file by converting the contained class files and extract the embedded JAR files
*
* @param result
* @param path
* @throws Exception
*/
private
static
void
convertJar
(
ConvertResult
result
,
Path
path
)
throws
Exception
{
// Convert the contained class files
convertSimpleJar
(
result
,
path
);
// Process the embedded jar files
ZipSecurity
.
readZipEntries
(
path
.
toFile
(),
(
entry
,
in
)
->
{
try
{
if
(
entry
.
getName
().
endsWith
(
".jar"
))
{
Path
tempJar
=
saveInputStreamToFile
(
in
,
".jar"
);
result
.
addTempPath
(
tempJar
);
convertSimpleJar
(
result
,
tempJar
);
}
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to process jar entry: {} in {}"
,
entry
,
path
,
e
);
}
});
}
private
static
void
convertSimpleJar
(
ConvertResult
result
,
Path
toBeConvertedPath
)
throws
Exception
{
Path
tempDirectory
=
Files
.
createTempDirectory
(
"jadx-"
);
result
.
addTempPath
(
tempDirectory
);
D
xConverter
.
run
(
p
ath
,
tempDirectory
);
D
8Converter
.
run
(
toBeConvertedP
ath
,
tempDirectory
);
LOG
.
debug
(
"Converted to dex: {}"
,
p
ath
.
toAbsolutePath
());
LOG
.
debug
(
"Converted to dex: {}"
,
toBeConvertedP
ath
.
toAbsolutePath
());
result
.
addConvertedFiles
(
collectFilesInDir
(
tempDirectory
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录