最近有需求需要通过MAC程序查看通过usb链接的硬件设备的信息,比如通过Mac系统查看手机的uuid,串号,五码,基带等信息,类似沙漏助手,爱思助手等,现在网上有一个著名的开源库,libimobiledevice,感觉和安卓的ADB有一拼,感谢前辈们的付出,但是这次我们不仅仅讲这个库的使用,我一个前同事(**杰同学)告诉我一个他们做mac程序时,查看硬件设备的一个终端命令,汇总来说,一共2个可以在命令行使用的工具,在此记录一下,方便自己以后学习使用,
libimobiledevice
安装方式:
brew install --HEAD libimobiledevice //brew的默认已经安装,如没有安装,自行查找安装方式 带参数HEAD安装最新版
brew install --HEAD ideviceinstaller //这个是安装ipa的一个库,可以顺便安装上,
常见用法:
附带官方使用介绍
查看当前的移动设备列表
idevice_id -l // 显示当前所连接的设备信息,包括 usb、WiFi 连接
安装ipa应用到iphone上
ideviceinstaller -u [udid] -i [xxx.ipa] #xxx.ipa:安装文件路径
重启设备
idevicediagnostics restart //设备重启
查看设备信息
ideviceinfo -u UDID
信息大概如下:
deviceinfo -u 3d92bfe127fd1e75f07ecb4cddb5732650b212fc
ActivationState: Activated
ActivationStateAcknowledged: true
BasebandActivationTicketVersion: V2
BasebandCertId: 2315222105
BasebandChipID: 9781473
BasebandKeyHashInformation:
AKeyStatus: 2
SKeyHash: u+/tcCwvaQ+1Y9t40I4yegCEmB28mALlaROhaIVGBWo=
SKeyStatus: 0
BasebandMasterKeyHash: 8CB15EE4C8002199070D9500BB8FB183B02713A5CA2A6B92DB5E75CE15536182
BasebandRegionSKU: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
BasebandSerialNumber: M8D5eQ==
BasebandStatus: BBInfoAvailable
BasebandVersion: 5.30.00
BluetoothAddress: cc:08:8d:e0:ef:e1
BoardId: 8
BrickState: false
BuildVersion: 16D57
CPUArchitecture: arm64
CarrierBundleInfoArray[1]:
0:
CFBundleIdentifier: com.apple.ChinaTelecom_USIM_cn
CFBundleVersion: 35.0.1
IntegratedCircuitCardIdentity: 89860316740103990298
InternationalMobileSubscriberIdentity: 460110015269713
MCC: 460
MNC: 11
MobileEquipmentIdentifier: 359168*****781
Slot: kOne
kCTPostponementInfoAvailable: SIMCarrierInfo
CertID: 2315222105
ChipID: 32784
ChipSerialNo: M8D5eQ==
DeviceClass: iPhone
DeviceColor: 2
DeviceName:11的iPhone
DieID: 7394096112599098
EthernetAddress: cc:08:8d:e0:ef:e2
FirmwareVersion: iBoot-4513.230.10
FusingStatus: 3
HardwareModel: D10AP
HardwarePlatform: t8010
HasSiDP: true
HostAttached: true
IntegratedCircuitCardIdentity: 89860316740103990298
InternationalMobileEquipmentIdentity: 359168073637813
InternationalMobileSubscriberIdentity: 460110015269713
InternationalMobileSubscriberIdentityOverride: false
MLBSerialNumber: F3X63250F6***6TFA
MobileEquipmentIdentifier: 35916***363781
MobileSubscriberCountryCode:
MobileSubscriberNetworkCode: 11
ModelNumber: MNGW2
NonVolatileRAM:
auto-boot: dHJ1ZQ==
backlight-level: MTUxMA==
boot-args:
com.apple.System.tz0-size: MHhDMDAwMDA=
oblit-begins: T2JsaXRUeXBlOiBPYmxpdGVyYXRlRGF0YVBhcnRpdGlvbi4gUmVhc29uOiB1bmtub3du
obliteration: aGFuZGxlX21lc3NhZ2U6IE9ibGl0ZXJhdGlvbiBDb21wbGV0ZQo=
PRIVersion_Major: 0
PRIVersion_Minor: 1
PRIVersion_ReleaseNo: 191
PartitionType: GUID_partition_scheme
PasswordProtected: false
PhoneNumber: +86 181 **** 5772
PkHash: if98WU1oTt+jcaZlvUC9AOG/rlbJxZpIN+cg7Rv1bCY=
ProductName: iPhone OS
ProductType: iPhone9,1
ProductVersion: 12.1.4
ProductionSOC: true
ProtocolVersion: 2
ProximitySensorCalibration: f3oABTIAHgD5oNhBpb34QQAAyEKoNbtBUVrEQQAAFkOoNbtBUVrEQQAAFkOmWz5DzF3qQMNls0RxxbNEcS20RCkEtETKshlCSBAaQvT9G0IHzh5CAAAgQv60H0NpLz9CAABIQuAJ9EOTSPNDB2EbRotsl0PvgF0dAh0IEn31pUUvjcJDrtOvRQIAAAAAAAAT
RegionInfo: CH/A
SIMStatus: kCTSIMSupportSIMStatusReady
SIMTrayStatus: kCTSIMSupportSIMTrayInsertedWithSIM
SerialNumber: DNQS70TQHG70
SoftwareBehavior: QQEAAAAAAAAAAAAAAAAAAA==
SoftwareBundleVersion:
SupportedDeviceFamilies[1]:
0: 1
TelephonyCapability: true
TimeIntervalSince1970: 1582305212.829859
TimeZone: Asia/Shanghai
TimeZoneOffsetFromUTC: 28800.000000
TrustedHostAttached: true
UniqueChipID: 7394096112599098
UniqueDeviceID: 3d92bfe127fd1b4cddb5732650b212fc
UseRaptorCerts: true
Uses24HourClock: false
WiFiAddress: cc:08:8d:e0:ef:e0
WirelessBoardSerialNumber: 6714B8F011C
kCTPostponementInfoPRIVersion: 0.1.191
kCTPostponementInfoPRLName: 301
kCTPostponementInfoServiceProvisioningState: true
kCTPostponementStatus: kCTPostponementStatusActivated
查看系统日志log
idevicesyslog
//ERROR: Could not start service com.apple.syslog_relay.
//Could not start logger for udid 3d92bfe127fd1e75f07ecb4cddb5732650b212fc
//如果遇到上面的错误,终端执行命令 sudo chmod -R 777 /var/db/lockdown
如果遇到错误 ERROR: Could not connect to lockdownd, error code -3
那只能卸载重装了
brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice
brew install ideviceinstaller
system_profiler
这个命令更适用于查看Mac上的硬件信息,移动设备,usb设备比较少
常见用法:
附带官方使用方法地址
Usage: system_profiler [-listDataTypes]
system_profiler [-xml] [-timeout n] [-detailLevel n]
system_profiler [-xml] [-timeout n] [dataType1 ... dataTypeN]
-detailLevel n specifies the level of detail for the report
mini = short report (contains no identifying or personal information)
basic = basic hardware and network information
full = all available information
-listDataTypes lists all the available datatypes
-xml generates xml output instead of plain text
if redirected to a file with the extension ".spx"
the file can be opened in System Profiler.app
-timeout specifies the maximum time to spend gathering information
the default is 180 seconds, 0 means no timeout
Redirect stderr to /dev/null to suppress progress and error messages.
Examples:
system_profiler
Generates a text report with the standard detail level.
system_profiler -detailLevel mini
Generates a short report without identifying/personal information.
system_profiler -listDataTypes
Shows a list of the available data types.
system_profiler SPSoftwareDataType SPNetworkDataType
Generates a text report containing only software and network data.
system_profiler -xml >MySystem.spx
Creates a XML file which can be opened by System Profiler.app
常用的命令:
查看一下当前USB设备连接的Iphone的UDID,
system_profiler SPUSBDataType | grep "Serial Number:.*" | sed s#".*Serial Number: "##'
生成完整的设备信息报告到桌面
system_profiler -detailLevel >~/Desktop/info.txt
生成的电脑上的信息特别完整,稍微截图一点,我尝试生成完整信息到桌面的文件,导出的txt文档大概3.2M,包括所有的硬件软件信息,有兴趣的同学可以尝试,也可以查看当前USB设备的信息可见数据源,稍微截图一些看一下
也可以查看Mac电脑上App的签名信息
如上,记录一下,之后再补充libimobiledevice相关的,向爱思助手等工具学习