Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_39073359
jadx
提交
ecf20020
J
jadx
项目概览
qq_39073359
/
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,发现更多精彩内容 >>
未验证
提交
ecf20020
编写于
12月 20, 2021
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: cache current working dir in static field, other minor changes
上级
ae85af61
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
45 deletion
+19
-45
jadx-core/src/main/java/jadx/api/ResourceType.java
jadx-core/src/main/java/jadx/api/ResourceType.java
+1
-1
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
+5
-43
jadx-plugins/jadx-plugins-api/src/main/java/jadx/api/plugins/utils/CommonFileUtils.java
...src/main/java/jadx/api/plugins/utils/CommonFileUtils.java
+12
-0
jadx-plugins/jadx-plugins-api/src/main/java/jadx/api/plugins/utils/ZipSecurity.java
...api/src/main/java/jadx/api/plugins/utils/ZipSecurity.java
+1
-1
未找到文件。
jadx-core/src/main/java/jadx/api/ResourceType.java
浏览文件 @
ecf20020
...
...
@@ -41,7 +41,7 @@ public enum ResourceType {
}
public
static
ResourceType
getFileType
(
String
fileName
)
{
if
(
fileName
.
matches
(
"[^/]+
/resources.pb"
))
{
if
(
fileName
.
endsWith
(
"
/resources.pb"
))
{
return
ARSC
;
}
int
dot
=
fileName
.
lastIndexOf
(
'.'
);
...
...
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
浏览文件 @
ecf20020
...
...
@@ -14,14 +14,11 @@ import java.nio.file.Path;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarOutputStream
;
import
java.util.stream.Stream
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
...
...
@@ -117,7 +114,11 @@ public class FileUtils {
try
(
Stream
<
Path
>
pathStream
=
Files
.
walk
(
dir
))
{
pathStream
.
sorted
(
Comparator
.
reverseOrder
())
.
map
(
Path:
:
toFile
)
.
forEach
(
File:
:
delete
);
.
forEach
(
file
->
{
if
(!
file
.
delete
())
{
LOG
.
warn
(
"Failed to remove file: {}"
,
file
.
getAbsolutePath
());
}
});
}
catch
(
Exception
e
)
{
throw
new
JadxRuntimeException
(
"Failed to delete directory "
+
dir
,
e
);
}
...
...
@@ -259,45 +260,6 @@ public class FileUtils {
return
false
;
}
private
static
List
<
String
>
getZipFileList
(
File
file
)
{
List
<
String
>
filesList
=
new
ArrayList
<>();
try
(
ZipFile
zipFile
=
new
ZipFile
(
file
))
{
Enumeration
<?
extends
ZipEntry
>
entries
=
zipFile
.
entries
();
while
(
entries
.
hasMoreElements
())
{
ZipEntry
entry
=
entries
.
nextElement
();
filesList
.
add
(
entry
.
getName
());
}
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Error read zip file '{}'"
,
file
.
getAbsolutePath
(),
e
);
}
return
filesList
;
}
public
static
boolean
isApkFile
(
File
file
)
{
if
(!
isZipFile
(
file
))
{
return
false
;
}
List
<
String
>
filesList
=
getZipFileList
(
file
);
return
filesList
.
contains
(
"AndroidManifest.xml"
)
&&
filesList
.
contains
(
"classes.dex"
);
}
public
static
boolean
isZipDexFile
(
File
file
)
{
if
(!
isZipFile
(
file
)
||
!
isZipFileCanBeOpen
(
file
))
{
return
false
;
}
List
<
String
>
filesList
=
getZipFileList
(
file
);
return
filesList
.
contains
(
"classes.dex"
);
}
private
static
boolean
isZipFileCanBeOpen
(
File
file
)
{
try
(
ZipFile
zipFile
=
new
ZipFile
(
file
))
{
return
zipFile
.
entries
().
hasMoreElements
();
}
catch
(
Exception
e
)
{
return
false
;
}
}
public
static
String
getPathBaseName
(
Path
file
)
{
String
fileName
=
file
.
getFileName
().
toString
();
int
extEndIndex
=
fileName
.
lastIndexOf
(
'.'
);
...
...
jadx-plugins/jadx-plugins-api/src/main/java/jadx/api/plugins/utils/CommonFileUtils.java
浏览文件 @
ecf20020
package
jadx.api.plugins.utils
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
...
...
@@ -9,6 +10,17 @@ import java.nio.file.Path;
public
class
CommonFileUtils
{
public
static
final
File
CWD
=
getCWD
();
public
static
final
Path
CWD_PATH
=
CWD
.
toPath
();
private
static
File
getCWD
()
{
try
{
return
new
File
(
"."
).
getCanonicalFile
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"Failed to init current working dir constant"
,
e
);
}
}
public
static
Path
saveToTempFile
(
InputStream
in
,
String
suffix
)
throws
IOException
{
return
saveToTempFile
(
null
,
in
,
suffix
);
}
...
...
jadx-plugins/jadx-plugins-api/src/main/java/jadx/api/plugins/utils/ZipSecurity.java
浏览文件 @
ecf20020
...
...
@@ -48,7 +48,7 @@ public class ZipSecurity {
// and prevents cases like "../classes.dex", to limit output only to the specified directory
public
static
boolean
isValidZipEntryName
(
String
entryName
)
{
try
{
File
currentPath
=
new
File
(
"."
).
getCanonicalFile
()
;
File
currentPath
=
CommonFileUtils
.
CWD
;
File
canonical
=
new
File
(
currentPath
,
entryName
).
getCanonicalFile
();
if
(
isInSubDirectoryInternal
(
currentPath
,
canonical
))
{
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录