Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
1f5cdeb0
Commit
1f5cdeb0
authored
Jul 09, 2016
by
chenzhong.cz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support arsc raw file view
parent
b2f41e95
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
37 deletions
+68
-37
ResourceFile.java
jadx-core/src/main/java/jadx/api/ResourceFile.java
+3
-3
ResourcesLoader.java
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
+35
-21
RenameVisitor.java
...e/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
+8
-2
AndroidResourcesUtils.java
...n/java/jadx/core/utils/android/AndroidResourcesUtils.java
+5
-1
InputFile.java
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
+1
-1
JRoot.java
jadx-gui/src/main/java/jadx/gui/treemodel/JRoot.java
+15
-8
MainWindow.java
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/api/ResourceFile.java
View file @
1f5cdeb0
package
jadx
.
api
;
package
jadx
.
api
;
import
jadx.core.xmlgen.ResContainer
;
import
java.io.File
;
import
java.io.File
;
import
jadx.core.xmlgen.ResContainer
;
public
class
ResourceFile
{
public
class
ResourceFile
{
public
static
final
class
ZipRef
{
public
static
final
class
ZipRef
{
...
@@ -56,7 +56,7 @@ public class ResourceFile {
...
@@ -56,7 +56,7 @@ public class ResourceFile {
this
.
zipRef
=
zipRef
;
this
.
zipRef
=
zipRef
;
}
}
ZipRef
getZipRef
()
{
public
ZipRef
getZipRef
()
{
return
zipRef
;
return
zipRef
;
}
}
...
...
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
View file @
1f5cdeb0
package
jadx
.
api
;
package
jadx
.
api
;
import
jadx.api.ResourceFile.ZipRef
;
import
org.slf4j.Logger
;
import
jadx.core.codegen.CodeWriter
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.utils.Utils
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.files.InputFile
;
import
jadx.core.xmlgen.ResContainer
;
import
jadx.core.xmlgen.ResTableParser
;
import
java.io.BufferedInputStream
;
import
java.io.BufferedInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
...
@@ -19,8 +15,13 @@ import java.util.List;
...
@@ -19,8 +15,13 @@ import java.util.List;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipFile
;
import
java.util.zip.ZipFile
;
import
org.slf4j.Logger
;
import
jadx.api.ResourceFile.ZipRef
;
import
org.slf4j.LoggerFactory
;
import
jadx.core.codegen.CodeWriter
;
import
jadx.core.utils.Utils
;
import
jadx.core.utils.exceptions.JadxException
;
import
jadx.core.utils.files.InputFile
;
import
jadx.core.xmlgen.ResContainer
;
import
jadx.core.xmlgen.ResTableParser
;
import
static
jadx
.
core
.
utils
.
files
.
FileUtils
.
READ_BUFFER_SIZE
;
import
static
jadx
.
core
.
utils
.
files
.
FileUtils
.
READ_BUFFER_SIZE
;
import
static
jadx
.
core
.
utils
.
files
.
FileUtils
.
close
;
import
static
jadx
.
core
.
utils
.
files
.
FileUtils
.
close
;
...
@@ -51,30 +52,35 @@ public final class ResourcesLoader {
...
@@ -51,30 +52,35 @@ public final class ResourcesLoader {
}
}
public
static
ResContainer
decodeStream
(
ResourceFile
rf
,
ResourceDecoder
decoder
)
throws
JadxException
{
public
static
ResContainer
decodeStream
(
ResourceFile
rf
,
ResourceDecoder
decoder
)
throws
JadxException
{
ZipRef
zipRef
=
rf
.
getZipRef
();
if
(
zipRef
==
null
)
{
return
null
;
}
ZipFile
zipFile
=
null
;
ZipFile
zipFile
=
null
;
InputStream
inputStream
=
null
;
InputStream
inputStream
=
null
;
ResContainer
result
=
null
;
ResContainer
result
=
null
;
try
{
try
{
zipFile
=
new
ZipFile
(
zipRef
.
getZipFile
());
long
size
;
ZipEntry
entry
=
zipFile
.
getEntry
(
zipRef
.
getEntryName
());
ZipRef
zipRef
=
rf
.
getZipRef
();
if
(
entry
==
null
)
{
if
(
zipRef
==
null
)
{
throw
new
IOException
(
"Zip entry not found: "
+
zipRef
);
File
file
=
new
File
(
rf
.
getName
());
inputStream
=
new
BufferedInputStream
(
new
FileInputStream
(
file
));
size
=
file
.
length
();
}
else
{
zipFile
=
new
ZipFile
(
zipRef
.
getZipFile
());
ZipEntry
entry
=
zipFile
.
getEntry
(
zipRef
.
getEntryName
());
if
(
entry
==
null
)
{
throw
new
IOException
(
"Zip entry not found: "
+
zipRef
);
}
inputStream
=
new
BufferedInputStream
(
zipFile
.
getInputStream
(
entry
));
size
=
entry
.
getSize
();
}
}
inputStream
=
new
BufferedInputStream
(
zipFile
.
getInputStream
(
entry
));
result
=
decoder
.
decode
(
size
,
inputStream
);
result
=
decoder
.
decode
(
entry
.
getSize
(),
inputStream
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
JadxException
(
"Error decode: "
+
zipRef
.
getEntry
Name
(),
e
);
throw
new
JadxException
(
"Error decode: "
+
rf
.
get
Name
(),
e
);
}
finally
{
}
finally
{
try
{
try
{
if
(
zipFile
!=
null
)
{
if
(
zipFile
!=
null
)
{
zipFile
.
close
();
zipFile
.
close
();
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Error close zip file: {}"
,
zipRef
,
e
);
LOG
.
error
(
"Error close zip file: {}"
,
rf
.
getName
()
,
e
);
}
}
close
(
inputStream
);
close
(
inputStream
);
}
}
...
@@ -133,6 +139,7 @@ public final class ResourcesLoader {
...
@@ -133,6 +139,7 @@ public final class ResourcesLoader {
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
LOG
.
debug
(
"Not a zip file: {}"
,
file
.
getAbsolutePath
());
LOG
.
debug
(
"Not a zip file: {}"
,
file
.
getAbsolutePath
());
addResourceFile
(
list
,
file
);
}
finally
{
}
finally
{
if
(
zip
!=
null
)
{
if
(
zip
!=
null
)
{
try
{
try
{
...
@@ -144,6 +151,13 @@ public final class ResourcesLoader {
...
@@ -144,6 +151,13 @@ public final class ResourcesLoader {
}
}
}
}
private
void
addResourceFile
(
List
<
ResourceFile
>
list
,
File
file
)
{
String
name
=
file
.
getAbsolutePath
();
ResourceType
type
=
ResourceType
.
getFileType
(
name
);
ResourceFile
rf
=
new
ResourceFile
(
jadxRef
,
name
,
type
);
list
.
add
(
rf
);
}
private
void
addEntry
(
List
<
ResourceFile
>
list
,
File
zipFile
,
ZipEntry
entry
)
{
private
void
addEntry
(
List
<
ResourceFile
>
list
,
File
zipFile
,
ZipEntry
entry
)
{
if
(
entry
.
isDirectory
())
{
if
(
entry
.
isDirectory
())
{
return
;
return
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/RenameVisitor.java
View file @
1f5cdeb0
...
@@ -10,6 +10,7 @@ import jadx.core.dex.info.FieldInfo;
...
@@ -10,6 +10,7 @@ import jadx.core.dex.info.FieldInfo;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.info.MethodInfo
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.instructions.args.ArgType
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.DexNode
;
import
jadx.core.dex.nodes.FieldNode
;
import
jadx.core.dex.nodes.FieldNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.MethodNode
;
import
jadx.core.dex.nodes.RootNode
;
import
jadx.core.dex.nodes.RootNode
;
...
@@ -18,6 +19,7 @@ import jadx.core.utils.files.InputFile;
...
@@ -18,6 +19,7 @@ import jadx.core.utils.files.InputFile;
import
java.io.File
;
import
java.io.File
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.FilenameUtils
;
...
@@ -33,13 +35,17 @@ public class RenameVisitor extends AbstractVisitor {
...
@@ -33,13 +35,17 @@ public class RenameVisitor extends AbstractVisitor {
public
void
init
(
RootNode
root
)
{
public
void
init
(
RootNode
root
)
{
IJadxArgs
args
=
root
.
getArgs
();
IJadxArgs
args
=
root
.
getArgs
();
InputFile
firstInputFile
=
root
.
getDexNodes
().
get
(
0
).
getDexFile
().
getInputFile
();
List
<
DexNode
>
dexNodes
=
root
.
getDexNodes
();
if
(
dexNodes
.
size
()
==
0
)
{
return
;
}
InputFile
firstInputFile
=
dexNodes
.
get
(
0
).
getDexFile
().
getInputFile
();
final
String
firstInputFileName
=
firstInputFile
.
getFile
().
getAbsolutePath
();
final
String
firstInputFileName
=
firstInputFile
.
getFile
().
getAbsolutePath
();
final
String
inputPath
=
FilenameUtils
.
getFullPathNoEndSeparator
(
firstInputFileName
);
final
String
inputPath
=
FilenameUtils
.
getFullPathNoEndSeparator
(
firstInputFileName
);
final
String
inputName
=
FilenameUtils
.
getBaseName
(
firstInputFileName
);
final
String
inputName
=
FilenameUtils
.
getBaseName
(
firstInputFileName
);
File
deobfMapFile
=
new
File
(
inputPath
,
inputName
+
".jobf"
);
File
deobfMapFile
=
new
File
(
inputPath
,
inputName
+
".jobf"
);
deobfuscator
=
new
Deobfuscator
(
args
,
root
.
getDexNodes
()
,
deobfMapFile
);
deobfuscator
=
new
Deobfuscator
(
args
,
dexNodes
,
deobfMapFile
);
boolean
deobfuscationOn
=
args
.
isDeobfuscationOn
();
boolean
deobfuscationOn
=
args
.
isDeobfuscationOn
();
if
(
deobfuscationOn
)
{
if
(
deobfuscationOn
)
{
deobfuscator
.
execute
();
deobfuscator
.
execute
();
...
...
jadx-core/src/main/java/jadx/core/utils/android/AndroidResourcesUtils.java
View file @
1f5cdeb0
...
@@ -48,7 +48,11 @@ public class AndroidResourcesUtils {
...
@@ -48,7 +48,11 @@ public class AndroidResourcesUtils {
}
}
private
static
ClassNode
makeClass
(
RootNode
root
,
String
clsName
)
{
private
static
ClassNode
makeClass
(
RootNode
root
,
String
clsName
)
{
DexNode
firstDex
=
root
.
getDexNodes
().
get
(
0
);
List
<
DexNode
>
dexNodes
=
root
.
getDexNodes
();
if
(
dexNodes
.
size
()
==
0
)
{
return
null
;
}
DexNode
firstDex
=
dexNodes
.
get
(
0
);
ClassInfo
r
=
ClassInfo
.
fromName
(
firstDex
,
clsName
);
ClassInfo
r
=
ClassInfo
.
fromName
(
firstDex
,
clsName
);
return
new
ClassNode
(
firstDex
,
r
);
return
new
ClassNode
(
firstDex
,
r
);
}
}
...
...
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
View file @
1f5cdeb0
...
@@ -68,7 +68,7 @@ public class InputFile {
...
@@ -68,7 +68,7 @@ public class InputFile {
loadFromZip
(
".jar"
);
loadFromZip
(
".jar"
);
return
;
return
;
}
}
throw
new
DecodeException
(
"Unsupported input file format: "
+
file
);
//
throw new DecodeException("Unsupported input file format: " + file);
}
}
private
void
addDexFile
(
Dex
dexBuf
)
throws
IOException
{
private
void
addDexFile
(
Dex
dexBuf
)
throws
IOException
{
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JRoot.java
View file @
1f5cdeb0
package
jadx
.
gui
.
treemodel
;
package
jadx
.
gui
.
treemodel
;
import
jadx.api.ResourceFile
;
import
jadx.gui.JadxWrapper
;
import
jadx.gui.treemodel.JResource.JResType
;
import
jadx.gui.utils.Utils
;
import
javax.swing.Icon
;
import
javax.swing.ImageIcon
;
import
java.io.File
;
import
java.io.File
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Enumeration
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.List
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
javax.swing.Icon
;
import
javax.swing.ImageIcon
;
import
jadx.api.ResourceFile
;
import
jadx.gui.JadxWrapper
;
import
jadx.gui.treemodel.JResource.JResType
;
import
jadx.gui.utils.Utils
;
public
class
JRoot
extends
JNode
{
public
class
JRoot
extends
JNode
{
private
static
final
long
serialVersionUID
=
8888495789773527342L
;
private
static
final
long
serialVersionUID
=
8888495789773527342L
;
...
@@ -45,7 +46,13 @@ public class JRoot extends JNode {
...
@@ -45,7 +46,13 @@ public class JRoot extends JNode {
JResource
root
=
new
JResource
(
null
,
"Resources"
,
JResType
.
ROOT
);
JResource
root
=
new
JResource
(
null
,
"Resources"
,
JResType
.
ROOT
);
String
splitPathStr
=
Pattern
.
quote
(
File
.
separator
);
String
splitPathStr
=
Pattern
.
quote
(
File
.
separator
);
for
(
ResourceFile
rf
:
resources
)
{
for
(
ResourceFile
rf
:
resources
)
{
String
[]
parts
=
new
File
(
rf
.
getName
()).
getPath
().
split
(
splitPathStr
);
String
rfName
;
if
(
rf
.
getZipRef
()
!=
null
)
{
rfName
=
rf
.
getName
();
}
else
{
rfName
=
new
File
(
rf
.
getName
()).
getName
();
}
String
[]
parts
=
new
File
(
rfName
).
getPath
().
split
(
splitPathStr
);
JResource
curRf
=
root
;
JResource
curRf
=
root
;
int
count
=
parts
.
length
;
int
count
=
parts
.
length
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
...
...
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
View file @
1f5cdeb0
...
@@ -171,7 +171,7 @@ public class MainWindow extends JFrame {
...
@@ -171,7 +171,7 @@ public class MainWindow extends JFrame {
public
void
openFile
()
{
public
void
openFile
()
{
JFileChooser
fileChooser
=
new
JFileChooser
();
JFileChooser
fileChooser
=
new
JFileChooser
();
fileChooser
.
setAcceptAllFileFilterUsed
(
true
);
fileChooser
.
setAcceptAllFileFilterUsed
(
true
);
String
[]
exts
=
{
"apk"
,
"dex"
,
"jar"
,
"class"
,
"zip"
,
"aar"
};
String
[]
exts
=
{
"apk"
,
"dex"
,
"jar"
,
"class"
,
"zip"
,
"aar"
,
"arsc"
};
String
description
=
"supported files: "
+
Arrays
.
toString
(
exts
).
replace
(
'['
,
'('
).
replace
(
']'
,
')'
);
String
description
=
"supported files: "
+
Arrays
.
toString
(
exts
).
replace
(
'['
,
'('
).
replace
(
']'
,
')'
);
fileChooser
.
setFileFilter
(
new
FileNameExtensionFilter
(
description
,
exts
));
fileChooser
.
setFileFilter
(
new
FileNameExtensionFilter
(
description
,
exts
));
fileChooser
.
setToolTipText
(
NLS
.
str
(
"file.open"
));
fileChooser
.
setToolTipText
(
NLS
.
str
(
"file.open"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment