Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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
pwn
libplist
Commits
889cb32a
Commit
889cb32a
authored
Nov 30, 2008
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Continue abstraction of xml and binary plist.
parent
831ee461
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
451 additions
and
483 deletions
+451
-483
plutil.c
dev/plutil.c
+5
-82
plist.c
src/plist.c
+437
-362
plist.h
src/plist.h
+9
-39
No files found.
dev/plutil.c
View file @
889cb32a
...
...
@@ -10,85 +10,6 @@
#include <stdio.h>
#include <stdlib.h>
void
print_nodes
(
bplist_node
*
root_node
)
{
// Yay, great. Let's print the list of nodes recursively...
int
i
=
0
;
if
(
!
root_node
)
return
;
// or not, because the programmer's stupid.
switch
(
root_node
->
type
)
{
case
BPLIST_DICT
:
printf
(
"Dictionary node.
\n
Length %lu
\n
"
,
(
long
unsigned
int
)
root_node
->
length
);
for
(
i
=
0
;
i
<
(
root_node
->
length
*
2
);
i
+=
2
)
{
// HI!
printf
(
"Key: "
);
print_nodes
(
root_node
->
subnodes
[
i
]);
printf
(
"Value: "
);
print_nodes
(
root_node
->
subnodes
[
i
+
1
]);
}
printf
(
"End dictionary node.
\n\n
"
);
break
;
case
BPLIST_ARRAY
:
printf
(
"Array node.
\n
"
);
for
(
i
=
0
;
i
<
root_node
->
length
;
i
++
)
{
printf
(
"
\t
Element %i: "
,
i
);
print_nodes
(
root_node
->
subnodes
[
i
]);
}
break
;
case
BPLIST_INT
:
if
(
root_node
->
length
==
sizeof
(
uint8_t
))
{
printf
(
"Integer: %i
\n
"
,
root_node
->
intval8
);
}
else
if
(
root_node
->
length
==
sizeof
(
uint16_t
))
{
printf
(
"Integer: %i
\n
"
,
root_node
->
intval16
);
}
else
if
(
root_node
->
length
==
sizeof
(
uint32_t
))
{
printf
(
"Integer: %i
\n
"
,
root_node
->
intval32
);
}
break
;
case
BPLIST_STRING
:
printf
(
"String: "
);
fwrite
(
root_node
->
strval
,
sizeof
(
char
),
root_node
->
length
,
stdout
);
fflush
(
stdout
);
printf
(
"
\n
"
);
break
;
case
BPLIST_DATA
:
printf
(
"Data: "
);
char
*
data
=
g_base64_encode
(
root_node
->
strval
,
root_node
->
length
);
fwrite
(
format_string
(
data
,
60
,
0
),
sizeof
(
char
),
strlen
(
data
),
stdout
);
fflush
(
stdout
);
printf
(
"
\n
"
);
break
;
case
BPLIST_UNICODE
:
printf
(
"Unicode data, may appear crappy: "
);
fwrite
(
root_node
->
unicodeval
,
sizeof
(
wchar_t
),
root_node
->
length
,
stdout
);
fflush
(
stdout
);
printf
(
"
\n
"
);
break
;
case
BPLIST_TRUE
:
printf
(
"True.
\n
"
);
break
;
case
BPLIST_FALSE
:
printf
(
"False.
\n
"
);
break
;
case
BPLIST_REAL
:
case
BPLIST_DATE
:
printf
(
"Real(?): %f
\n
"
,
root_node
->
realval
);
break
;
default:
printf
(
"oops
\n
Type set to %x and length is %lu
\n
"
,
root_node
->
type
,
(
long
unsigned
int
)
root_node
->
length
);
break
;
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
stat
*
filestats
=
(
struct
stat
*
)
malloc
(
sizeof
(
struct
stat
));
...
...
@@ -117,15 +38,17 @@ int main(int argc, char *argv[])
fclose
(
bplist
);
printf
(
"or here?
\n
"
);
// bplist_entire contains our stuff
bplist_node
*
root_node
;
root_node
=
parse_nodes
(
bplist_entire
,
filestats
->
st_size
,
&
position
);
plist_t
root_node
=
NULL
;
bin_to_plist
(
bplist_entire
,
filestats
->
st_size
,
&
root_node
);
printf
(
"plutil debug mode
\n\n
"
);
printf
(
"file size %i
\n\n
"
,
(
int
)
filestats
->
st_size
);
if
(
!
root_node
)
{
printf
(
"Invalid binary plist (or some other error occurred.)
\n
"
);
return
0
;
}
print_nodes
(
root_node
);
char
*
plist_xml
=
NULL
;
plist_to_xml
(
root_node
,
&
plist_xml
);
printf
(
"%s
\n
"
,
plist_xml
);
return
0
;
}
...
...
src/plist.c
View file @
889cb32a
This diff is collapsed.
Click to expand it.
src/plist.h
View file @
889cb32a
...
...
@@ -46,38 +46,8 @@ void free_dictionary(char **dictionary);
/* Binary plist stuff */
enum
{
BPLIST_TRUE
=
0x08
,
BPLIST_FALSE
=
0x09
,
BPLIST_FILL
=
0x0F
,
/* will be used for length grabbing */
BPLIST_INT
=
0x10
,
BPLIST_REAL
=
0x20
,
BPLIST_DATE
=
0x33
,
BPLIST_DATA
=
0x40
,
BPLIST_STRING
=
0x50
,
BPLIST_UNICODE
=
0x60
,
BPLIST_UID
=
0x70
,
BPLIST_ARRAY
=
0xA0
,
BPLIST_SET
=
0xC0
,
BPLIST_DICT
=
0xD0
,
BPLIST_MASK
=
0xF0
};
typedef
struct
_bplist_node
{
struct
_bplist_node
*
next
,
**
subnodes
;
// subnodes is for arrays, dicts and (potentially) sets.
uint64_t
length
,
intval64
;
uint32_t
intval32
;
// length = subnodes
uint16_t
intval16
;
uint8_t
intval8
;
uint8_t
type
,
*
indexes
;
// indexes for array-types; essentially specify the order in which to access for key => value pairs
char
*
strval
;
double
realval
;
wchar_t
*
unicodeval
;
}
bplist_node
;
bplist_node
*
parse_nodes
(
const
char
*
bpbuffer
,
uint32_t
bplength
,
uint32_t
*
position
);
typedef
enum
{
typedef
enum
{
PLIST_BOOLEAN
,
PLIST_UINT8
,
PLIST_UINT16
,
...
...
@@ -100,15 +70,15 @@ typedef GNode *plist_t;
typedef
GNode
*
dict_t
;
typedef
GNode
*
array_t
;
void
plist_new_plist
(
plist_t
*
plist
);
void
plist_new_dict_in_plist
(
plist_t
plist
,
dict_t
*
dict
);
void
plist_new_array_in_plist
(
plist_t
plist
,
int
length
,
plist_type
type
,
void
**
values
,
array_t
*
array
);
void
plist_add_dict_element
(
dict_t
dict
,
char
*
key
,
plist_type
type
,
void
*
value
);
void
plist_new_plist
(
plist_t
*
plist
);
void
plist_new_dict_in_plist
(
plist_t
plist
,
dict_t
*
dict
);
void
plist_new_array_in_plist
(
plist_t
plist
,
int
length
,
plist_type
type
,
void
**
values
,
array_t
*
array
);
void
plist_add_dict_element
(
dict_t
dict
,
char
*
key
,
plist_type
type
,
void
*
value
);
void
plist_free
(
plist_t
plist
);
void
plist_to_xml
(
plist_t
plist
,
char
**
plist_xml
);
void
plist_to_bin
(
plist_t
plist
,
char
**
plist_bin
);
void
plist_to_xml
(
plist_t
plist
,
char
**
plist_xml
);
void
plist_to_bin
(
plist_t
plist
,
char
**
plist_bin
,
int
*
length
);
void
xml_to_plist
(
const
char
*
plist_xml
,
plist_t
*
plist
);
void
bin_to_plist
(
const
char
*
plist_bin
,
plist_t
*
plist
);
void
xml_to_plist
(
const
char
*
plist_xml
,
plist_t
*
plist
);
void
bin_to_plist
(
const
char
*
plist_bin
,
int
length
,
plist_t
*
plist
);
#endif
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