Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76393173
jadx
提交
52412dfe
J
jadx
项目概览
2301_76393173
/
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 搜索 >>
提交
52412dfe
编写于
3月 12, 2021
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(gui): resolve potential command injection, fix other code style issues (#1119)
上级
ab02e6e7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
43 deletion
+45
-43
jadx-gui/src/main/java/jadx/gui/ui/QuarkDialog.java
jadx-gui/src/main/java/jadx/gui/ui/QuarkDialog.java
+45
-43
未找到文件。
jadx-gui/src/main/java/jadx/gui/ui/QuarkDialog.java
浏览文件 @
52412dfe
package
jadx.gui.ui
;
import
java.awt.*
;
import
java.awt.BorderLayout
;
import
java.awt.Container
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.swing.*
;
import
javax.swing.JButton
;
import
javax.swing.JComboBox
;
import
javax.swing.JDialog
;
import
javax.swing.JLabel
;
import
javax.swing.JPanel
;
import
javax.swing.JProgressBar
;
import
javax.swing.SwingWorker
;
import
javax.swing.WindowConstants
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.google.gson.JsonIOException
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.google.gson.JsonSyntaxException
;
import
jadx.gui.settings.JadxSettings
;
import
jadx.gui.treemodel.JRoot
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.
logs.LogCollector
;
import
jadx.gui.utils.
UiUtils
;
class
QuarkDialog
extends
JDialog
{
...
...
@@ -46,7 +51,6 @@ class QuarkDialog extends JDialog {
private
ArrayList
<
Path
>
analyzeFile
=
new
ArrayList
<
Path
>();
public
QuarkDialog
(
MainWindow
mainWindow
)
{
this
.
mainWindow
=
mainWindow
;
this
.
settings
=
mainWindow
.
getSettings
();
this
.
files
=
mainWindow
.
getWrapper
().
getOpenPaths
();
...
...
@@ -56,11 +60,9 @@ class QuarkDialog extends JDialog {
return
;
}
initUI
();
settings
.
loadWindowPos
(
this
);
}
private
boolean
prepareAnalysis
()
{
String
[]
exts
=
new
String
[]
{
"apk"
,
"dex"
};
if
(
this
.
files
.
size
()
!=
1
)
{
...
...
@@ -69,8 +71,8 @@ class QuarkDialog extends JDialog {
int
dotIndex
=
fileName
.
lastIndexOf
(
'.'
);
String
extension
=
(
dotIndex
==
-
1
)
?
""
:
fileName
.
substring
(
dotIndex
+
1
);
if
(
!
Arrays
.
stream
(
exts
).
any
Match
(
extension:
:
equals
))
{
LOG
.
warn
(
"Quark: Current file can't be analysis
"
,
fileName
);
if
(
Arrays
.
stream
(
exts
).
none
Match
(
extension:
:
equals
))
{
LOG
.
warn
(
"Quark: Current file can't be analysis
: {}
"
,
fileName
);
continue
;
}
analyzeFile
.
add
(
filePath
);
...
...
@@ -80,8 +82,8 @@ class QuarkDialog extends JDialog {
String
fileName
=
this
.
files
.
get
(
0
).
toString
();
int
dotIndex
=
fileName
.
lastIndexOf
(
'.'
);
String
extension
=
(
dotIndex
==
-
1
)
?
""
:
fileName
.
substring
(
dotIndex
+
1
);
if
(
!
Arrays
.
stream
(
exts
).
any
Match
(
extension:
:
equals
))
{
LOG
.
warn
(
"Quark: Current file can't be analysis
"
,
fileName
);
if
(
Arrays
.
stream
(
exts
).
none
Match
(
extension:
:
equals
))
{
LOG
.
warn
(
"Quark: Current file can't be analysis
: {}
"
,
fileName
);
return
false
;
}
analyzeFile
.
add
(
this
.
files
.
get
(
0
));
...
...
@@ -99,7 +101,6 @@ class QuarkDialog extends JDialog {
}
public
final
void
initUI
()
{
JLabel
description
=
new
JLabel
(
"Analyzing apk using Quark-Engine"
);
JLabel
selectApkText
=
new
JLabel
(
"Select Apk/Dex"
);
description
.
setAlignmentX
(
0.5f
);
...
...
@@ -144,10 +145,13 @@ class QuarkDialog extends JDialog {
setTitle
(
"Quark Engine"
);
pack
();
setSize
(
200
,
125
);
setDefaultCloseOperation
(
DISPOSE_ON_CLOSE
);
setModalityType
(
ModalityType
.
MODELESS
);
if
(!
mainWindow
.
getSettings
().
loadWindowPos
(
this
))
{
setSize
(
300
,
140
);
}
setLocationRelativeTo
(
null
);
setDefaultCloseOperation
(
WindowConstants
.
DISPOSE_ON_CLOSE
);
setModalityType
(
ModalityType
.
MODELESS
);
UiUtils
.
addEscapeShortCutToDispose
(
this
);
}
private
void
analyzeAPK
()
{
...
...
@@ -156,22 +160,17 @@ class QuarkDialog extends JDialog {
}
private
void
loadReportFile
()
{
try
{
JsonObject
quarkReport
=
(
JsonObject
)
JsonParser
.
parseReader
(
new
FileReader
(
quarkReportFile
.
getAbsolutePath
().
toString
()));
JRoot
root
=
mainWindow
.
getCacheObject
().
getJRoot
();
try
(
Reader
reader
=
new
FileReader
(
quarkReportFile
))
{
JsonObject
quarkReport
=
(
JsonObject
)
JsonParser
.
parseReader
(
reader
);
QuarkReport
quarkNode
=
QuarkReport
.
analysisAPK
(
quarkReport
);
JRoot
root
=
mainWindow
.
getCacheObject
().
getJRoot
();
root
.
update
();
root
.
add
(
quarkNode
);
mainWindow
.
reloadTree
();
}
catch
(
JsonIOException
|
JsonSyntaxException
|
FileNotFoundException
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Quark: Load report failed: "
,
e
);
}
}
private
void
close
()
{
...
...
@@ -180,7 +179,6 @@ class QuarkDialog extends JDialog {
@Override
public
void
dispose
()
{
LogCollector
.
getInstance
().
resetListener
();
settings
.
saveWindowPos
(
this
);
super
.
dispose
();
}
...
...
@@ -193,29 +191,34 @@ class QuarkDialog extends JDialog {
@Override
public
Void
doInBackground
()
{
try
{
quarkReportFile
=
File
.
createTempFile
(
"QuarkReport-"
,
".json"
);
String
outputPath
=
quarkReportFile
.
getAbsolutePath
().
toString
();
String
apkName
=
selectFile
.
getSelectedItem
().
toString
();
String
apkName
=
(
String
)
selectFile
.
getSelectedItem
();
String
apkPath
=
null
;
for
(
Path
path
:
files
)
{
if
(
path
.
getFileName
().
toString
().
equals
(
apkName
))
{
apkPath
=
path
.
toString
();
}
}
String
cmd
=
"quark -a "
+
apkPath
+
" -s -o "
+
outputPath
;
Runtime
run
=
Runtime
.
getRuntime
();
Process
process
=
run
.
exec
(
cmd
);
BufferedReader
buf
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
()));
String
output
=
""
;
LOG
.
debug
(
"Quark analyzing..."
);
while
((
output
=
buf
.
readLine
())
!=
null
)
{
LOG
.
debug
(
output
);
List
<
String
>
cmdList
=
new
ArrayList
<>();
cmdList
.
add
(
"quark"
);
cmdList
.
add
(
"-a"
);
cmdList
.
add
(
apkPath
);
cmdList
.
add
(
"-s"
);
cmdList
.
add
(
"-o"
);
cmdList
.
add
(
quarkReportFile
.
getAbsolutePath
());
LOG
.
debug
(
"Running Quark cmd: {}"
,
String
.
join
(
" "
,
cmdList
));
Process
process
=
Runtime
.
getRuntime
().
exec
(
cmdList
.
toArray
(
new
String
[
0
]));
try
(
BufferedReader
buf
=
new
BufferedReader
(
new
InputStreamReader
(
process
.
getInputStream
())))
{
LOG
.
debug
(
"Quark analyzing..."
);
while
(
process
.
isAlive
())
{
String
output
=
buf
.
readLine
();
if
(
output
!=
null
)
{
LOG
.
debug
(
output
);
}
}
}
}
catch
(
IOException
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Quark failed: "
,
e
);
dispose
();
}
...
...
@@ -228,5 +231,4 @@ class QuarkDialog extends JDialog {
dispose
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录