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
89050631
Commit
89050631
authored
Aug 19, 2008
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate iphone.c
parent
318f4bd5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
27 deletions
+36
-27
libiphone.h
include/libiphone/libiphone.h
+5
-4
iphone.c
src/iphone.c
+24
-16
iphone.h
src/iphone.h
+4
-4
usbmux.c
src/usbmux.c
+1
-1
usbmux.h
src/usbmux.h
+2
-2
No files found.
include/libiphone/libiphone.h
View file @
89050631
...
@@ -35,14 +35,15 @@ extern "C" {
...
@@ -35,14 +35,15 @@ extern "C" {
#define IPHONE_E_NO_DEVICE -2
#define IPHONE_E_NO_DEVICE -2
#define IPHONE_E_TIMEOUT -3
#define IPHONE_E_TIMEOUT -3
#define IPHONE_E_NOT_ENOUGH_DATA -4
#define IPHONE_E_NOT_ENOUGH_DATA -4
#define IPHONE_E_BAD_HEADER -5
//lockdownd specific error
//lockdownd specific error
#define IPHONE_E_INVALID_CONF -
5
#define IPHONE_E_INVALID_CONF -
6
#define IPHONE_E_PAIRING_FAILED -
6
#define IPHONE_E_PAIRING_FAILED -
7
#define IPHONE_E_SSL_ERROR -
7
#define IPHONE_E_SSL_ERROR -
8
//afc specific error
//afc specific error
#define IPHONE_E_NO_SUCH_FILE -
8
#define IPHONE_E_NO_SUCH_FILE -
9
struct
iphone_device_int
;
struct
iphone_device_int
;
typedef
struct
iphone_device_int
*
iphone_device_t
;
typedef
struct
iphone_device_int
*
iphone_device_t
;
...
...
src/iphone.c
View file @
89050631
...
@@ -34,10 +34,15 @@ extern int debug;
...
@@ -34,10 +34,15 @@ extern int debug;
* @return A structure with data on the first iPhone it finds. (Or NULL, on
* @return A structure with data on the first iPhone it finds. (Or NULL, on
* error)
* error)
*/
*/
iPhone_t
get_iPhone
()
{
int
iphone_get_device
(
iphone_device_t
*
device
){
iPhone
*
phone
=
(
iPhone
*
)
malloc
(
sizeof
(
iPhone
));
//check we can actually write in device
if
(
!
device
||
(
device
&&
*
device
))
return
IPHONE_E_INVALID_ARG
;
struct
usb_bus
*
bus
,
*
busses
;
struct
usb_bus
*
bus
,
*
busses
;
struct
usb_device
*
dev
;
struct
usb_device
*
dev
;
iphone_device_t
phone
=
(
iphone_device_t
)
malloc
(
sizeof
(
struct
iphone_device_int
));
usbmux_version_header
*
version
=
version_header
();
// Initialize the struct
// Initialize the struct
phone
->
device
=
NULL
;
phone
->
device
=
NULL
;
...
@@ -74,7 +79,7 @@ iPhone_t get_iPhone() {
...
@@ -74,7 +79,7 @@ iPhone_t get_iPhone() {
if
(
!
phone
->
device
||
!
phone
->
__device
)
{
if
(
!
phone
->
device
||
!
phone
->
__device
)
{
free_iPhone
(
phone
);
free_iPhone
(
phone
);
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): iPhone not found
\n
"
);
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): iPhone not found
\n
"
);
return
NULL
;
return
IPHONE_E_NO_DEVICE
;
}
}
// Send the version command to the phone
// Send the version command to the phone
...
@@ -99,7 +104,7 @@ iPhone_t get_iPhone() {
...
@@ -99,7 +104,7 @@ iPhone_t get_iPhone() {
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): Invalid version message -- header too short.
\n
"
);
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): Invalid version message -- header too short.
\n
"
);
if
(
debug
&&
bytes
<
0
)
fprintf
(
stderr
,
"get_iPhone(): libusb error message %d: %s (%s)
\n
"
,
if
(
debug
&&
bytes
<
0
)
fprintf
(
stderr
,
"get_iPhone(): libusb error message %d: %s (%s)
\n
"
,
bytes
,
usb_strerror
(),
strerror
(
-
bytes
));
bytes
,
usb_strerror
(),
strerror
(
-
bytes
));
return
NULL
;
return
IPHONE_E_NOT_ENOUGH_DATA
;
}
}
// Check for correct version
// Check for correct version
...
@@ -107,20 +112,21 @@ iPhone_t get_iPhone() {
...
@@ -107,20 +112,21 @@ iPhone_t get_iPhone() {
// We're all ready to roll.
// We're all ready to roll.
fprintf
(
stderr
,
"get_iPhone() success
\n
"
);
fprintf
(
stderr
,
"get_iPhone() success
\n
"
);
free
(
version
);
free
(
version
);
return
phone
;
*
device
=
phone
;
return
IPHONE_E_SUCCESS
;
}
else
{
}
else
{
// Bad header
// Bad header
free_iPhone
(
phone
);
free_iPhone
(
phone
);
free
(
version
);
free
(
version
);
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): Received a bad header/invalid version number."
);
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): Received a bad header/invalid version number."
);
return
NULL
;
return
IPHONE_E_BAD_HEADER
;
}
}
// If it got to this point it's gotta be bad
// If it got to this point it's gotta be bad
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): Unknown error.
\n
"
);
if
(
debug
)
fprintf
(
stderr
,
"get_iPhone(): Unknown error.
\n
"
);
free_iPhone
(
phone
);
free_iPhone
(
phone
);
free
(
version
);
free
(
version
);
return
NULL
;
return
IPHONE_E_NO_DEVICE
;
// if it got to this point it's gotta be bad
}
}
/** Cleans up an iPhone structure, then frees the structure itself.
/** Cleans up an iPhone structure, then frees the structure itself.
...
@@ -129,14 +135,14 @@ iPhone_t get_iPhone() {
...
@@ -129,14 +135,14 @@ iPhone_t get_iPhone() {
*
*
* @param phone A pointer to an iPhone structure.
* @param phone A pointer to an iPhone structure.
*/
*/
void
free_iPhone
(
iPhone_t
phone
)
{
void
iphone_free_device
(
iphone_device_t
device
)
{
if
(
phone
->
buffer
)
free
(
phon
e
->
buffer
);
if
(
device
->
buffer
)
free
(
devic
e
->
buffer
);
if
(
phon
e
->
device
)
{
if
(
devic
e
->
device
)
{
usb_release_interface
(
phon
e
->
device
,
1
);
usb_release_interface
(
devic
e
->
device
,
1
);
usb_reset
(
phon
e
->
device
);
usb_reset
(
devic
e
->
device
);
usb_close
(
phon
e
->
device
);
usb_close
(
devic
e
->
device
);
}
}
free
(
phon
e
);
free
(
devic
e
);
}
}
/** Sends data to the phone
/** Sends data to the phone
...
@@ -147,7 +153,8 @@ void free_iPhone(iPhone_t phone) {
...
@@ -147,7 +153,8 @@ void free_iPhone(iPhone_t phone) {
* @param datalen The length of the data
* @param datalen The length of the data
* @return The number of bytes sent, or -1 on error or something.
* @return The number of bytes sent, or -1 on error or something.
*/
*/
int
send_to_phone
(
iPhone
*
phone
,
char
*
data
,
int
datalen
)
{
int
send_to_phone
(
iphone_device_t
phone
,
char
*
data
,
int
datalen
)
{
if
(
!
phone
)
return
-
1
;
int
bytes
=
0
;
int
bytes
=
0
;
if
(
!
phone
)
return
-
1
;
if
(
!
phone
)
return
-
1
;
...
@@ -173,7 +180,8 @@ int send_to_phone(iPhone *phone, char *data, int datalen) {
...
@@ -173,7 +180,8 @@ int send_to_phone(iPhone *phone, char *data, int datalen) {
*
*
* @return How many bytes were read in, or -1 on error.
* @return How many bytes were read in, or -1 on error.
*/
*/
int
recv_from_phone
(
iPhone
*
phone
,
char
*
data
,
int
datalen
)
{
int
recv_from_phone
(
iphone_device_t
phone
,
char
*
data
,
int
datalen
)
{
if
(
!
phone
)
return
-
1
;
int
bytes
=
0
;
int
bytes
=
0
;
if
(
!
phone
)
return
-
1
;
if
(
!
phone
)
return
-
1
;
...
...
src/iphone.h
View file @
89050631
...
@@ -33,13 +33,13 @@
...
@@ -33,13 +33,13 @@
#define BULKIN 0x85
#define BULKIN 0x85
#define BULKOUT 0x04
#define BULKOUT 0x04
typedef
struct
iPhone_s
{
struct
iphone_device_int
{
char
*
buffer
;
char
*
buffer
;
struct
usb_dev_handle
*
device
;
struct
usb_dev_handle
*
device
;
struct
usb_device
*
__device
;
struct
usb_device
*
__device
;
}
iPhone
;
};
// Function definitions
// Function definitions
int
send_to_phone
(
i
Phone
*
phone
,
char
*
data
,
int
datalen
);
int
send_to_phone
(
i
phone_device_t
phone
,
char
*
data
,
int
datalen
);
int
recv_from_phone
(
i
Phone
*
phone
,
char
*
data
,
int
datalen
);
int
recv_from_phone
(
i
phone_device_t
phone
,
char
*
data
,
int
datalen
);
#endif
#endif
src/usbmux.c
View file @
89050631
...
@@ -116,7 +116,7 @@ void add_connection(usbmux_connection *connection) {
...
@@ -116,7 +116,7 @@ void add_connection(usbmux_connection *connection) {
*
*
* @return A mux TCP header for the connection which is used for tracking and data transfer.
* @return A mux TCP header for the connection which is used for tracking and data transfer.
*/
*/
usbmux_connection
*
mux_connect
(
i
Phone
*
phone
,
uint16
s_port
,
uint16
d_port
)
{
usbmux_connection
*
mux_connect
(
i
phone_device_t
phone
,
uint16
s_port
,
uint16
d_port
)
{
if
(
!
phone
||
!
s_port
||
!
d_port
)
return
NULL
;
if
(
!
phone
||
!
s_port
||
!
d_port
)
return
NULL
;
int
bytes
=
0
;
int
bytes
=
0
;
// Initialize connection stuff
// Initialize connection stuff
...
...
src/usbmux.h
View file @
89050631
...
@@ -45,7 +45,7 @@ typedef struct {
...
@@ -45,7 +45,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
usbmux_tcp_header
*
header
;
usbmux_tcp_header
*
header
;
i
Phone
*
phone
;
i
phone_device_t
phone
;
char
*
recv_buffer
;
char
*
recv_buffer
;
int
r_len
;
int
r_len
;
}
usbmux_connection
;
}
usbmux_connection
;
...
@@ -58,7 +58,7 @@ typedef struct {
...
@@ -58,7 +58,7 @@ typedef struct {
usbmux_version_header
*
version_header
();
usbmux_version_header
*
version_header
();
usbmux_connection
*
mux_connect
(
i
Phone
*
phone
,
uint16
s_port
,
uint16
d_port
);
usbmux_connection
*
mux_connect
(
i
phone_device_t
phone
,
uint16
s_port
,
uint16
d_port
);
void
mux_close_connection
(
usbmux_connection
*
connection
);
void
mux_close_connection
(
usbmux_connection
*
connection
);
int
mux_send
(
usbmux_connection
*
connection
,
const
char
*
data
,
uint32
datalen
);
int
mux_send
(
usbmux_connection
*
connection
,
const
char
*
data
,
uint32
datalen
);
int
mux_recv
(
usbmux_connection
*
connection
,
char
*
data
,
uint32
datalen
);
int
mux_recv
(
usbmux_connection
*
connection
,
char
*
data
,
uint32
datalen
);
...
...
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