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
6ac4ceb4
Commit
6ac4ceb4
authored
Aug 25, 2008
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate main.c
parent
c042f7ca
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
64 deletions
+48
-64
libiphone.h
include/libiphone/libiphone.h
+11
-0
AFC.c
src/AFC.c
+1
-1
AFC.h
src/AFC.h
+1
-10
ifuse.c
src/ifuse.c
+2
-18
main.c
src/main.c
+33
-35
No files found.
include/libiphone/libiphone.h
View file @
6ac4ceb4
...
...
@@ -46,6 +46,17 @@ extern "C" {
//afc specific error
#define IPHONE_E_NO_SUCH_FILE -10
enum
{
AFC_FILE_READ
=
0x00000002
,
// seems to be able to read and write files
AFC_FILE_WRITE
=
0x00000003
,
// writes and creates a file, blanks it out, etc.
AFC_FILE_RW
=
0x00000005
,
// seems to do the same as 2. Might even create the file.
AFC_FILE_OP4
=
0x00000004
,
// no idea -- appears to be "write" -- clears file beforehand like 3
AFC_FILE_OP6
=
0x00000006
,
// no idea yet -- appears to be the same as 5.
AFC_FILE_OP1
=
0x00000001
,
// no idea juuust yet... probably read.
AFC_FILE_OP0
=
0x00000000
,
AFC_FILE_OP10
=
0x0000000a
};
struct
iphone_device_int
;
typedef
struct
iphone_device_int
*
iphone_device_t
;
...
...
src/AFC.c
View file @
6ac4ceb4
...
...
@@ -596,7 +596,7 @@ int iphone_afc_get_file_attr ( iphone_afc_client_t client, const char *filename,
if
(
!
file
){
ret
=
IPHONE_E_NO_SUCH_FILE
;
}
else
{
stbuf
->
st_mode
=
file
->
type
|
0644
;
// but we don't want anything on the iPhone executable, like, ever
stbuf
->
st_mode
=
file
->
type
|
(
S_ISDIR
(
file
->
type
)
?
0755
:
0644
);
stbuf
->
st_size
=
file
->
size
;
stbuf
->
st_blksize
=
2048
;
// FIXME: Is this the actual block size used on the iPhone?
stbuf
->
st_blocks
=
file
->
blocks
;
...
...
src/AFC.h
View file @
6ac4ceb4
...
...
@@ -52,16 +52,7 @@ struct iphone_afc_file_int {
uint32
filehandle
,
blocks
,
size
,
type
;
};
enum
{
AFC_FILE_READ
=
0x00000002
,
// seems to be able to read and write files
AFC_FILE_WRITE
=
0x00000003
,
// writes and creates a file, blanks it out, etc.
AFC_FILE_RW
=
0x00000005
,
// seems to do the same as 2. Might even create the file.
AFC_FILE_OP4
=
0x00000004
,
// no idea -- appears to be "write" -- clears file beforehand like 3
AFC_FILE_OP6
=
0x00000006
,
// no idea yet -- appears to be the same as 5.
AFC_FILE_OP1
=
0x00000001
,
// no idea juuust yet... probably read.
AFC_FILE_OP0
=
0x00000000
,
AFC_FILE_OP10
=
0x0000000a
};
enum
{
AFC_ERROR
=
0x00000001
,
...
...
src/ifuse.c
View file @
6ac4ceb4
...
...
@@ -42,8 +42,8 @@
GHashTable
*
file_handles
;
int
fh_index
=
0
;
i
Phone
*
phone
=
NULL
;
lockdownd_client
*
control
=
NULL
;
i
phone_device_t
phone
=
NULL
;
iphone_lckd_client_t
control
=
NULL
;
int
debug
=
0
;
...
...
@@ -52,22 +52,6 @@ static int ifuse_getattr(const char *path, struct stat *stbuf) {
AFCFile
*
file
;
AFClient
*
afc
=
fuse_get_context
()
->
private_data
;
memset
(
stbuf
,
0
,
sizeof
(
struct
stat
));
file
=
afc_get_file_info
(
afc
,
path
);
if
(
!
file
){
res
=
-
ENOENT
;
}
else
{
stbuf
->
st_mode
=
file
->
type
|
(
S_ISDIR
(
file
->
type
)
?
0755
:
0644
);
stbuf
->
st_size
=
file
->
size
;
stbuf
->
st_blksize
=
2048
;
// FIXME: Is this the actual block size used on the iPhone?
stbuf
->
st_blocks
=
file
->
blocks
;
stbuf
->
st_uid
=
getuid
();
stbuf
->
st_gid
=
getgid
();
afc_close_file
(
afc
,
file
);
free
(
file
);
}
return
res
;
}
...
...
src/main.c
View file @
6ac4ceb4
...
...
@@ -29,17 +29,15 @@
#include <libxml/parser.h>
#include <libxml/tree.h>
#include "plist.h"
#include "lockdown.h"
#include "AFC.h"
#include "userpref.h"
#include <libiphone/libiphone.h>
int
debug
=
1
;
int
main
(
int
argc
,
char
*
argv
[])
{
int
bytes
=
0
,
port
=
0
,
i
=
0
;
lockdownd_client
*
control
=
NULL
;
i
Phone
*
phone
=
get_iPhone
()
;
iphone_lckd_client_t
control
=
NULL
;
i
phone_device_t
phone
=
NULL
;
if
(
argc
>
1
&&
!
strcasecmp
(
argv
[
1
],
"--debug"
)){
debug
=
1
;
...
...
@@ -47,13 +45,13 @@ int main(int argc, char *argv[]) {
debug
=
0
;
}
if
(
!
phone
)
{
if
(
IPHONE_E_SUCCESS
!=
iphone_get_device
(
&
phone
)
)
{
printf
(
"No iPhone found, is it plugged in?
\n
"
);
return
-
1
;
}
if
(
!
lockdownd_ini
t
(
phone
,
&
control
)){
free_iPhon
e
(
phone
);
if
(
IPHONE_E_SUCCESS
!=
iphone_lckd_new_clien
t
(
phone
,
&
control
)){
iphone_free_devic
e
(
phone
);
return
-
1
;
}
...
...
@@ -63,21 +61,22 @@ int main(int argc, char *argv[]) {
free
(
uid
);
}
port
=
lockdown
d_start_service
(
control
,
"com.apple.afc"
);
port
=
iphone_lck
d_start_service
(
control
,
"com.apple.afc"
);
if
(
port
)
{
AFClient
*
afc
=
afc_connect
(
phone
,
3432
,
port
);
iphone_afc_client_t
afc
=
NULL
;
iphone_afc_new_client
(
phone
,
3432
,
port
,
&
afc
);
if
(
afc
)
{
char
**
dirs
;
dirs
=
afc_get_dir_list
(
afc
,
"/eafaedf"
);
if
(
!
dirs
)
dirs
=
afc_get_dir_list
(
afc
,
"/"
);
dirs
=
iphone_
afc_get_dir_list
(
afc
,
"/eafaedf"
);
if
(
!
dirs
)
dirs
=
iphone_
afc_get_dir_list
(
afc
,
"/"
);
printf
(
"Directory time.
\n
"
);
for
(
i
=
0
;
dirs
[
i
];
i
++
)
{
printf
(
"/%s
\n
"
,
dirs
[
i
]);
}
g_strfreev
(
dirs
);
dirs
=
afc_get_devinfo
(
afc
);
dirs
=
iphone_
afc_get_devinfo
(
afc
);
if
(
dirs
)
{
for
(
i
=
0
;
dirs
[
i
];
i
+=
2
)
{
printf
(
"%s: %s
\n
"
,
dirs
[
i
],
dirs
[
i
+
1
]);
...
...
@@ -85,64 +84,63 @@ int main(int argc, char *argv[]) {
}
g_strfreev
(
dirs
);
AFCFile
*
my_file
=
afc_open_file
(
afc
,
"/iTunesOnTheGoPlaylist.plist"
,
AFC_FILE_READ
);
if
(
my_file
)
{
printf
(
"A file size: %i
\n
"
,
my_file
->
size
);
char
*
file_data
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
my_file
->
size
);
bytes
=
afc_read_file
(
afc
,
my_file
,
file_data
,
my_file
->
size
);
iphone_afc_file_t
my_file
=
NULL
;
struct
stat
stbuf
;
iphone_afc_get_file_attr
(
afc
,
"/iTunesOnTheGoPlaylist.plist"
,
&
stbuf
);
if
(
IPHONE_E_SUCCESS
==
iphone_afc_open_file
(
afc
,
"/iTunesOnTheGoPlaylist.plist"
,
AFC_FILE_READ
,
&
my_file
)
&&
my_file
)
{
printf
(
"A file size: %i
\n
"
,
stbuf
.
st_size
);
char
*
file_data
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
stbuf
.
st_size
);
bytes
=
iphone_afc_read_file
(
afc
,
my_file
,
file_data
,
stbuf
.
st_size
);
if
(
bytes
>=
0
)
{
printf
(
"The file's data:
\n
"
);
fwrite
(
file_data
,
1
,
bytes
,
stdout
);
}
printf
(
"
\n
Closing my file.
\n
"
);
afc_close_file
(
afc
,
my_file
);
free
(
my_file
);
iphone_afc_close_file
(
afc
,
my_file
);
free
(
file_data
);
}
else
printf
(
"couldn't open a file
\n
"
);
my_file
=
afc_open_file
(
afc
,
"/readme.libiphone.fx"
,
AFC_FILE_WRITE
);
iphone_afc_open_file
(
afc
,
"/readme.libiphone.fx"
,
AFC_FILE_WRITE
,
&
my_file
);
if
(
my_file
)
{
char
*
outdatafile
=
strdup
(
"this is a bitchin text file
\n
"
);
bytes
=
afc_write_file
(
afc
,
my_file
,
outdatafile
,
strlen
(
outdatafile
));
bytes
=
iphone_
afc_write_file
(
afc
,
my_file
,
outdatafile
,
strlen
(
outdatafile
));
free
(
outdatafile
);
if
(
bytes
>
0
)
printf
(
"Wrote a surprise. ;)
\n
"
);
else
printf
(
"I wanted to write a surprise, but... :(
\n
"
);
afc_close_file
(
afc
,
my_file
);
free
(
my_file
);
iphone_afc_close_file
(
afc
,
my_file
);
}
printf
(
"Deleting a file...
\n
"
);
bytes
=
afc_delete_file
(
afc
,
"/delme"
);
bytes
=
iphone_
afc_delete_file
(
afc
,
"/delme"
);
if
(
bytes
)
printf
(
"Success.
\n
"
);
else
printf
(
"Failure. (expected unless you have a /delme file on your phone)
\n
"
);
printf
(
"Renaming a file...
\n
"
);
bytes
=
afc_rename_file
(
afc
,
"/renme"
,
"/renme2"
);
bytes
=
iphone_
afc_rename_file
(
afc
,
"/renme"
,
"/renme2"
);
if
(
bytes
>
0
)
printf
(
"Success.
\n
"
);
else
printf
(
"Failure. (expected unless you have a /renme file on your phone)
\n
"
);
printf
(
"Seek & read
\n
"
);
my_file
=
afc_open_file
(
afc
,
"/readme.libiphone.fx"
,
AFC_FILE_READ
);
bytes
=
afc_seek_file
(
afc
,
my_file
,
5
);
iphone_afc_open_file
(
afc
,
"/readme.libiphone.fx"
,
AFC_FILE_READ
,
&
my_file
);
bytes
=
iphone_
afc_seek_file
(
afc
,
my_file
,
5
);
if
(
bytes
)
printf
(
"WARN: SEEK DID NOT WORK
\n
"
);
char
*
threeletterword
=
(
char
*
)
malloc
(
sizeof
(
char
)
*
5
);
bytes
=
afc_read_file
(
afc
,
my_file
,
threeletterword
,
3
);
bytes
=
iphone_
afc_read_file
(
afc
,
my_file
,
threeletterword
,
3
);
threeletterword
[
3
]
=
'\0'
;
if
(
bytes
>
0
)
printf
(
"Result: %s
\n
"
,
threeletterword
);
else
printf
(
"Couldn't read!
\n
"
);
free
(
threeletterword
);
afc_close_file
(
afc
,
my_file
);
free
(
my_file
);
iphone_afc_close_file
(
afc
,
my_file
);
}
afc_disconnec
t
(
afc
);
iphone_afc_free_clien
t
(
afc
);
}
else
{
printf
(
"Start service failure.
\n
"
);
}
printf
(
"All done.
\n
"
);
lockdownd_close
(
control
);
free_iPhon
e
(
phone
);
iphone_lckd_free_client
(
control
);
iphone_free_devic
e
(
phone
);
return
0
;
}
...
...
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