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
36eff97c
Commit
36eff97c
authored
Dec 01, 2008
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish new plist API migration.
parent
505c9758
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
93 deletions
+90
-93
lockdown.c
src/lockdown.c
+90
-93
No files found.
src/lockdown.c
View file @
36eff97c
...
@@ -662,113 +662,110 @@ iphone_error_t lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_
...
@@ -662,113 +662,110 @@ iphone_error_t lockdownd_gen_pair_cert(char *public_key_b64, char **device_cert_
*/
*/
iphone_error_t
lockdownd_start_SSL_session
(
iphone_lckd_client_t
control
,
const
char
*
HostID
)
iphone_error_t
lockdownd_start_SSL_session
(
iphone_lckd_client_t
control
,
const
char
*
HostID
)
{
{
xmlDocPtr
plist
=
new_plist
()
;
plist_t
plist
=
NULL
;
xmlNode
*
dict
=
add_child_to_plist
(
plist
,
"dict"
,
"
\n
"
,
NULL
,
0
)
;
dict_t
dict
=
NULL
;
xmlNode
*
key
;
char
*
XML_content
=
NULL
;
char
*
what2send
=
NULL
,
**
dictionary
=
NULL
;
uint32_t
length
=
0
,
bytes
=
0
,
return_me
=
0
;
uint32_t
len
=
0
,
bytes
=
0
,
return_me
=
0
,
i
=
0
;
iphone_error_t
ret
=
IPHONE_E_UNKNOWN_ERROR
;
iphone_error_t
ret
=
IPHONE_E_UNKNOWN_ERROR
;
// end variables
key
=
add_key_str_dict_element
(
plist
,
dict
,
"HostID"
,
HostID
,
1
);
/* Setup DevicePublicKey request plist */
if
(
!
key
)
{
plist_new_plist
(
&
plist
);
log_debug_msg
(
"Couldn't add a key.
\n
"
);
plist_new_dict_in_plist
(
plist
,
&
dict
);
xmlFreeDoc
(
plist
);
plist_add_dict_element
(
dict
,
"HostID"
,
PLIST_STRING
,
(
void
*
)
HostID
);
return
IPHONE_E_DICT_ERROR
;
plist_add_dict_element
(
dict
,
"Request"
,
PLIST_STRING
,
(
void
*
)
"StartSession"
);
}
plist_to_xml
(
plist
,
&
XML_content
,
&
length
);
key
=
add_key_str_dict_element
(
plist
,
dict
,
"Request"
,
"StartSession"
,
1
);
log_debug_msg
(
"Send msg :
\n
size : %i
\n
xml : %s"
,
length
,
XML_content
);
if
(
!
key
)
{
log_debug_msg
(
"Couldn't add a key.
\n
"
);
xmlFreeDoc
(
plist
);
return
IPHONE_E_DICT_ERROR
;
}
xmlDocDumpMemory
(
plist
,
(
xmlChar
**
)
&
what2send
,
&
len
);
ret
=
iphone_lckd_send
(
control
,
XML_content
,
length
,
&
bytes
);
ret
=
iphone_lckd_send
(
control
,
what2send
,
len
,
&
bytes
);
xmlFree
(
what2send
);
xmlFree
(
XML_content
);
xmlFreeDoc
(
plist
);
XML_content
=
NULL
;
plist_free
(
plist
);
plist
=
NULL
;
if
(
ret
!=
IPHONE_E_SUCCESS
)
if
(
ret
!=
IPHONE_E_SUCCESS
)
return
ret
;
return
ret
;
if
(
bytes
>
0
)
{
if
(
bytes
>
0
)
{
ret
=
iphone_lckd_recv
(
control
,
&
what2send
,
&
len
);
ret
=
iphone_lckd_recv
(
control
,
&
XML_content
,
&
bytes
);
plist
=
xmlReadMemory
(
what2send
,
len
,
NULL
,
NULL
,
0
);
log_debug_msg
(
"Receive msg :
\n
size : %i
\n
xml : %s"
,
bytes
,
XML_content
);
dict
=
xmlDocGetRootElement
(
plist
);
xml_to_plist
(
XML_content
,
bytes
,
&
plist
);
if
(
!
dict
)
if
(
!
plist
)
return
IPHONE_E_DICT_ERROR
;
return
IPHONE_E_PLIST_ERROR
;
for
(
dict
=
dict
->
children
;
dict
;
dict
=
dict
->
next
)
{
if
(
!
xmlStrcmp
(
dict
->
name
,
"dict"
))
plist_t
query_node
=
find_query_node
(
plist
,
"Request"
,
"StartSession"
);
break
;
plist_t
result_key_node
=
g_node_next_sibling
(
query_node
);
}
plist_t
result_value_node
=
g_node_next_sibling
(
result_key_node
);
dictionary
=
read_dict_element_strings
(
dict
);
xmlFreeDoc
(
plist
);
plist_type
result_key_type
;
free
(
what2send
);
plist_type
result_value_type
;
for
(
i
=
0
;
dictionary
[
i
];
i
+=
2
)
{
char
*
result_key
=
NULL
;
if
(
!
strcmp
(
dictionary
[
i
],
"Result"
)
&&
!
strcmp
(
dictionary
[
i
+
1
],
"Success"
))
{
char
*
result_value
=
NULL
;
// Set up GnuTLS...
//gnutls_anon_client_credentials_t anoncred;
get_type_and_value
(
result_key_node
,
&
result_key_type
,
(
void
*
)
(
&
result_key
));
gnutls_certificate_credentials_t
xcred
;
get_type_and_value
(
result_value_node
,
&
result_value_type
,
(
void
*
)
(
&
result_value
));
log_debug_msg
(
"We started the session OK, now trying GnuTLS
\n
"
);
xmlFree
(
XML_content
);
errno
=
0
;
XML_content
=
NULL
;
gnutls_global_init
();
plist_free
(
plist
);
//gnutls_anon_allocate_client_credentials(&anoncred);
plist
=
NULL
;
gnutls_certificate_allocate_credentials
(
&
xcred
);
gnutls_certificate_set_x509_trust_file
(
xcred
,
"hostcert.pem"
,
GNUTLS_X509_FMT_PEM
);
if
(
result_key_type
==
PLIST_KEY
&&
gnutls_init
(
control
->
ssl_session
,
GNUTLS_CLIENT
);
result_value_type
==
PLIST_STRING
&&
!
strcmp
(
result_key
,
"Result"
)
&&
!
strcmp
(
result_value
,
"Success"
))
{
{
// Set up GnuTLS...
int
protocol_priority
[
16
]
=
{
GNUTLS_SSL3
,
0
};
//gnutls_anon_client_credentials_t anoncred;
int
kx_priority
[
16
]
=
{
GNUTLS_KX_ANON_DH
,
GNUTLS_KX_RSA
,
0
};
gnutls_certificate_credentials_t
xcred
;
int
cipher_priority
[
16
]
=
{
GNUTLS_CIPHER_AES_128_CBC
,
GNUTLS_CIPHER_AES_256_CBC
,
0
};
int
mac_priority
[
16
]
=
{
GNUTLS_MAC_SHA1
,
GNUTLS_MAC_MD5
,
0
};
log_debug_msg
(
"We started the session OK, now trying GnuTLS
\n
"
);
int
comp_priority
[
16
]
=
{
GNUTLS_COMP_NULL
,
0
};
errno
=
0
;
gnutls_global_init
();
gnutls_cipher_set_priority
(
*
control
->
ssl_session
,
cipher_priority
);
//gnutls_anon_allocate_client_credentials(&anoncred);
gnutls_compression_set_priority
(
*
control
->
ssl_session
,
comp_priority
);
gnutls_certificate_allocate_credentials
(
&
xcred
);
gnutls_kx_set_priority
(
*
control
->
ssl_session
,
kx_priority
);
gnutls_certificate_set_x509_trust_file
(
xcred
,
"hostcert.pem"
,
GNUTLS_X509_FMT_PEM
);
gnutls_protocol_set_priority
(
*
control
->
ssl_session
,
protocol_priority
);
gnutls_init
(
control
->
ssl_session
,
GNUTLS_CLIENT
);
gnutls_mac_set_priority
(
*
control
->
ssl_session
,
mac_priority
);
{
int
protocol_priority
[
16
]
=
{
GNUTLS_SSL3
,
0
};
}
int
kx_priority
[
16
]
=
{
GNUTLS_KX_ANON_DH
,
GNUTLS_KX_RSA
,
0
};
gnutls_credentials_set
(
*
control
->
ssl_session
,
GNUTLS_CRD_CERTIFICATE
,
xcred
);
// this part is killing me.
int
cipher_priority
[
16
]
=
{
GNUTLS_CIPHER_AES_128_CBC
,
GNUTLS_CIPHER_AES_256_CBC
,
0
};
int
mac_priority
[
16
]
=
{
GNUTLS_MAC_SHA1
,
GNUTLS_MAC_MD5
,
0
};
log_debug_msg
(
"GnuTLS step 1...
\n
"
);
int
comp_priority
[
16
]
=
{
GNUTLS_COMP_NULL
,
0
};
gnutls_transport_set_ptr
(
*
control
->
ssl_session
,
(
gnutls_transport_ptr_t
)
control
);
log_debug_msg
(
"GnuTLS step 2...
\n
"
);
gnutls_cipher_set_priority
(
*
control
->
ssl_session
,
cipher_priority
);
gnutls_transport_set_push_function
(
*
control
->
ssl_session
,
(
gnutls_push_func
)
&
lockdownd_secuwrite
);
gnutls_compression_set_priority
(
*
control
->
ssl_session
,
comp_priority
);
log_debug_msg
(
"GnuTLS step 3...
\n
"
);
gnutls_kx_set_priority
(
*
control
->
ssl_session
,
kx_priority
);
gnutls_transport_set_pull_function
(
*
control
->
ssl_session
,
(
gnutls_pull_func
)
&
lockdownd_securead
);
gnutls_protocol_set_priority
(
*
control
->
ssl_session
,
protocol_priority
);
log_debug_msg
(
"GnuTLS step 4 -- now handshaking...
\n
"
);
gnutls_mac_set_priority
(
*
control
->
ssl_session
,
mac_priority
);
if
(
errno
)
}
log_debug_msg
(
"WARN: errno says %s before handshake!
\n
"
,
strerror
(
errno
));
gnutls_credentials_set
(
*
control
->
ssl_session
,
GNUTLS_CRD_CERTIFICATE
,
xcred
);
// this part is killing me.
return_me
=
gnutls_handshake
(
*
control
->
ssl_session
);
log_debug_msg
(
"GnuTLS handshake done...
\n
"
);
log_debug_msg
(
"GnuTLS step 1...
\n
"
);
gnutls_transport_set_ptr
(
*
control
->
ssl_session
,
(
gnutls_transport_ptr_t
)
control
);
free_dictionary
(
dictionary
);
log_debug_msg
(
"GnuTLS step 2...
\n
"
);
gnutls_transport_set_push_function
(
*
control
->
ssl_session
,
(
gnutls_push_func
)
&
lockdownd_secuwrite
);
if
(
return_me
!=
GNUTLS_E_SUCCESS
)
{
log_debug_msg
(
"GnuTLS step 3...
\n
"
);
log_debug_msg
(
"GnuTLS reported something wrong.
\n
"
);
gnutls_transport_set_pull_function
(
*
control
->
ssl_session
,
(
gnutls_pull_func
)
&
lockdownd_securead
);
gnutls_perror
(
return_me
);
log_debug_msg
(
"GnuTLS step 4 -- now handshaking...
\n
"
);
log_debug_msg
(
"oh.. errno says %s
\n
"
,
strerror
(
errno
));
return
IPHONE_E_SSL_ERROR
;
if
(
errno
)
}
else
{
log_debug_msg
(
"WARN: errno says %s before handshake!
\n
"
,
strerror
(
errno
));
control
->
in_SSL
=
1
;
return_me
=
gnutls_handshake
(
*
control
->
ssl_session
);
return
IPHONE_E_SUCCESS
;
log_debug_msg
(
"GnuTLS handshake done...
\n
"
);
}
if
(
return_me
!=
GNUTLS_E_SUCCESS
)
{
log_debug_msg
(
"GnuTLS reported something wrong.
\n
"
);
gnutls_perror
(
return_me
);
log_debug_msg
(
"oh.. errno says %s
\n
"
,
strerror
(
errno
));
return
IPHONE_E_SSL_ERROR
;
}
else
{
control
->
in_SSL
=
1
;
return
IPHONE_E_SUCCESS
;
}
}
}
}
log_debug_msg
(
"Apparently failed negotiating with lockdownd.
\n
"
);
log_debug_msg
(
"Apparently failed negotiating with lockdownd.
\n
"
);
log_debug_msg
(
"Responding dictionary:
\n
"
);
log_debug_msg
(
"Responding dictionary:
\n
"
);
for
(
i
=
0
;
dictionary
[
i
];
i
+=
2
)
{
log_debug_msg
(
"
\t
%s: %s
\n
"
,
dictionary
[
i
],
dictionary
[
i
+
1
]);
}
free_dictionary
(
dictionary
);
return
IPHONE_E_SSL_ERROR
;
return
IPHONE_E_SSL_ERROR
;
}
else
{
}
else
{
log_debug_msg
(
"Didn't get enough bytes.
\n
"
);
log_debug_msg
(
"Didn't get enough bytes.
\n
"
);
...
...
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