Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
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
55f16cc3
Commit
55f16cc3
authored
Dec 21, 2014
by
YASME-Tim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Boundaries check. Testing with other given xml binaries.
parent
e01789bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
4 deletions
+39
-4
BinaryXMLParser.java
...-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
+39
-4
No files found.
jadx-core/src/main/java/jadx/core/xmlgen/BinaryXMLParser.java
View file @
55f16cc3
...
...
@@ -42,12 +42,15 @@ public class BinaryXMLParser {
if
(
cInt16
(
bytes
,
count
)
!=
0x0003
)
die
(
"Version is not 3"
);
if
(
cInt16
(
bytes
,
count
)
!=
0x0008
)
die
(
"Size of header is not 8"
);
if
(
cInt32
(
bytes
,
count
)
!=
bytes
.
length
)
die
(
"Size of manifest doesn't match"
);
while
(
true
)
{
while
(
(
count
+
2
)<=
bytes
.
length
)
{
int
type
=
cInt16
(
bytes
,
count
);
if
(
type
==
0x0001
)
parseStringPool
();
else
if
(
type
==
0x0180
)
parseResourceMap
();
else
if
(
type
==
0x0100
)
parseNameSpace
();
else
if
(
type
==
0x0101
)
parseNameSpaceEnd
();
else
if
(
type
==
0x0102
)
parseElement
();
else
if
(
type
==
0x0103
)
parseElementEnd
();
else
if
(
type
==
0x0000
)
continue
;
// NullType is just doing nothing
else
die
(
"Type: "
+
Integer
.
toHexString
(
type
)
+
" not yet implemented"
);
System
.
out
.
println
(
"COUNT: "
+
Integer
.
toHexString
(
count
));
}
...
...
@@ -105,7 +108,8 @@ public class BinaryXMLParser {
if
(
cInt16
(
bytes
,
count
)
!=
0x0010
)
die
(
"NAMESPACE header is not 0x0010"
);
if
(
cInt32
(
bytes
,
count
)
!=
0x18
)
die
(
"NAMESPACE header chunk is not 0x18 big"
);
int
beginLineNumber
=
cInt32
(
bytes
,
count
);
if
(
beginLineNumber
!=
2
)
die
(
"NAMESPACE beginning line number != 2 not supported yet"
);
//if(beginLineNumber!=2) die("NAMESPACE beginning line number != 2 not supported yet");
System
.
out
.
println
(
"NAMESPACE BEGIN Line: "
+
beginLineNumber
);
System
.
out
.
println
(
"Comment: 0x"
+
Integer
.
toHexString
(
cInt32
(
bytes
,
count
)));
int
beginPrefix
=
cInt32
(
bytes
,
count
);
System
.
out
.
println
(
"Prefix: "
+
strings
[
beginPrefix
]);
...
...
@@ -115,9 +119,24 @@ public class BinaryXMLParser {
System
.
out
.
println
(
"COUNT: "
+
Integer
.
toHexString
(
count
));
}
private
void
parseNameSpaceEnd
()
{
if
(
cInt16
(
bytes
,
count
)
!=
0x0010
)
die
(
"NAMESPACE header is not 0x0010"
);
if
(
cInt32
(
bytes
,
count
)
!=
0x18
)
die
(
"NAMESPACE header chunk is not 0x18 big"
);
int
endLineNumber
=
cInt32
(
bytes
,
count
);
//if(endLineNumber!=2) die("NAMESPACE begining line number != 2 not supported yet");
System
.
out
.
println
(
"NAMESPACE END Line: "
+
endLineNumber
);
System
.
out
.
println
(
"Comment: 0x"
+
Integer
.
toHexString
(
cInt32
(
bytes
,
count
)));
int
endPrefix
=
cInt32
(
bytes
,
count
);
System
.
out
.
println
(
"Prefix: "
+
strings
[
endPrefix
]);
nsPrefix
=
strings
[
endPrefix
];
int
endURI
=
cInt32
(
bytes
,
count
);
System
.
out
.
println
(
"URI: "
+
strings
[
endURI
]);
}
private
void
parseElement
()
{
if
(
cInt16
(
bytes
,
count
)
!=
0x0010
)
die
(
"ELEMENT HEADER SIZE is not 0x10"
);
if
(
cInt32
(
bytes
,
count
)
!=
0x0060
)
die
(
"ELEMENT CHUNK SIZE is not 0x60"
);
//if(cInt32(bytes, count) != 0x0060) die("ELEMENT CHUNK SIZE is not 0x60");
count
+=
4
;
int
elementLineNumber
=
cInt32
(
bytes
,
count
);
System
.
out
.
println
(
"elementLineNumber: "
+
elementLineNumber
);
System
.
out
.
println
(
"Comment: 0x"
+
Integer
.
toHexString
(
cInt32
(
bytes
,
count
)));
...
...
@@ -126,6 +145,7 @@ public class BinaryXMLParser {
System
.
out
.
println
(
"Namespace: 0x"
+
Integer
.
toHexString
(
startNS
));
int
startNSName
=
cInt32
(
bytes
,
count
);
// what to do with this id?
System
.
out
.
println
(
"Namespace name: "
+
strings
[
startNSName
]);
System
.
out
.
println
(
"<"
+
strings
[
startNSName
]
+
""
);
int
attributeStart
=
cInt16
(
bytes
,
count
);
if
(
attributeStart
!=
0x14
)
die
(
"startNS's attributeStart is not 0x14"
);
int
attributeSize
=
cInt16
(
bytes
,
count
);
...
...
@@ -156,8 +176,23 @@ public class BinaryXMLParser {
if
(
attributeNS
!=
-
1
)
System
.
out
.
print
(
nsPrefix
+
":"
);
if
(
attrValDataType
==
0x3
)
System
.
out
.
println
(
strings
[
attributeName
]
+
"="
+
strings
[
attrValData
]);
else
if
(
attrValDataType
==
0x10
)
System
.
out
.
println
(
strings
[
attributeName
]
+
"="
+
attrValData
);
else
System
.
out
.
println
(
"
UNKNOWN DATA TYPE: "
+
attrValDataType
);
else
System
.
out
.
println
(
strings
[
attributeName
]
+
" =
UNKNOWN DATA TYPE: "
+
attrValDataType
);
}
System
.
out
.
println
(
">"
);
}
private
void
parseElementEnd
()
{
if
(
cInt16
(
bytes
,
count
)
!=
0x0010
)
die
(
"ELEMENT END header is not 0x0010"
);
if
(
cInt32
(
bytes
,
count
)
!=
0x18
)
die
(
"ELEMENT END header chunk is not 0x18 big"
);
int
endLineNumber
=
cInt32
(
bytes
,
count
);
//if(endLineNumber!=2) die("NAMESPACE beginning line number != 2 not supported yet");
System
.
out
.
println
(
"ELEMENT END Line:"
+
endLineNumber
);
System
.
out
.
println
(
"Comment: 0x"
+
Integer
.
toHexString
(
cInt32
(
bytes
,
count
)));
int
elementNS
=
cInt32
(
bytes
,
count
);
int
elementName
=
cInt32
(
bytes
,
count
);
System
.
out
.
print
(
"</"
);
if
(
elementNS
!=
-
1
)
System
.
out
.
print
(
strings
[
elementNS
]+
":"
);
System
.
out
.
println
(
strings
[
elementName
]+
">"
);
}
private
int
cInt8
(
byte
[]
bytes
,
int
offset
)
{
...
...
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