Class: IOS10ApplicationStateDbWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/ios10_application_state_db_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initializeIOS10ApplicationStateDbWrapper

Returns a new instance of IOS10ApplicationStateDbWrapper.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/lib/ios10_application_state_db_wrapper.rb', line 5

def initialize
  @db_file = "/User/Library/FrontBoard/applicationState.db"

  @cache_path = "#{$tmp_path}/device/applicationState.db"

  @ldid_binary = "/usr/bin/ldid"



  # download latest db file
  FileUtils.mkpath "#{$tmp_path}/device" unless File.directory? "#{$tmp_path}/device"
  $device.ops.download @db_file, @cache_path

end

Instance Method Details

#data_path_by_bundle_id(bundle_id) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/lib/ios10_application_state_db_wrapper.rb', line 34

def data_path_by_bundle_id(bundle_id)

  #puts @cache_path
  db = SQLite3::Database.open @cache_path
  #puts db.inspect

  #puts bundle_id
  plist = ""

  # I fail to get prepared statements to work with SQLite... So using strig concatenation instead. here be dragons
  stmnt = db.prepare "SELECT kvs.value FROM application_identifier_tab left join kvs on application_identifier_tab.id = kvs.application_identifier where kvs.key = 2 and application_identifier_tab.application_identifier='#{bundle_id}'"
  # stmnt.bind_params(bundle_id)
  rs = stmnt.execute
  #
  #binding.pry
  #puts rs.inspect
  row = rs.next
  if row.nil?
    return nil
  end
  #puts row.inspect
  plist = row[0]

  #puts plist

  outer_plist = Plist4r.new({:from_string => plist})
  h = outer_plist.to_hash
  if h.key? "sandboxPath"
    return h["sandboxPath"]
  end
  #puts outer_plist.inspect
  plist = outer_plist.to_hash["String"]
  inner_plist = Plist4r::Plist.new({:from_string => plist})
  return inner_plist.to_hash["$objects"][4]

end

#entitlements_by_binary(binary_path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lib/ios10_application_state_db_wrapper.rb', line 21

def entitlements_by_binary(binary_path)
  unless $device.ops.file_exists?(@ldid_binary)
    $log.error "Cannot find ldid binary at #{@ldid_binary}"
    return ""
  end

  plist = $device.ops.execute("#{@ldid_binary} -e '#{binary_path}'")
  entitlements = Plist4r.new({:from_string => plist})
  puts entitlements
  entitlements
end

#keychain_access_groups_by_binary(binary_path) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/lib/ios10_application_state_db_wrapper.rb', line 71

def keychain_access_groups_by_binary binary_path
  unless $device.ops.file_exists?(@ldid_binary)
    $log.error "Cannot find ldid binary at #{@ldid_binary}"
    return ""
  end

  plist = $device.ops.execute("#{@ldid_binary} -e '#{binary_path}'")
  entitlements = Plist4r.new({:from_string => plist})
  puts entitlements["keychain-access-groups"]
  return entitlements["keychain-access-groups"]
end