Last active
April 12, 2025 01:53
-
-
Save bih/0e7f7e0e8d3483469be6 to your computer and use it in GitHub Desktop.
Get all of your iPhone data via USB (relies on libimobiledevice - https://github.com/libimobiledevice/libimobiledevice)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "json" | |
class IOS | |
def self.get | |
q = `ideviceinfo` | |
IOS.new(q.split("\n").map{ |item| k, v = item.split(": ", 2); { k.strip.to_sym => v.strip }}) | |
rescue | |
nil | |
end | |
def initialize(data) | |
@data = {} | |
data.each do |each_data| | |
@data.merge!(each_data) | |
end | |
end | |
def name | |
@data[:DeviceName] | |
end | |
def class | |
@data[:DeviceClass] | |
end | |
def iphone? | |
@data[:DeviceClass] == "iPhone" | |
end | |
def ipad? | |
@data[:DeviceClass] == "iPad" | |
end | |
def ipod? | |
@data[:DeviceClass] == "iPod" | |
end | |
def password? | |
@data[:PasswordProtected] == "true" | |
end | |
def trusted? | |
@data[:TrustedHostAttached] == "true" | |
end | |
def activated? | |
@data[:ActivationState] == "Activated" | |
end | |
def mobileNetwork | |
@data[:CFBundleIdentifier][10..-1] | |
end | |
def mobileNumber | |
@data[:PhoneNumber].delete(" ") | |
end | |
def countryCode | |
@data[:PhoneNumber][1..3].strip | |
end | |
def ethernet | |
@data[:EthernetAddress] | |
end | |
def wifi | |
@data[:WiFiAddress] | |
end | |
def clock_24_hour? | |
@data[:Uses24HourClock] == "true" | |
end | |
def clock_12_hour? | |
@data[:Uses24HourClock] == "false" | |
end | |
def timezone | |
@data[:TimeZone] | |
end | |
def take_screenshot! | |
file = `idevicescreenshot`.split(" ").last | |
f = File.read(file) | |
File.unlink(file) | |
f | |
end | |
def time | |
Time.at(@data[:TimeIntervalSince1970].to_f) | |
end | |
# def to_s | |
# @data.map{ |k, v| { k => v }}.join("\n") | |
# end | |
end | |
while true | |
if (ios = IOS.get).nil? | |
puts ".. Attempting to find an iPhone connected." | |
else | |
puts "*" * 40 | |
puts "----- iPhone Found and Connected -----" | |
puts "Device Name: #{ios.name}" | |
puts "Device Class: #{ios.class}" | |
puts "Mobile Number: #{ios.mobileNumber}" | |
puts "Wi-Fi Address: #{ios.wifi}" | |
puts "Ethernet Address: #{ios.ethernet}" | |
puts "Time Zone: #{ios.timezone}" | |
puts "*" * 40 | |
break | |
end | |
sleep 2 | |
end | |
# puts IOS.get | |
# puts IOS.get.countryCode |
Stop shilling for TunesKit!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To be honest, it is too difficult for me to learn how to get iPhone data in this way. The easy way for me to get all lost or deleted iPhone data is to use a iPhone data recovery software. It is for all iOS users to recover photos, contacts, notes, messages, videos, music, calendars, whatsapp messages, etc from iPhone, iPad, iPod, iTunes/iCloud backup files in 3 steps.