Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
90692d89
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,发现更多精彩内容 >>
提交
90692d89
编写于
6月 01, 2018
作者:
S
Sergey Toshin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Xml deobf 2.0
上级
4f02864e
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
99 addition
and
6 deletion
+99
-6
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
+2
-1
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
+7
-0
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
...-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
+49
-5
jadx-core/src/main/java/jadx/core/xmlgen/XmlDeobf.java
jadx-core/src/main/java/jadx/core/xmlgen/XmlDeobf.java
+41
-0
未找到文件。
jadx-core/src/main/java/jadx/api/ResourcesLoader.java
浏览文件 @
90692d89
...
...
@@ -99,7 +99,8 @@ public final class ResourcesLoader {
jadxRef
.
getXmlParser
().
parse
(
inputStream
));
case
ARSC:
return
new
ResTableParser
().
decodeFiles
(
inputStream
);
return
new
ResTableParser
()
.
decodeFiles
(
inputStream
);
case
IMG:
return
ResContainer
.
singleImageFile
(
rf
.
getName
(),
inputStream
);
...
...
jadx-core/src/main/java/jadx/core/codegen/CodeWriter.java
浏览文件 @
90692d89
...
...
@@ -120,6 +120,13 @@ public class CodeWriter {
return
this
;
}
public
void
updateContent
(
String
newData
)
{
offset
=
newData
.
length
();
buf
=
new
StringBuilder
(
newData
);
line
=
newData
.
split
(
NL
).
length
+
1
;
code
=
newData
;
}
public
CodeWriter
newLine
()
{
addLine
();
return
this
;
...
...
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
浏览文件 @
90692d89
...
...
@@ -56,11 +56,15 @@ public class BinaryXMLParser extends CommonBinaryParser {
private
int
namespaceDepth
=
0
;
private
int
[]
resourceIds
;
public
BinaryXMLParser
(
RootNode
root
)
{
private
RootNode
rootNode
;
private
String
appPackageName
;
public
BinaryXMLParser
(
RootNode
rootNode
)
{
this
.
rootNode
=
rootNode
;
try
{
readAndroidRStyleClass
();
// add application constants
ConstStorage
constStorage
=
root
.
getConstValues
();
ConstStorage
constStorage
=
root
Node
.
getConstValues
();
Map
<
Object
,
FieldNode
>
constFields
=
constStorage
.
getGlobalConstFields
();
for
(
Map
.
Entry
<
Object
,
FieldNode
>
entry
:
constFields
.
entrySet
())
{
Object
key
=
entry
.
getKey
();
...
...
@@ -248,6 +252,7 @@ public class BinaryXMLParser extends CommonBinaryParser {
isOneLine
=
true
;
isLastEnd
=
false
;
currentTag
=
getValidTagAttributeName
(
getString
(
startNSName
));
currentTag
=
deobfClassName
(
currentTag
);
writer
.
startLine
(
"<"
).
add
(
currentTag
);
writer
.
attachSourceLine
(
elementBegLineNumber
);
int
attributeStart
=
is
.
readInt16
();
...
...
@@ -298,16 +303,23 @@ public class BinaryXMLParser extends CommonBinaryParser {
}
else
{
writer
.
add
(
' '
);
}
String
shortNsName
=
null
;
if
(
attributeNS
!=
-
1
)
{
writer
.
add
(
getAttributeNS
(
attributeNS
)).
add
(
':'
);
shortNsName
=
getAttributeNS
(
attributeNS
);
writer
.
add
(
shortNsName
).
add
(
':'
);
}
String
attrName
=
getValidTagAttributeName
(
getAttributeName
(
attributeName
));
writer
.
add
(
attrName
).
add
(
"=\""
);
String
decodedAttr
=
ManifestAttributes
.
getInstance
().
decode
(
attrName
,
attrValData
);
if
(
decodedAttr
!=
null
)
{
memorizePackageName
(
attrName
,
decodedAttr
);
if
(
isDeobfCandidateAttr
(
shortNsName
,
attrName
))
{
decodedAttr
=
deobfClassName
(
decodedAttr
);
}
writer
.
add
(
StringUtils
.
escapeXML
(
decodedAttr
));
}
else
{
decodeAttribute
(
attributeNS
,
attrValDataType
,
attrValData
);
decodeAttribute
(
attributeNS
,
attrValDataType
,
attrValData
,
shortNsName
,
attrName
);
}
writer
.
add
(
'"'
);
}
...
...
@@ -367,7 +379,9 @@ public class BinaryXMLParser extends CommonBinaryParser {
return
"NOT_FOUND_STR_0x"
+
Integer
.
toHexString
(
strId
);
}
private
void
decodeAttribute
(
int
attributeNS
,
int
attrValDataType
,
int
attrValData
)
{
private
void
decodeAttribute
(
int
attributeNS
,
int
attrValDataType
,
int
attrValData
,
String
shortNsName
,
String
attrName
)
{
if
(
attrValDataType
==
TYPE_REFERENCE
)
{
// reference custom processing
String
name
=
styleMap
.
get
(
attrValData
);
...
...
@@ -408,6 +422,10 @@ public class BinaryXMLParser extends CommonBinaryParser {
}
}
else
{
String
str
=
valuesParser
.
decodeValue
(
attrValDataType
,
attrValData
);
memorizePackageName
(
attrName
,
str
);
if
(
isDeobfCandidateAttr
(
shortNsName
,
attrName
))
{
str
=
deobfClassName
(
str
);
}
writer
.
add
(
str
!=
null
?
StringUtils
.
escapeXML
(
str
)
:
"null"
);
}
}
...
...
@@ -465,4 +483,30 @@ public class BinaryXMLParser extends CommonBinaryParser {
}
return
sb
.
toString
();
}
private
String
deobfClassName
(
String
className
)
{
String
newName
=
XmlDeobf
.
deobfClassName
(
rootNode
,
className
,
appPackageName
);
if
(
newName
!=
null
)
{
return
newName
;
}
return
className
;
}
private
boolean
isDeobfCandidateAttr
(
String
shortNsName
,
String
attrName
)
{
String
fullName
;
if
(
shortNsName
!=
null
)
{
fullName
=
shortNsName
+
":"
+
attrName
;
}
else
{
return
false
;
}
return
"android:name"
.
equals
(
fullName
);
}
private
void
memorizePackageName
(
String
attrName
,
String
attrValue
)
{
if
(
"manifest"
.
equals
(
currentTag
)
&&
"package"
.
equals
(
attrName
))
{
appPackageName
=
attrValue
;
}
}
}
jadx-core/src/main/java/jadx/core/xmlgen/XmlDeobf.java
0 → 100644
浏览文件 @
90692d89
package
jadx.core.xmlgen
;
import
java.util.HashMap
;
import
java.util.Map
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.core.dex.nodes.RootNode
;
/*
* modifies android:name attributes and xml tags which are old class names
* but were changed during deobfuscation
*/
public
class
XmlDeobf
{
private
static
final
Map
<
String
,
String
>
deobfMap
=
new
HashMap
<>();
private
XmlDeobf
()
{}
public
static
String
deobfClassName
(
RootNode
rootNode
,
String
potencialClassName
,
String
packageName
)
{
if
(
packageName
!=
null
&&
potencialClassName
.
startsWith
(
"."
))
{
potencialClassName
=
packageName
+
potencialClassName
;
}
return
getNewClassName
(
rootNode
,
potencialClassName
);
}
private
static
String
getNewClassName
(
RootNode
rootNode
,
String
old
)
{
if
(
deobfMap
.
isEmpty
())
{
for
(
ClassNode
classNode
:
rootNode
.
getClasses
(
true
))
{
if
(
classNode
.
getAlias
()
!=
null
)
{
String
oldName
=
classNode
.
getClassInfo
().
getFullName
();
String
newName
=
classNode
.
getAlias
().
getFullName
();
if
(!
oldName
.
equals
(
newName
))
{
deobfMap
.
put
(
oldName
,
newName
);
}
}
}
}
return
deobfMap
.
get
(
old
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录