Skip to content

Commit

Permalink
make openssl as optional
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed Mar 9, 2021
1 parent c500ca2 commit 9a6891d
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9 deletions.
1 change: 1 addition & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Ref: https://packaging.python.org/guides/publishing-package-distribution-release


## References
- https://www.theiphonewiki.com/wiki/Usbmux
- C implementation <https://github.com/libimobiledevice>
- Python implement of libimobiledevice: <https://github.com/iOSForensics/pymobiledevice>
- Apple Device Images: <https://github.com/iGhibli/iOS-DeviceSupport>
Expand Down
36 changes: 36 additions & 0 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### Layer 1: **usbmuxd**

```
# Client send to unix:/var/run/usbmuxd
00000000: A9 01 00 00 01 00 00 00 08 00 00 00 01 00 00 00 ................
00000010: ...body...
- 0x00-0x04 (A9 01 00 00): length
- 0x04-0x08 (01 00 00 00): protocol version (always 1)
- 0x08-0x0B (08 00 00 00): message type 8(Plist)
- 0x0B-0x10 (01 00 00 00): tag, the received message must contains the same tag
# Usbmuxd replys with
00000000: 6C 03 00 00 01 00 00 00 08 00 00 00 01 00 00 00 l...............
00000010: ...body...
- 0x00-0x04 (6C 03 00 00): length
- 0x04-0x08 (01 00 00 00): protocol version
- 0x08-0x0B (08 00 00 00): message type 8(Plist)
- 0x0B-0x10 (01 00 00 00): tag, same as request
```

Example of python code

```python
import struct
import socket

socket.socket(AF_INET)
```

### Layer 2: **Plist Message**
tbd

### Layer 3: **DTX Message**
tbd
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@

## 安装

Python 3.7+
Python 3.6+

```bash
pip3 install -U "tidevice[openssl]" # Recommend
```

如果上面的命令提示安装失败,就试试下面的命令。(不过这种方法安装,配对功能就没有了,因为没有办法进行签名)

```bash
pip3 install -U tidevice
Expand Down
8 changes: 7 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ Command line tool to communicate with iOS device, support the following function
Support platform: Mac, Linux, Windows

## Install
Python 3.7+
Python 3.6+

```bash
pip3 install -U "tidevice[openssl]" # Recommend
```

The extra *openssl*, contains device pair support. If can install it, try

```bash
pip3 install -U tidevice
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@ requests
colored
packaging

# pyOpenSSL requires cryptography which only have cp36.whl on windows
pyOpenSSL; sys_platform != 'win32' #>=20.0.1
pyasn1; sys_platform != 'win32' #>=0.4.8

tornado
simple_tornado
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ classifier =
packages =
tidevice

[extras]
# pyOpenSSL requires cryptography which only have cp36.whl on windows
openssl =
pyOpenSSL
pyasn1

[entry_points]
# https://docs.openstack.org/pbr/3.1.1/#entry-points
console_scripts =
Expand Down
6 changes: 3 additions & 3 deletions tidevice/_safe_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ def prepare(self):
def is_secure(self):
return isinstance(self._sock, ssl.SSLSocket)

def send_packet(self, payload: dict, reqtype: int = 8):
def send_packet(self, payload: dict, message_type: int = 8):
"""
Args:
payload: required
# The following args only used in the first request
reqtype: request type, always 8
message_type: 8 (Plist)
tag: int
"""
#if self.is_secure():
Expand All @@ -122,7 +122,7 @@ def send_packet(self, payload: dict, reqtype: int = 8):
if self._first: # first package
length = 16 + len(body_data)
header = struct.pack(
"IIII", length, 1, reqtype,
"IIII", length, 1, message_type,
self._tag) # version: 1, request: 8(?), tag: 1(?)
else:
header = struct.pack(">I", len(body_data))
Expand Down

0 comments on commit 9a6891d

Please sign in to comment.