Go Module
版本: https://github.com/electricbubble/gidevice
CLI
版本: https://github.com/electricbubble/gidevice-cli
使用 Golang
实现的的与 iOS 设备 进行通信的跨平台工具库
所有功能无需越狱
macOS
可直接使用
Windows
需要先安装iTunes
或者 usbmuxd
Linux
或其他需先安装 usbmuxd
已实现功能:
CLI
版本使用示例$ gidevice list
$ gidevice mount -l
# gidevice mount -l -u=39xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7
$ gidevice mount -d=/path/.../DeviceSupport/14.4/
$ gidevice mount /path/.../DeviceSupport/14.4/DeveloperDiskImage.dmg /path/.../DeviceSupport/14.4/DeveloperDiskImage.dmg.signature
# Default port local=8100 remote=8100
$ gidevice forward
$ gidevice forward -l=9100 -r=9100 -u=39xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx7
Go Module
版本使用示例package main
import (
giDevice "github.com/electricbubble/gidevice"
"log"
)
func main() {
usbmux, err := giDevice.NewUsbmux()
if err != nil {
log.Fatalln(err)
}
devices, err := usbmux.Devices()
if err != nil {
log.Fatal(err)
}
for _, dev := range devices {
log.Println(dev.Properties().SerialNumber, dev.Properties().ProductID, dev.Properties().DeviceID)
}
}
package main
import (
"encoding/base64"
giDevice "github.com/electricbubble/gidevice"
"log"
)
func main() {
usbmux, err := giDevice.NewUsbmux()
if err != nil {
log.Fatal(err)
}
devices, err := usbmux.Devices()
if err != nil {
log.Fatal(err)
}
if len(devices) == 0 {
log.Fatal("No Device")
}
d := devices[0]
imageSignatures, err := d.Images()
if err != nil {
log.Fatalln(err)
}
for i, imgSign := range imageSignatures {
log.Printf("[%d] %s\n", i+1, base64.StdEncoding.EncodeToString(imgSign))
}
dmgPath := "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/14.4/DeveloperDiskImage.dmg"
signaturePath := "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/14.4/DeveloperDiskImage.dmg.signature"
err = d.MountDeveloperDiskImage(dmgPath, signaturePath)
if err != nil {
log.Fatalln(err)
}
}
package main
import (
giDevice "github.com/electricbubble/gidevice"
"log"
"path/filepath"
)
func main() {
usbmux, err := giDevice.NewUsbmux()
if err != nil {
log.Fatalln(err)
}
devices, err := usbmux.Devices()
if err != nil {
log.Fatalln(err)
}
if len(devices) == 0 {
log.Fatalln("No Device")
}
d := devices[0]
bundleID := "com.apple.Preferences"
pid, err := d.AppLaunch(bundleID)
if err != nil {
log.Fatalln(err)
}
err = d.AppKill(pid)
if err != nil {
log.Fatalln(err)
}
runningProcesses, err := d.AppRunningProcesses()
if err != nil {
log.Fatalln(err)
}
for _, process := range runningProcesses {
if process.IsApplication {
log.Printf("%4d\t%-24s\t%-36s\t%s\n", process.Pid, process.Name, filepath.Base(process.RealAppName), process.StartDate)
}
}
}
package main
import (
giDevice "github.com/electricbubble/gidevice"
"image"
"image/jpeg"
"image/png"
"log"
"os"
)
func main() {
usbmux, err := giDevice.NewUsbmux()
if err != nil {
log.Fatalln(err)
}
devices, err := usbmux.Devices()
if err != nil {
log.Fatalln(err)
}
if len(devices) == 0 {
log.Fatalln("No Device")
}
d := devices[0]
raw, err := d.Screenshot()
if err != nil {
log.Fatalln(err)
}
img, format, err := image.Decode(raw)
if err != nil {
log.Fatalln(err)
}
userHomeDir, _ := os.UserHomeDir()
file, err := os.Create(userHomeDir + "/Desktop/s1." + format)
if err != nil {
log.Fatalln(err)
}
defer func() { _ = file.Close() }()
switch format {
case "png":
err = png.Encode(file, img)
case "jpeg":
err = jpeg.Encode(file, img, nil)
}
if err != nil {
log.Fatalln(err)
}
log.Println(file.Name())
}
package main
import (
giDevice "github.com/electricbubble/gidevice"
"log"
)
func main() {
usbmux, err := giDevice.NewUsbmux()
if err != nil {
log.Fatalln(err)
}
devices, err := usbmux.Devices()
if err != nil {
log.Fatalln(err)
}
if len(devices) == 0 {
log.Fatalln("No Device")
}
d := devices[0]
// https://api.map.baidu.com/lbsapi/getpoint/index.html
if err = d.SimulateLocationUpdate(116.024067, 40.362639, giDevice.CoordinateSystemBD09); err != nil {
log.Fatalln(err)
}
// https://developer.amap.com/tools/picker
// https://lbs.qq.com/tool/getpoint/index.html
// if err = d.SimulateLocationUpdate(120.116979, 30.252876, giDevice.CoordinateSystemGCJ02); err != nil {
// log.Fatalln(err)
// }
// if err = d.SimulateLocationUpdate(121.499763, 31.239580,giDevice.CoordinateSystemWGS84); err != nil {
// if err = d.SimulateLocationUpdate(121.499763, 31.239580); err != nil {
// log.Fatalln(err)
// }
// err = d.SimulateLocationRecover()
// if err != nil {
// log.Fatalln(err)
// }
}
1
janxin 2021-05-13 07:21:55 +08:00 via iPhone 1
桥了一下 libimobiledevice ?
|
2
hongxi2200 OP @janxin
是哒,不过没抄全,只实现了基本功能。。 |
3
janxin 2021-05-13 08:57:57 +08:00 via iPhone
@hongxi2200 🐂体力活啊
|
4
learningman 2021-05-13 09:10:29 +08:00 via Android
一眼看成 Google 实现的。。。
|
5
hongxi2200 OP @janxin
抄作业而已。。。 |
6
hongxi2200 OP @learningman
是用的 `Golang` 翻译了 [libimobiledevice]( https://github.com/libimobiledevice/libimobiledevice) 的代码呀 |
7
dxatgp02 2021-05-13 10:31:26 +08:00
用这工具能做什么事?
|
8
hongxi2200 OP @work19990909
已实现功能: - 设备列表查询 - 开发者镜像挂载 - App 启 /停 /卸载 /安装 - 端口转发 - 截图 - XCTest - Syslog - CrashReport - 沙盒文件访问 - 定位修改 /恢复 - Pair |
9
hongxi2200 OP @work19990909
电脑连上 iOS 设备 就可以干这些事儿 |
10
dxatgp02 2021-05-13 11:11:33 +08:00
@hongxi2200 厉害,等于实现远程启动 APP
|
11
hongxi2200 OP |
12
95276 2021-05-14 11:25:36 +08:00
楼主厉害,这个修改一下搞到一个小型 linux 设备上就可以随时改定位了.
市场上好像有这种东西. |
13
hongxi2200 OP @95276
以前在淘宝上看到过有人卖 C# 版的。。 |
14
hongxi2200 OP |
15
visionsmile 2021-08-19 10:46:32 +08:00
请问能实现端口的 reverse 反向转发吗?把 PC/Mac 的端口转发到 IOS 上。
|