Skip to content

Instantly share code, notes, and snippets.

@bih
Last active April 12, 2025 01:53
Show Gist options
  • Save bih/0e7f7e0e8d3483469be6 to your computer and use it in GitHub Desktop.
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)
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
@fffelix-jan
Copy link

Gorencesdfd

Stop shilling for TunesKit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment