electricbubble / gidevice Goto Github PK
View Code? Open in Web Editor NEWcommunicate with iOS devices implemented with Golang
License: MIT License
communicate with iOS devices implemented with Golang
License: MIT License
如题
如题。
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0xabaa90]
goroutine 232 [running]:
github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive.func1()
/home/work/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:323 +0x30
created by github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive
/home/work/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:320 +0x5b
gidevice 开启 XCTest 确认连接状态使用 gwda控制
out, cancel, err := ID.XCTest(bundleID)
if err != nil {
log.Fatal(err)
}
done := make(chan os.Signal, 1)
signal.Notify(done, os.Interrupt)
go func() {
for s := range out {
fmt.Print(s)
has := strings.Contains(s, "Using singleton test manager")
if has {
driver, _ := gwda.NewUSBDriver(nil)
driver.PressButton(gwda.DeviceButtonHome)
driver.SiriActivate("What's the weather like today")
}
}
}()
<-done
cancel()
或者有更好的办法么?
out, cancel, err := d.XCTest("com.aichy.wb.xctrunner")
if err != nil {
log.Fatal(err)
}
这里如果手机连接状态异常比如usb拔掉了或者 XCTest 崩溃了如何监测呢?感谢~
For example
gidevice xctest
我这只有一台测试机,还不知道是不是ios15.5的问题
挂载后直接device.xctest会出现WebDriverAgent server start failed: dtx: get result: timeout after 30.0002822s
有头绪吗
运行命令
./gidevice xctest com.facebook.WebDriverAgentRunner.xctrunner -u xxxx --env=USE_PORT=8100 --env=MJPEG_SERVER_PORT=9100
执行一段时间后,运行基于 appium 的 UI 自动化脚本时,出现如下报错然后自动退出:
t = 3505.76s Requesting snapshot of accessibility hierarchy for app with pid 566
t = 3506.16s Find: Descendants matching type Any
t = 3506.17s Find: Elements matching predicate '(wdType == "XCUIElementTypeTextField" AND wdValue == "请输入手机号") AND (1 == 1 OR identifier == 0 OR frame == 0 OR value == 0 OR title == 0 OR label == 0 OR elementType == 0 OR enabled == 0 OR placeholderValue == 0 OR selected == 0)'
panic: runtime error: slice bounds out of range [:209106] with capacity 132768
goroutine 8 [running]:
github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).ReceiveDTXMessage(0xc00038b1a0, 0xc000096000, 0x0, 0x0)
/home/runner/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:180 +0x1265
github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive.func1(0xc00038b1a0)
/home/runner/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:326 +0x5e
created by github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive
/home/runner/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:320 +0x3f
目前为偶现,暂时未找到稳定复现步骤。
package main
import (
giDevice "github.com/electricbubble/gidevice"
"github.com/electricbubble/gidevice/pkg/libimobiledevice"
)
func main() {
libimobiledevice.SetDebug(true)
giDevice.NewUsbmux()
}
vendor/github.com/electricbubble/gidevice/pkg/ipa/ipa.go:35:17: undefined: io.ReadAll
我需要初始化什么么?
Can you add watch service also like it's implemented in tidevice?
Doing a GetValue("","") does not return IMEI. How can I gather it? Do I need to use the instruments service?
device.InstallationProxyBrowse(giDevice.WithApplicationType(giDevice.ApplicationTypeUser)) 无论最后有没有加上筛选,获取出来的结果比较少,手机上的抖音等等获取不到
hi, I ran the example code of SimulateLocation
but return error as below
2021/06/12 01:07:39 receive packet: InvalidService
Here is my code and iOS version is 14.0.1
package main
import (
"log"
giDevice "github.com/electricbubble/gidevice"
"github.com/electricbubble/gidevice/pkg/libimobiledevice"
)
func main() {
libimobiledevice.SetDebug(true)
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://developer.amap.com/tools/picker
// https://lbs.qq.com/tool/getpoint/index.html
if err = d.SimulateLocationUpdate(113.925734, 22.511836, giDevice.CoordinateSystemWGS84); err != nil {
log.Fatalln(err)
}
}
I tried to debug this program and found it break at this function
func (c *lockdown) startService(service string, escrowBag []byte) (dynamicPort int, enableSSL bool, err error) {
req := c.client.NewStartServiceRequest(service)
if escrowBag != nil {
req.EscrowBag = escrowBag
}
var pkt libimobiledevice.Packet
if pkt, err = c.client.NewXmlPacket(req); err != nil {
return 0, false, err
}
if err = c.client.SendPacket(pkt); err != nil {
return 0, false, err
}
// returned error InvalidService
respPkt, err := c.client.ReceivePacket()
if err != nil {
return 0, false, err
}
var reply libimobiledevice.LockdownStartServiceResponse
if err = respPkt.Unmarshal(&reply); err != nil {
return 0, false, err
}
if reply.Error != "" {
return 0, false, fmt.Errorf("lockdown start service: %s", reply.Error)
}
dynamicPort = reply.Port
enableSSL = reply.EnableServiceSSL
return
}
Any Suggestion?
When installing a big ipa file (3.3G), it will report error after uploading to PublicStaging:
device_test.go:104: receive packet: read tcp 127.0.0.1:15119->127.0.0.1:27015: wsarecv: An established connection was aborted by the software in your host machine.
It seems like lockdown connection has been closed by the phone.
A simple fix would work:
`
func (d *device) AppInstall(ipaPath string) (err error) {
if _, err = d.AfcService(); err != nil {
return err
}
stagingPath := "PublicStaging"
if _, err = d.afc.Stat(stagingPath); err != nil {
if err != ErrAfcStatNotExist {
return err
}
if err = d.afc.Mkdir(stagingPath); err != nil {
return fmt.Errorf("app install: %w", err)
}
}
var info map[string]interface{}
if info, err = ipa.Info(ipaPath); err != nil {
return err
}
bundleID, ok := info["CFBundleIdentifier"]
if !ok {
return errors.New("can't find 'CFBundleIdentifier'")
}
installationPath := path.Join(stagingPath, fmt.Sprintf("%s.ipa", bundleID))
var data []byte
if data, err = os.ReadFile(ipaPath); err != nil {
return err
}
if err = d.afc.WriteFile(installationPath, data, AfcFileModeWr); err != nil {
return err
}
d.lockdown = nil
if _, err = d.installationProxyService(); err != nil {
return err
}
return d.installationProxy.Install(fmt.Sprintf("%s", bundleID), installationPath)
}
`
Add a d.lockdown = nil before loading installation proxy service.
But I'm not sure that's the best way of fixing.
检测到 electricbubble/gidevice 一共引入了9个开源组件,存在2个漏洞
漏洞标题:go-yaml < 2.2.8拒绝服务漏洞
缺陷组件:gopkg.in/[email protected]
漏洞编号:CVE-2019-11254
漏洞描述:gopkg.in/yaml.v2是go语言中用于处理yaml格式的包。
在2.2.8之前的版本中,处理恶意的yaml数据时,会导致CPU资源耗尽。
漏洞由Kubernetes开发者在fuzz测试中发现并提交修复补丁。
国家漏洞库信息:https://www.cnvd.org.cn/flaw/show/CNVD-2020-35519
影响范围:(∞, 2.2.8)
最小修复版本:2.2.8
缺陷组件引入路径:github.com/electricbubble/gidevice@->gopkg.in/[email protected]
另外还有2个漏洞,详细报告:https://mofeisec.com/jr?p=a68dca
用的过程会有偶现这个报错,一般重试可以正常运行,但是想看看能不能优化一下这部分
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x704070]
goroutine 9 [running]:
github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive.func1()
*********/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:342 +0x30
created by github.com/electricbubble/gidevice/pkg/libimobiledevice.(*dtxMessageClient).startReceive
********/go/pkg/mod/github.com/electricbubble/[email protected]/pkg/libimobiledevice/client_dtxmessage.go:339 +0x56
exit status 2
在开发新的service模块,但是用LockdownBasicResponse解析会有问题,应该是要用自定义的response plist结构解析,但是没法知道原本的xml结构是怎样,有办法吗?
Failed invoking method '_IDE_initiateSessionWithIdentifier:capabilities:' with error: {%!s(uint64=1) DTXMessage map[]}
err := device.MountDeveloperDiskImage(xxx,xxx.sign)
if err != nil {
fmt.Println(err)
}
iOS 15.0,镜像用的这里面的 https://github.com/iGhibli/iOS-DeviceSupport/tree/master/DeviceSupport
err报错提示为 tls: failed to find any PEM data in key input
Starting at iOS 17.0, Apple refactored a lot in the way iOS devices communicate with the macOS. Up until iOS 16, The communication was TCP based (using the help of usbmuxd for USB devices) with TLS (for making sure only trusted peers are able to connect).
Since the above change I am not able to use the screenshot service.
Can someone please look into how to integrate the new service according to new protocol please?
多次重复启动wda会造成失败
详见SonicCloudOrg/sonic-ios-bridge#21
我cli多了自动挂载镜像处理,我这边debug了应该不是cli问题
请问有想法吗?
我启动wda的gofile https://github.com/SonicCloudOrg/sonic-ios-bridge/blob/main/cmd/wda.go
我这边正在基于gidevice开发Go版的性能监控工具,CPU、GPU、流量等功能已正常实现,当尝试实现统计帧率、jank次数、和卡顿率功能时,参考了py-ios-device中获取并解析com.apple.instruments.server.services.coreprofilesessiontap帧渲染数据的逻辑,发现gidevice返回的数据不正常,预期返回的数据长度应该是和py-ios-device一样(64的整数倍),但实际测试返回的数据长度是随机没有规律的,如下图所示:
造成这种现象我觉得最大的可能是调用com.apple.instruments.server.services.coreprofilesessiontap时,传过去的参数没有被正确接受和解析,导致InstrumentsServer返回的不是预期的数据,希望大佬帮忙排查一下,参数结构如下图所示:
Hi, great package first of all!
Can you add ioregistry similar to idevicediagnostics ioregistry
我预计六月份补充一下com.apple.webinspector service implementation.
xctest启动后几分钟不动会断开,访问/status也是死掉了,然后过阵子访问又可以,这情况发生概率有点高。断开期间已确认没有任何wda指令发送过去阻塞。tidevice没有这个问题,不知道是tidevice做的xctest监听异常就杀掉重启的功劳还是底层实现不一样呢?
I want to get battery data.
device.GetValue("com.apple.mobile.battery","")
but I get nil map.
What should I do? thx
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.